Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/performance into test
正在显示
1 个修改的文件
包含
13 行增加
和
21 行删除
@@ -173,6 +173,19 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -173,6 +173,19 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
173 | ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | 173 | ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) |
174 | userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 174 | userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
175 | 175 | ||
176 | + // 查询系统默认规则 | ||
177 | + _, sysRules, err := ruleRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "sysType": domain.EvaluationSysTypeSystem, "limit": 1}) | ||
178 | + if err != nil { | ||
179 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
180 | + } | ||
181 | + // 不存在,生成默认规则 | ||
182 | + if len(sysRules) == 0 { | ||
183 | + newRule := domain.GenerateSysRule(in.CompanyId) | ||
184 | + if _, err := ruleRepository.Insert(newRule); err != nil { | ||
185 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
186 | + } | ||
187 | + } | ||
188 | + | ||
176 | total, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in)) | 189 | total, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in)) |
177 | if err != nil { | 190 | if err != nil { |
178 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 191 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -180,31 +193,11 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -180,31 +193,11 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
180 | 193 | ||
181 | ras := make([]*adapter.RuleAdapter, 0) | 194 | ras := make([]*adapter.RuleAdapter, 0) |
182 | creatorIds := make([]int64, 0) | 195 | creatorIds := make([]int64, 0) |
183 | - var havaSystemType = false | ||
184 | for i := range rules { | 196 | for i := range rules { |
185 | ra := &adapter.RuleAdapter{} | 197 | ra := &adapter.RuleAdapter{} |
186 | ra.EvaluationRule = rules[i] | 198 | ra.EvaluationRule = rules[i] |
187 | ras = append(ras, ra) | 199 | ras = append(ras, ra) |
188 | creatorIds = append(creatorIds, rules[i].CreatorId) | 200 | creatorIds = append(creatorIds, rules[i].CreatorId) |
189 | - | ||
190 | - if rules[i].SysType == domain.EvaluationSysTypeSystem { | ||
191 | - havaSystemType = true | ||
192 | - break | ||
193 | - } | ||
194 | - } | ||
195 | - | ||
196 | - // 如果不存在系统默认就生成一个 | ||
197 | - if !havaSystemType { | ||
198 | - newRule := domain.GenerateSysRule(in.CompanyId) | ||
199 | - rule, err := ruleRepository.Insert(newRule) | ||
200 | - if err != nil { | ||
201 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
202 | - } | ||
203 | - ra := &adapter.RuleAdapter{} | ||
204 | - ra.EvaluationRule = rule | ||
205 | - ras = append(ras, ra) | ||
206 | - | ||
207 | - total += 1 | ||
208 | } | 201 | } |
209 | 202 | ||
210 | _, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)}) | 203 | _, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)}) |
@@ -218,7 +211,6 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -218,7 +211,6 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
218 | if v, ok := userNameMap[ras[i].CreatorId]; ok { | 211 | if v, ok := userNameMap[ras[i].CreatorId]; ok { |
219 | ras[i].CreatorName = v | 212 | ras[i].CreatorName = v |
220 | } | 213 | } |
221 | - | ||
222 | } | 214 | } |
223 | 215 | ||
224 | if err := transactionContext.CommitTransaction(); err != nil { | 216 | if err := transactionContext.CommitTransaction(); err != nil { |
-
请 注册 或 登录 后发表评论