"refactor(service): 重构服务实例化方式,移除全局变量改用New方法"
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user