2025-12-31 18:58:44 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/cool"
|
|
|
|
|
"blazing/modules/config/model"
|
2025-12-31 21:00:29 +08:00
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
2025-12-31 18:58:44 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type TaskService struct {
|
|
|
|
|
*cool.Service
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewTaskService() *TaskService {
|
|
|
|
|
return &TaskService{
|
|
|
|
|
&cool.Service{
|
|
|
|
|
Model: model.NewTaskConfig(),
|
2026-01-01 19:57:39 +08:00
|
|
|
PageQueryOp: &cool.QueryOp{
|
|
|
|
|
FieldEQ: []string{"task_type"},
|
|
|
|
|
},
|
2026-01-01 15:37:43 +08:00
|
|
|
//UniqueKey: map[string]string{"task_id": "索引不能重复"},
|
2025-12-31 18:58:44 +08:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-12-31 21:00:29 +08:00
|
|
|
func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
|
2026-01-01 19:57:39 +08:00
|
|
|
var item []model.TaskConfig
|
|
|
|
|
cool.DBM(s.Model).Where("task_id", id).
|
2025-12-31 21:00:29 +08:00
|
|
|
Cache(gdb.CacheOption{
|
|
|
|
|
// Duration: time.Hour,
|
|
|
|
|
|
|
|
|
|
Force: false,
|
|
|
|
|
}).Scan(&item)
|
2026-01-01 19:57:39 +08:00
|
|
|
var res *model.TaskConfig
|
|
|
|
|
if len(item) == 1 { //只有一个直接默认
|
|
|
|
|
res = &item[0]
|
|
|
|
|
}
|
|
|
|
|
if len(item) > 1 { //
|
2025-12-31 21:00:29 +08:00
|
|
|
|
2026-01-01 19:57:39 +08:00
|
|
|
for _, v := range item {
|
|
|
|
|
if v.OutState == os {
|
|
|
|
|
res = &item[os]
|
|
|
|
|
return res
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res
|
2025-12-31 21:00:29 +08:00
|
|
|
|
|
|
|
|
}
|
2026-01-01 15:37:43 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
}
|