- 在多个战斗控制器方法中添加 defer 调用,确保战斗操作正确延迟执行 - 修改 ChangePet 方法返回值类型,增强接口一致性 - 修复战斗准备阶段逻辑,重构战斗开始信息构建过程 - 移除冗余广播调用,调整 PVE 战斗初始化流程 - 更新 README 中的 pprof 命令地址并完善项目介绍部分 fix(effect): 修复效果叠加逻辑与ID解析问题 - 效果叠加时默认增加一层,而非直接相加参数 - 修正 EffectIDCombiner 类型、CatchTime 的掩码偏移计算错误 - 添加重复效果日志输出,便于调试追踪 feat(boss): 完善BOSS特性实现逻辑 - 修正 NewSel17 特性
109 lines
2.3 KiB
Go
109 lines
2.3 KiB
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"blazing/cool"
|
|
|
|
"blazing/modules/dict/model"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
)
|
|
|
|
type DictInfoService struct {
|
|
*cool.Service
|
|
}
|
|
|
|
// func init() {
|
|
|
|
// t, _ := NewDictInfoService().Data(context.TODO(), []string{"mapid"})
|
|
// fmt.Println(t)
|
|
|
|
// }
|
|
|
|
// Data方法, 用于获取数据
|
|
func (s *DictInfoService) Data(ctx context.Context, types []string) (data interface{}, err error) {
|
|
var (
|
|
dictInfoModel = model.NewDictInfo()
|
|
dictTypeModel = model.NewDictType()
|
|
)
|
|
mType := cool.DBM(dictTypeModel)
|
|
// 如果types不为空, 则查询指定类型的数据
|
|
if len(types) > 0 {
|
|
mType = mType.Where("key in (?)", types)
|
|
}
|
|
// 查询所有类型
|
|
typeData, err := mType.All()
|
|
// 如果typeData为空, 则返回空
|
|
if typeData.IsEmpty() {
|
|
return g.Map{}, nil
|
|
}
|
|
data = g.Map{}
|
|
for _, v := range typeData {
|
|
m := cool.DBM(dictInfoModel)
|
|
result, err := m.Where("typeId", v["id"]).Fields("id", "name", "parentId", "typeId").Order("ordernum asc").All()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if result.IsEmpty() {
|
|
continue
|
|
}
|
|
data.(g.Map)[v["key"].String()] = result
|
|
}
|
|
return
|
|
}
|
|
|
|
// ModifyAfter 修改后
|
|
func (s *DictInfoService) ModifyAfter(ctx context.Context, method string, param map[string]interface{}) (err error) {
|
|
if method == "Delete" {
|
|
// 删除后,同时删除子节点
|
|
ids, ok := param["ids"]
|
|
if !ok {
|
|
return
|
|
}
|
|
for _, v := range ids.([]interface{}) {
|
|
err = delChildDict(gconv.Int64(v))
|
|
if err != nil {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// delChildDict 删除子字典
|
|
func delChildDict(id int64) error {
|
|
var (
|
|
dictInfoModel = model.NewDictInfo()
|
|
)
|
|
m := cool.DBM(dictInfoModel)
|
|
result, err := m.Where("parentId=?", id).Fields("id").All()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result.IsEmpty() {
|
|
return nil
|
|
}
|
|
for _, v := range result {
|
|
delChildDict(v["id"].Int64())
|
|
}
|
|
_, err = m.Where("parentId=?", id).Delete()
|
|
return err
|
|
}
|
|
|
|
// NewDictInfoService 初始化 DictInfoService
|
|
func NewDictInfoService() *DictInfoService {
|
|
return &DictInfoService{
|
|
&cool.Service{
|
|
UniqueKey: map[string]string{"name": "名称不能重复"},
|
|
Model: model.NewDictInfo(),
|
|
ListQueryOp: &cool.QueryOp{
|
|
FieldEQ: []string{"typeId"},
|
|
KeyWordField: []string{"name"},
|
|
AddOrderby: g.MapStrStr{"createTime": "ASC"},
|
|
},
|
|
},
|
|
}
|
|
}
|