fix(cache):修正缓存无法保存纯数字内容的问题。

This commit is contained in:
徐涛
2022-09-06 15:06:34 +08:00
parent a1e9167cdf
commit 8a21a2f469
8 changed files with 31 additions and 14 deletions

View File

@@ -205,7 +205,7 @@ func (_ChargeService) ListPagedChargeRecord(keyword, beginDate, endDate string,
total int64
err error
)
if cachedTotal, _ := cache.RetreiveCount("charge_with_name", condition...); cachedTotal != -1 {
if cachedTotal, err := cache.RetreiveCount("charge_with_name", condition...); cachedTotal != -1 && err == nil {
total = cachedTotal
} else {
total, err = global.DBConn.

View File

@@ -45,7 +45,7 @@ func (_EndUserService) SearchEndUserRecord(reportId, keyword string, page int) (
total int64
err error
)
if cachedTotal, _ := cache.RetreiveCount("end_user_detail", conditions...); cachedTotal != -1 {
if cachedTotal, err := cache.RetreiveCount("end_user_detail", conditions...); cachedTotal != -1 && err == nil {
total = cachedTotal
} else {
total, err = global.DBConn.

View File

@@ -36,7 +36,7 @@ func (_Meter04kVService) ListMeterDetail(park, keyword string, page int) ([]mode
total int64
err error
)
if cachedTotal, _ := cache.RetreiveCount("meter_04kv", condition...); cachedTotal != -1 {
if cachedTotal, err := cache.RetreiveCount("meter_04kv", condition...); cachedTotal != -1 && err == nil {
total = cachedTotal
} else {
total, err = global.DBConn.Where(cond).NoAutoCondition().Count(new(model.Meter04KV))

View File

@@ -461,7 +461,7 @@ func (_ReportService) SearchReport(requestUser, requestPark, requestKeyword stri
total int64
err error
)
if cachedTotal, _ := cache.RetreiveCount("join_report_for_withdraw", conditions...); cachedTotal != -1 {
if cachedTotal, err := cache.RetreiveCount("join_report_for_withdraw", conditions...); cachedTotal != -1 && err == nil {
total = cachedTotal
} else {
total, err := global.DBConn.

View File

@@ -14,7 +14,7 @@ type _StatisticsService struct{}
var StatisticsService _StatisticsService
func (_StatisticsService) EnabledEnterprises() (int64, error) {
if cachedCount, _ := cache.RetreiveCount("enabled_ent"); cachedCount != -1 {
if cachedCount, err := cache.RetreiveCount("enabled_ent"); cachedCount != -1 && err == nil {
return cachedCount, nil
}
c, err := global.DBConn.
@@ -28,7 +28,7 @@ func (_StatisticsService) EnabledEnterprises() (int64, error) {
}
func (_StatisticsService) EnabledParks(userIds ...string) (int64, error) {
if cachedParks, _ := cache.RetreiveCount("enabled_parks", userIds...); cachedParks != -1 {
if cachedParks, err := cache.RetreiveCount("enabled_parks", userIds...); cachedParks != -1 && err == nil {
return cachedParks, nil
}
cond := builder.NewCond().And(builder.Eq{"enabled": true})

View File

@@ -342,7 +342,7 @@ func (_UserService) ListUserDetail(keyword string, userType int, userState *bool
total int64
err error
)
if cacheCounts, _ := cache.RetreiveCount("join_user_detail", cacheConditions...); cacheCounts != -1 {
if cacheCounts, err := cache.RetreiveCount("join_user_detail", cacheConditions...); cacheCounts != -1 && err == nil {
total = cacheCounts
} else {
total, err = global.DBConn.

View File

@@ -85,7 +85,7 @@ func (_WithdrawService) FetchPagedWithdrawApplies(page int, keyword string) ([]m
total int64
err error
)
if cachedTotal, _ := cache.RetreiveCount("join_report_for_withdraw", conditions...); cachedTotal != -1 {
if cachedTotal, err := cache.RetreiveCount("join_report_for_withdraw", conditions...); cachedTotal != -1 && err == nil {
total = cachedTotal
} else {
total, err = global.DBConn.
@@ -134,7 +134,7 @@ func (_WithdrawService) AuditWithdraw(reportId string, granted bool) error {
}
func (_WithdrawService) AuditWaits() (int64, error) {
if cachedWaits, _ := cache.RetreiveCount("withdraw_waits"); cachedWaits != -1 {
if cachedWaits, err := cache.RetreiveCount("withdraw_waits"); cachedWaits != -1 && err == nil {
return cachedWaits, nil
}
cond := builder.NewCond()