This commit is contained in:
wh_zcy 2023-03-17 15:31:50 +08:00
parent adbe3b7415
commit 5080121075
2 changed files with 15 additions and 13 deletions

View File

@ -1,6 +1,7 @@
package rtask
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/redis"
@ -36,7 +37,7 @@ func (this *ModelRtask) updateUserRtaskId(uid string, rtaskId int32) (err error)
return this.moduleRtask.ModuleUser.ChangeUserExpand(uid, ex_update)
}
//查询用户随机任务
// 查询用户随机任务
func (this *ModelRtask) GetRtask(uid string) *pb.DBRtask {
rtask := &pb.DBRtask{Uid: uid}
err := this.Get(uid, rtask)
@ -79,16 +80,23 @@ func (this *ModelRtask) checkCondi(uid string, condiId int32) (err error, ok boo
}
//验证限定条件
var condi *rtaskCondi
if condi, ok = this.moduleRtask.handleMap[condiId]; !ok {
cond, ok := this.moduleRtask.handleMap.Load(condiId)
if !ok {
errors.Errorf("condiID: %v handle no found", condiId)
return
}
if condi, ok = cond.(*rtaskCondi); !ok {
err = fmt.Errorf("condiType err")
return
}
if condi.verify == nil {
errors.Errorf("condiID: %v", condiId)
return
}
conf, err:= this.moduleRtask.configure.getRtaskTypeById(condiId)
if err!= nil {
conf, err := this.moduleRtask.configure.getRtaskTypeById(condiId)
if err != nil {
errors.Errorf("conf not found condiID: %v", condiId)
return
}

View File

@ -41,13 +41,12 @@ type ModuleRtask struct {
modelRtaskRecord *ModelRtaskRecord
api *apiComp
configure *configureComp
lock sync.Mutex
handleMap map[int32]*rtaskCondi //任务校验处理器
handleMap sync.Map //map[int32]*rtaskCondi //任务校验处理器
}
func NewModule() core.IModule {
return &ModuleRtask{
handleMap: make(map[int32]*rtaskCondi),
// handleMap: make(map[int32]*rtaskCondi),
}
}
@ -76,12 +75,7 @@ func (this *ModuleRtask) OnInstallComp() {
}
func (this *ModuleRtask) registerVerifyHandle(condiId int32, condi *rtaskCondi) {
// if _, ok := this.handleMap[condiId]; !ok {
// this.handleMap[condiId] = condi
// }
this.lock.Lock()
defer this.lock.Unlock()
this.handleMap[condiId] = condi
this.handleMap.Store(condiId, condi)
}
func (this *ModuleRtask) getHandle(tt comm.TaskType) (condis []*rtaskCondi) {