feat(user):通过完成用户检索功能,继续确定项目的基本代码结构。

This commit is contained in:
徐涛
2023-06-01 12:04:03 +08:00
parent 71f39c8c2f
commit 9aa32d99b9
7 changed files with 219 additions and 10 deletions

9
cache/search.go vendored
View File

@@ -1,11 +1,16 @@
package cache
import (
"electricity_bill_calc/logger"
"fmt"
"strings"
"time"
"go.uber.org/zap"
)
var log = logger.Named("Cache")
func assembleSearchKey(entityName string, additional ...string) string {
var keys = make([]string, 0)
keys = append(keys, strings.ToUpper(entityName))
@@ -70,6 +75,10 @@ func RetrievePagedSearch[T any](entityName string, conditions ...string) (*T, in
if err != nil {
return nil, -1, err
}
if instance == nil || count == nil {
log.Warn("检索结果或者检索总数为空。", zap.String("searchKey", searchKey), zap.String("countKey", countKey))
return nil, -1, nil
}
return instance, count.Count, nil
}