feat: 添加战胜规则配置模块
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
41
modules/config/service/fight_rule_service.go
Normal file
41
modules/config/service/fight_rule_service.go
Normal file
@@ -0,0 +1,41 @@
|
||||
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"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user