...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_rule/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"sort"
|
|
|
)
|
|
|
|
|
|
type EvaluationRuleService struct {
|
...
|
...
|
@@ -36,6 +37,13 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac |
|
|
if count > 0 {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在")
|
|
|
}
|
|
|
|
|
|
if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序
|
|
|
sort.SliceStable(in.Rating.Levels, func(i, j int) bool {
|
|
|
return in.Rating.Levels[i].QuantizedValue < in.Rating.Levels[j].QuantizedValue
|
|
|
})
|
|
|
}
|
|
|
|
|
|
newRule := &domain.EvaluationRule{
|
|
|
Id: 0,
|
|
|
Name: in.Name,
|
...
|
...
|
@@ -82,6 +90,12 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序
|
|
|
sort.SliceStable(in.Rating.Levels, func(i, j int) bool {
|
|
|
return in.Rating.Levels[i].QuantizedValue < in.Rating.Levels[j].QuantizedValue
|
|
|
})
|
|
|
}
|
|
|
|
|
|
rule.Name = in.Name
|
|
|
rule.Remark = in.Remark
|
|
|
rule.Type = in.Type
|
...
|
...
|
@@ -152,12 +166,12 @@ func (rs *EvaluationRuleService) List(in *command.QueryRuleCommand) (interface{} |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// FIXME 总数量是否使用Count获取一个总数量
|
|
|
count, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in))
|
|
|
|
|
|
total, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return tool_funs.SimpleWrapGridMap(count, rules), nil
|
|
|
return tool_funs.SimpleWrapGridMap(total, rules), nil
|
|
|
}
|
|
|
|
|
|
func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (interface{}, error) {
|
...
|
...
|
@@ -171,8 +185,7 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i |
|
|
ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
|
|
|
// FIXME 总数量是否使用Count获取一个总数量
|
|
|
count, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in))
|
|
|
total, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -197,5 +210,5 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i |
|
|
ras[i].CreatorName = v
|
|
|
}
|
|
|
}
|
|
|
return tool_funs.SimpleWrapGridMap(count, ras), nil
|
|
|
return tool_funs.SimpleWrapGridMap(total, ras), nil
|
|
|
} |
...
|
...
|
|