"refactor(service): 重构服务实例化方式,移除全局变量改用New方法"

This commit is contained in:
1
2025-12-22 14:10:22 +00:00
parent cf7736a3e7
commit c19a268b7b
7 changed files with 13 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ import (
"blazing/cool"
"blazing/modules/config/model"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/util/grand"
)
@@ -15,7 +16,11 @@ type ItemService struct {
func (s *ItemService) GetItemCount(id uint32) uint32 {
var item model.ItemGift
cool.DBM(s.Model).Where("id", id).Scan(&item)
cool.DBM(s.Model).Where("id", id).Cache(gdb.CacheOption{
// Duration: time.Hour,
Force: false,
}).Scan(&item)
if item.ItemID == 0 {
return 0
@@ -35,5 +40,3 @@ func NewItemService() *ItemService {
},
}
}
var Items = NewItemService()