42 lines
1.0 KiB
Go
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"},
|
|
},
|
|
},
|
|
}
|
|
}
|