fix version 1

This commit is contained in:
2026-09-22 21:15:34 +08:00
parent 9f86366638
commit d63d7e8b3a
277 changed files with 9959 additions and 1514 deletions

View File

@@ -4,6 +4,7 @@ import (
"bsm/full/module/base/initial/internal/impl"
"bsm/full/module/base/initial/internal/models"
pb "bsm/full/module/base/initial/pb"
"git.apinb.com/bsm-sdk/core/errcode"
"git.apinb.com/bsm-sdk/core/vars"
)
@@ -23,16 +24,22 @@ func GetAreasByCache(in *pb.AreasRequest) ([]*models.InitialAreas, error) {
val = in.GetCountryId()
}
cacheKey := impl.RedisService.BuildKey("areas", key, val, in.ShowTown)
// 缓存键只包含实际参与查询的条件show_town 在现有模型下无对应列,不参与查询)
cacheKey := impl.RedisService.BuildKey("areas", key, val)
err := impl.RedisService.Get(cacheKey, &areas)
if err == nil {
return areas, nil
}
err = impl.DBService.Where("enabled = ?", true).Where(key, val).Where("show_town = ?", in.ShowTown).
Order("sort_order ASC, name ASC").
// 按模型真实列查询InitialAreas 没有 enabled/show_town/sort_order 列)
err = impl.DBService.Where(key, val).
Order("name ASC").
Find(&areas).Error
if err != nil {
// 查询失败不写缓存,避免空结果污染缓存
return nil, errcode.ErrDB
}
err = impl.RedisService.Set(cacheKey, areas, vars.DefaultTTL)
return areas, err