作者 郑周

评估规则 业务逻辑

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