Files
bl/modules/config/service/fight_rule_service.go
xinian 1969c01f3e
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
feat: 添加战胜规则配置模块
2026-03-21 00:57:18 +08:00

42 lines
1.0 KiB
Go

package service
import (
"blazing/cool"
"blazing/modules/config/model"
)
type FightRuleService struct {
*cool.Service
}
// GetByRuleIdx 根据规则索引查询规则配置
func (s *FightRuleService) GetByRuleIdx(ruleIdx uint32) *model.FightRule {
var rule *model.FightRule
dbm_notenable(s.Model).Where("rule_idx", ruleIdx).Scan(&rule)
return rule
}
// GetByRuleIdxs 根据规则索引批量查询规则配置
func (s *FightRuleService) GetByRuleIdxs(ruleIdxs []uint32) []model.FightRule {
var rules []model.FightRule
dbm_notenable(s.Model).WhereIn("rule_idx", ruleIdxs).Scan(&rules)
return rules
}
func NewFightRuleService() *FightRuleService {
return &FightRuleService{
&cool.Service{
Model: model.NewFightRule(),
UniqueKey: map[string]string{"idx_rule_idx": "规则索引不能重复"},
PageQueryOp: &cool.QueryOp{
KeyWordField: []string{"desc"},
FieldEQ: []string{"rule_idx"},
},
ListQueryOp: &cool.QueryOp{
KeyWordField: []string{"desc"},
FieldEQ: []string{"rule_idx"},
},
},
}
}