```
refactor(task): 重构任务奖励系统,优化任务奖励处理逻辑 移除废弃的任务相关代码文件,包括task/list.go和task/list_daily.go, 以及相关的模型定义config_task表和PetReward服务。 修改任务奖励获取方式,从原有的TaskResultMap改为通过数据库配置获取, 新增TaskService.Get方法用于获取任务配置信息。 --- feat(boss): 优化
This commit is contained in:
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
type PetRewardService struct {
|
||||
@@ -23,3 +25,18 @@ func (s *PetRewardService) GetEgg() model.PetReward {
|
||||
return item
|
||||
|
||||
}
|
||||
func (s *PetRewardService) Get(id uint32) *model.PetReward {
|
||||
if id == 0 {
|
||||
return nil
|
||||
}
|
||||
var item *model.PetReward
|
||||
cool.DBM(s.Model).Where("id", 1).
|
||||
Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
}
|
||||
@@ -48,7 +48,10 @@ func (s *ShinyService) RandShiny(id uint32) *data.GlowFilter {
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
cool.DBM(s.Model).Wheref(`bind_elf_ids @> ?::jsonb`, id).Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Cache(gdb.CacheOption{
|
||||
cool.DBM(s.Model).
|
||||
Wheref(`bind_elf_ids @> ?::jsonb`, id).
|
||||
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").
|
||||
Where("is_enabled", 1).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
@@ -78,11 +81,15 @@ func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter {
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
cool.DBM(s.Model).Wheref(`bind_elf_ids @> ?::jsonb`, id).Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
cool.DBM(s.Model).
|
||||
Wheref(`bind_elf_ids @> ?::jsonb`, id).
|
||||
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").
|
||||
Where("is_enabled", 1).
|
||||
Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&ret)
|
||||
Force: false,
|
||||
}).Scan(&ret)
|
||||
|
||||
rets := utils.ToMap(ret, func(t model.ColorfulSkin) uint32 {
|
||||
return uint32(t.ID)
|
||||
@@ -98,7 +105,7 @@ func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter {
|
||||
r := json.Unmarshal([]byte(v.Color), &t)
|
||||
if r == nil {
|
||||
m := cool.DBM(s.Model).Where("id", id)
|
||||
m.Increment("refresh_count", 1)
|
||||
m.Increment("usage_count", 1)
|
||||
return &t
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
type TaskService struct {
|
||||
@@ -16,3 +18,15 @@ func NewTaskService() *TaskService {
|
||||
},
|
||||
}
|
||||
}
|
||||
func (s *TaskService) Get(id, os uint32) *model.TaskConfig {
|
||||
var item *model.TaskConfig
|
||||
cool.DBM(s.Model).Where("task_id", id).Where("out_state", os).
|
||||
Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user