forked from free-lancers/electricity_bill_calc_service
feat(user):通过完成用户检索功能,继续确定项目的基本代码结构。
This commit is contained in:
9
cache/search.go
vendored
9
cache/search.go
vendored
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user