```
feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
This commit is contained in:
58
modules/player/service/task.go
Normal file
58
modules/player/service/task.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/model"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// 获取任务信息
|
||||
func (s *TaskService) Exec(id uint32, t func(*model.TaskEX) bool) {
|
||||
var gg model.TaskEX
|
||||
m1 := s.PModel(s.Model).Where("task_id", id)
|
||||
m1.Scan(&gg)
|
||||
tre := t(&gg)
|
||||
if !tre { //不需要更新
|
||||
return
|
||||
}
|
||||
gg.PlayerID = uint64(s.userid)
|
||||
gg.TaskID = id
|
||||
_, err := m1.Save(gg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// IsToday 判断给定时间是否是今天
|
||||
func IsToday(t1 *gtime.Time) bool {
|
||||
if t1 == nil {
|
||||
return false
|
||||
}
|
||||
t := t1.Time
|
||||
|
||||
// 获取当前时间
|
||||
now := time.Now()
|
||||
|
||||
// 比较年、月、日是否相同
|
||||
return t.Year() == now.Year() &&
|
||||
t.Month() == now.Month() &&
|
||||
t.Day() == now.Day()
|
||||
}
|
||||
|
||||
type TaskService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
func NewTaskService(id uint32) *TaskService {
|
||||
return &TaskService{
|
||||
|
||||
BaseService: BaseService{userid: id,
|
||||
|
||||
Service: &cool.Service{Model: model.NewTask()},
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user