Files
bl/modules/config/service/map_model.go
昔念 f810a2ae86
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
```
feat(pet): 宠物系统重构和功能增强

- 修复战斗boss中effect ID索引错误问题
- 实现宠物仓库和背包管理功能
- 添加宠物列表排序保存功能
- 重构宠物备份列表同步逻辑
- 优化宠物释放和获取逻辑
- 添加宠物背包仓库切换功能
- 修复地图模型广播信息结构问题
- 调整宠物特效数据库查询逻辑
```
2026-04-02 07:49:49 +08:00

86 lines
1.8 KiB
Go

package service
import (
"blazing/cool"
"blazing/modules/config/model"
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/util/gconv"
)
type MapmodelService struct {
*cool.Service
}
func NewMapmodelService() *MapmodelService {
return &MapmodelService{
&cool.Service{
Model: model.NewMapModel(),
PageQueryOp: &cool.QueryOp{
KeyWordField: []string{"remake"},
FieldEQ: []string{"map_id"},
},
ListQueryOp: &cool.QueryOp{
KeyWordField: []string{"remake"},
FieldEQ: []string{"map_id"},
},
},
}
}
func (s *MapmodelService) appendShinyFilter(item map[string]interface{}) map[string]interface{} {
if item == nil {
return item
}
shinyID := gconv.Int(item["shiny"])
if shinyID <= 0 {
shinyID = gconv.Int(item["shinyid"])
}
if shinyID <= 0 {
item["shiny_filter"] = nil
return item
}
item["shiny_filter"] = NewShinyService().GetShiny(shinyID)
return item
}
func (s *MapmodelService) ServiceInfo(ctx context.Context, req *cool.InfoReq) (data interface{}, err error) {
result, err := s.Service.ServiceInfo(ctx, req)
if err != nil || result == nil {
return result, err
}
record, ok := result.(gdb.Record)
if !ok || record.IsEmpty() {
return result, err
}
return s.appendShinyFilter(record.Map()), nil
}
func (s *MapmodelService) ServiceList(ctx context.Context, req *cool.ListReq) (data interface{}, err error) {
result, err := s.Service.ServiceList(ctx, req)
if err != nil || result == nil {
return result, err
}
rows, ok := result.(gdb.Result)
if !ok {
return result, err
}
list := make([]map[string]interface{}, 0, len(rows))
for _, row := range rows {
list = append(list, s.appendShinyFilter(row.Map()))
}
return list, nil
}
func (s *MapmodelService) GetDataByModelId(modelid uint32) (ret *model.MapModel) {
dbm_notenable(s.Model).Where("id", modelid).Scan(&ret)
return
}