作者 郑周

1. 添加系统默认规则

@@ -416,6 +416,11 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter @@ -416,6 +416,11 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter
416 _, users, _ := userRepository.Find(map[string]interface{}{"ids": pmpUserIds, "limit": len(pmpUserIds)}) 416 _, users, _ := userRepository.Find(map[string]interface{}{"ids": pmpUserIds, "limit": len(pmpUserIds)})
417 pmpUsers = users 417 pmpUsers = users
418 } 418 }
  419 +
  420 + if err := transactionContext.CommitTransaction(); err != nil {
  421 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  422 + }
  423 +
419 projectAdapters := adapter.TransformProjectListAdapter(projects, pmpUsers) 424 projectAdapters := adapter.TransformProjectListAdapter(projects, pmpUsers)
420 return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil 425 return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil
421 } 426 }
@@ -568,13 +573,7 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo @@ -568,13 +573,7 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo
568 repeatNum++ 573 repeatNum++
569 } 574 }
570 } 575 }
571 - //if repeatNum > 0 {  
572 - // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum))  
573 - //}  
574 576
575 - if err != nil {  
576 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
577 - }  
578 if err := transactionContext.CommitTransaction(); err != nil { 577 if err := transactionContext.CommitTransaction(); err != nil {
579 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 578 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
580 } 579 }
@@ -162,23 +162,6 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac @@ -162,23 +162,6 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac
162 return rule, nil 162 return rule, nil
163 } 163 }
164 164
165 -//func (rs *EvaluationRuleService) List(in *command.QueryRuleCommand) (interface{}, error) {  
166 -// transactionContext, err := factory.StartTransaction()  
167 -// if err != nil {  
168 -// return nil, err  
169 -// }  
170 -// defer func() {  
171 -// transactionContext.RollbackTransaction()  
172 -// }()  
173 -// ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext})  
174 -//  
175 -// total, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in))  
176 -// if err != nil {  
177 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
178 -// }  
179 -// return tool_funs.SimpleWrapGridMap(total, rules), nil  
180 -//}  
181 -  
182 func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (interface{}, error) { 165 func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (interface{}, error) {
183 transactionContext, err := factory.ValidateStartTransaction(in) 166 transactionContext, err := factory.ValidateStartTransaction(in)
184 if err != nil { 167 if err != nil {
@@ -220,6 +203,8 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i @@ -220,6 +203,8 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
220 ra := &adapter.RuleAdapter{} 203 ra := &adapter.RuleAdapter{}
221 ra.EvaluationRule = rule 204 ra.EvaluationRule = rule
222 ras = append(ras, ra) 205 ras = append(ras, ra)
  206 +
  207 + total += 1
223 } 208 }
224 209
225 _, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)}) 210 _, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)})
@@ -234,6 +219,11 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i @@ -234,6 +219,11 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i
234 ras[i].CreatorName = v 219 ras[i].CreatorName = v
235 } 220 }
236 } 221 }
  222 +
  223 + if err := transactionContext.CommitTransaction(); err != nil {
  224 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  225 + }
  226 +
237 return tool_funs.SimpleWrapGridMap(total, ras), nil 227 return tool_funs.SimpleWrapGridMap(total, ras), nil
238 } 228 }
239 229
@@ -271,5 +261,9 @@ func (rs *EvaluationRuleService) ListCreator(in *command.QueryCreatorCommand) (i @@ -271,5 +261,9 @@ func (rs *EvaluationRuleService) ListCreator(in *command.QueryCreatorCommand) (i
271 } 261 }
272 cas = append(cas, ca) 262 cas = append(cas, ca)
273 } 263 }
  264 +
  265 + if err := transactionContext.CommitTransaction(); err != nil {
  266 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  267 + }
274 return map[string]interface{}{"list": cas}, nil 268 return map[string]interface{}{"list": cas}, nil
275 } 269 }
@@ -145,7 +145,7 @@ func GenerateSysRule(companyId int64) *EvaluationRule { @@ -145,7 +145,7 @@ func GenerateSysRule(companyId int64) *EvaluationRule {
145 145
146 newRule := &EvaluationRule{ 146 newRule := &EvaluationRule{
147 Id: 0, 147 Id: 0,
148 - Name: "评级(默认)", 148 + Name: "评级",
149 Remark: "", 149 Remark: "",
150 CompanyId: companyId, 150 CompanyId: companyId,
151 CreatorId: 0, 151 CreatorId: 0,