feat(config): 更新商品配置模型和任务服务查询功能 - 将商品描述字段从 Description 改为 Desc,优化字段命名 - 将价格字段类型从 uint32 改为 int32,支持负数价格表示 - 更新价格信息注释说明,明确 -1 代表不允许购买的含义 - 移除商品分类字段,简化商品配置结构 - 移除备注信息字段,精简数据模型 - 为任务服务添加关键词
66 lines
1.1 KiB
Go
66 lines
1.1 KiB
Go
package service
|
|
|
|
import (
|
|
"blazing/cool"
|
|
"blazing/modules/config/model"
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
|
)
|
|
|
|
type TaskService struct {
|
|
*cool.Service
|
|
}
|
|
|
|
func NewTaskService() *TaskService {
|
|
return &TaskService{
|
|
&cool.Service{
|
|
Model: model.NewTaskConfig(),
|
|
PageQueryOp: &cool.QueryOp{
|
|
FieldEQ: []string{"task_type"},
|
|
KeyWordField: []string{"remark"},
|
|
},
|
|
//UniqueKey: map[string]string{"task_id": "索引不能重复"},
|
|
},
|
|
}
|
|
}
|
|
func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
|
|
var item []model.TaskConfig
|
|
dbm(s.Model).Where("task_id", id).Scan(&item)
|
|
var res *model.TaskConfig
|
|
if len(item) == 1 { //只有一个直接默认
|
|
if item[0].OutState == os {
|
|
res = &item[0]
|
|
}
|
|
if item[0].OutState < 10 {
|
|
res = &item[0]
|
|
}
|
|
|
|
}
|
|
if len(item) > 1 { //
|
|
|
|
for _, v := range item {
|
|
if v.OutState == os {
|
|
res = &item[os]
|
|
return res
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|
|
func (s *TaskService) GetDaily() []model.TaskConfig {
|
|
var item []model.TaskConfig
|
|
cool.DBM(s.Model).Where("task_type", 1).
|
|
Cache(gdb.CacheOption{
|
|
// Duration: time.Hour,
|
|
|
|
Force: false,
|
|
}).Scan(&item)
|
|
|
|
return item
|
|
|
|
}
|