作者 郑周

评估规则 业务逻辑

@@ -8,7 +8,6 @@ import ( @@ -8,7 +8,6 @@ import (
8 type UpdateRuleCommand struct { 8 type UpdateRuleCommand struct {
9 Id int64 `cname:"规则ID" json:"id,string" valid:"Required"` 9 Id int64 `cname:"规则ID" json:"id,string" valid:"Required"`
10 CompanyId int64 `cname:"公司ID" json:"companyId"` 10 CompanyId int64 `cname:"公司ID" json:"companyId"`
11 - CreatorId int64 `cname:"创建人ID" json:"creatorId"`  
12 Name string `cname:"规则名称" json:"name" valid:"Required"` 11 Name string `cname:"规则名称" json:"name" valid:"Required"`
13 Remark string `cname:"规则备注" json:"remark"` 12 Remark string `cname:"规则备注" json:"remark"`
14 Type int `cname:"评估方式" json:"type"` 13 Type int `cname:"评估方式" json:"type"`
@@ -21,10 +20,6 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { @@ -21,10 +20,6 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) {
21 validation.SetError("companyId", "公司ID无效") 20 validation.SetError("companyId", "公司ID无效")
22 return 21 return
23 } 22 }
24 - if in.CreatorId == 0 {  
25 - validation.SetError("creatorId", "创建人ID无效")  
26 - return  
27 - }  
28 23
29 if len(in.Name) > 40 { 24 if len(in.Name) > 40 {
30 validation.SetError("name", "名称最大长度40个字符") 25 validation.SetError("name", "名称最大长度40个字符")
@@ -35,7 +35,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac @@ -35,7 +35,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac
35 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 35 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
36 } 36 }
37 if count > 0 { 37 if count > 0 {
38 - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") 38 + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估规则")
39 } 39 }
40 40
41 if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序 41 if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序
@@ -82,7 +82,7 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac @@ -82,7 +82,7 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac
82 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 82 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
83 } 83 }
84 if count > 0 { 84 if count > 0 {
85 - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") 85 + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估规则")
86 } 86 }
87 87
88 rule, err := ruleRepository.FindOne(map[string]interface{}{"id": in.Id}) 88 rule, err := ruleRepository.FindOne(map[string]interface{}{"id": in.Id})
@@ -21,8 +21,6 @@ func (controller *RuleController) CreateRule() { @@ -21,8 +21,6 @@ func (controller *RuleController) CreateRule() {
21 ua := middlewares.GetUser(controller.Ctx) 21 ua := middlewares.GetUser(controller.Ctx)
22 in.CompanyId = ua.CompanyId 22 in.CompanyId = ua.CompanyId
23 in.CreatorId = ua.UserId 23 in.CreatorId = ua.UserId
24 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
25 - //in.CreatorId = middlewares.GetUserId(controller.Ctx)  
26 controller.Response(ruService.Create(in)) 24 controller.Response(ruService.Create(in))
27 } 25 }
28 } 26 }
@@ -35,9 +33,6 @@ func (controller *RuleController) UpdateRule() { @@ -35,9 +33,6 @@ func (controller *RuleController) UpdateRule() {
35 } else { 33 } else {
36 ua := middlewares.GetUser(controller.Ctx) 34 ua := middlewares.GetUser(controller.Ctx)
37 in.CompanyId = ua.CompanyId 35 in.CompanyId = ua.CompanyId
38 - in.CreatorId = ua.UserId  
39 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
40 - //in.CreatorId = middlewares.GetUserId(controller.Ctx)  
41 controller.Response(ruService.Update(in)) 36 controller.Response(ruService.Update(in))
42 } 37 }
43 } 38 }