合并分支 'test' 到 'master'
Test 查看合并请求 !4
正在显示
34 个修改的文件
包含
378 行增加
和
75 行删除
| @@ -8,6 +8,7 @@ COPY ./go.mod go.mod | @@ -8,6 +8,7 @@ COPY ./go.mod go.mod | ||
| 8 | COPY ./go.sum go.sum | 8 | COPY ./go.sum go.sum |
| 9 | COPY ./main.go main.go | 9 | COPY ./main.go main.go |
| 10 | COPY ./key key | 10 | COPY ./key key |
| 11 | +COPY ./templates templates | ||
| 11 | RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] | 12 | RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] |
| 12 | ENV GO111MODULE on | 13 | ENV GO111MODULE on |
| 13 | ENV GOPROXY https://goproxy.io | 14 | ENV GOPROXY https://goproxy.io |
| 1 | package main | 1 | package main |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "time" | ||
| 5 | + | ||
| 4 | "github.com/beego/beego/v2/server/web" | 6 | "github.com/beego/beego/v2/server/web" |
| 5 | - service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task" | 7 | + serviceTask "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" |
| 7 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" | 9 | _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" |
| 8 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" | ||
| 9 | - "time" | ||
| 10 | ) | 10 | ) |
| 11 | 11 | ||
| 12 | func main() { | 12 | func main() { |
| @@ -17,14 +17,14 @@ func main() { | @@ -17,14 +17,14 @@ func main() { | ||
| 17 | // for k, v := range methods { | 17 | // for k, v := range methods { |
| 18 | // fmt.Printf("%s => %v \n", k, v) | 18 | // fmt.Printf("%s => %v \n", k, v) |
| 19 | // } | 19 | // } |
| 20 | - go consumer.Run() | 20 | + // go consumer.Run() |
| 21 | web.Run() | 21 | web.Run() |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | // 定时任务-间隔发送评估环节 | 24 | // 定时任务-间隔发送评估环节 |
| 25 | func startNodeTask() { | 25 | func startNodeTask() { |
| 26 | go func() { | 26 | go func() { |
| 27 | - nodeTaskService := service.NewNodeTaskService() | 27 | + nodeTaskService := serviceTask.NewNodeTaskService() |
| 28 | for { | 28 | for { |
| 29 | timer := time.NewTimer(time.Second * 60) | 29 | timer := time.NewTimer(time.Second * 60) |
| 30 | <-timer.C | 30 | <-timer.C |
| @@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
| 5 | + "unicode/utf8" | ||
| 5 | ) | 6 | ) |
| 6 | 7 | ||
| 7 | type CreateCycleCommand struct { | 8 | type CreateCycleCommand struct { |
| @@ -23,7 +24,7 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | @@ -23,7 +24,7 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) { | ||
| 23 | validation.SetError("creatorId", "创建人ID无效") | 24 | validation.SetError("creatorId", "创建人ID无效") |
| 24 | return | 25 | return |
| 25 | } | 26 | } |
| 26 | - if len(in.Name) > 40 { | 27 | + if utf8.RuneCountInString(in.Name) > 40 { |
| 27 | validation.SetError("name", "名称最大长度40个字符") | 28 | validation.SetError("name", "名称最大长度40个字符") |
| 28 | return | 29 | return |
| 29 | } | 30 | } |
| @@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
| 5 | + "unicode/utf8" | ||
| 5 | ) | 6 | ) |
| 6 | 7 | ||
| 7 | type UpdateCycleCommand struct { | 8 | type UpdateCycleCommand struct { |
| @@ -15,7 +16,7 @@ type UpdateCycleCommand struct { | @@ -15,7 +16,7 @@ type UpdateCycleCommand struct { | ||
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { | 18 | func (in *UpdateCycleCommand) Valid(validation *validation.Validation) { |
| 18 | - if len(in.Name) > 40 { | 19 | + if utf8.RuneCountInString(in.Name) > 40 { |
| 19 | validation.SetError("name", "角色名称最大长度40个字符") | 20 | validation.SetError("name", "角色名称最大长度40个字符") |
| 20 | return | 21 | return |
| 21 | } | 22 | } |
| @@ -328,7 +328,7 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf | @@ -328,7 +328,7 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf | ||
| 328 | } | 328 | } |
| 329 | 329 | ||
| 330 | func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface{}, error) { | 330 | func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface{}, error) { |
| 331 | - transactionContext, err := factory.StartTransaction() | 331 | + transactionContext, err := factory.ValidateStartTransaction(in) |
| 332 | if err != nil { | 332 | if err != nil { |
| 333 | return nil, err | 333 | return nil, err |
| 334 | } | 334 | } |
| @@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
| 5 | + "unicode/utf8" | ||
| 5 | ) | 6 | ) |
| 6 | 7 | ||
| 7 | type CreateProjectCommand struct { | 8 | type CreateProjectCommand struct { |
| @@ -24,7 +25,7 @@ func (in *CreateProjectCommand) Valid(validation *validation.Validation) { | @@ -24,7 +25,7 @@ func (in *CreateProjectCommand) Valid(validation *validation.Validation) { | ||
| 24 | validation.SetError("creatorId", "创建人ID无效") | 25 | validation.SetError("creatorId", "创建人ID无效") |
| 25 | return | 26 | return |
| 26 | } | 27 | } |
| 27 | - if len(in.Name) > 40 { | 28 | + if utf8.RuneCountInString(in.Name) > 40 { |
| 28 | validation.SetError("name", "项目名称最大长度40个字符") | 29 | validation.SetError("name", "项目名称最大长度40个字符") |
| 29 | return | 30 | return |
| 30 | } | 31 | } |
| @@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
| 5 | + "unicode/utf8" | ||
| 5 | ) | 6 | ) |
| 6 | 7 | ||
| 7 | type UpdateProjectCommand struct { | 8 | type UpdateProjectCommand struct { |
| @@ -36,7 +37,7 @@ type CheckRecipientCommand struct { | @@ -36,7 +37,7 @@ type CheckRecipientCommand struct { | ||
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { | 39 | func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { |
| 39 | - if len(in.Name) > 40 { | 40 | + if utf8.RuneCountInString(in.Name) > 40 { |
| 40 | validation.SetError("name", "项目名称最大长度40个字符") | 41 | validation.SetError("name", "项目名称最大长度40个字符") |
| 41 | return | 42 | return |
| 42 | } | 43 | } |
| @@ -301,7 +301,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in | @@ -301,7 +301,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in | ||
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (interface{}, error) { | 303 | func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (interface{}, error) { |
| 304 | - transactionContext, err := factory.StartTransaction() | 304 | + transactionContext, err := factory.ValidateStartTransaction(in) |
| 305 | if err != nil { | 305 | if err != nil { |
| 306 | return nil, err | 306 | return nil, err |
| 307 | } | 307 | } |
| @@ -3,6 +3,7 @@ package command | @@ -3,6 +3,7 @@ package command | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
| 5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 6 | + "unicode/utf8" | ||
| 6 | ) | 7 | ) |
| 7 | 8 | ||
| 8 | type CreateRuleCommand struct { | 9 | type CreateRuleCommand struct { |
| @@ -25,12 +26,12 @@ func (in *CreateRuleCommand) Valid(validation *validation.Validation) { | @@ -25,12 +26,12 @@ func (in *CreateRuleCommand) Valid(validation *validation.Validation) { | ||
| 25 | return | 26 | return |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 28 | - if len(in.Name) > 40 { | 29 | + if utf8.RuneCountInString(in.Name) > 40 { |
| 29 | validation.SetError("name", "名称最大长度40个字符") | 30 | validation.SetError("name", "名称最大长度40个字符") |
| 30 | return | 31 | return |
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | - if len(in.Remark) > 100 { | 34 | + if utf8.RuneCountInString(in.Remark) > 100 { |
| 34 | validation.SetError("remark", "备注不能超过100个字符") | 35 | validation.SetError("remark", "备注不能超过100个字符") |
| 35 | return | 36 | return |
| 36 | } | 37 | } |
| @@ -3,6 +3,7 @@ package command | @@ -3,6 +3,7 @@ package command | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
| 5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 6 | + "unicode/utf8" | ||
| 6 | ) | 7 | ) |
| 7 | 8 | ||
| 8 | type UpdateRuleCommand struct { | 9 | type UpdateRuleCommand struct { |
| @@ -21,12 +22,12 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | @@ -21,12 +22,12 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | ||
| 21 | return | 22 | return |
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | - if len(in.Name) > 40 { | 25 | + if utf8.RuneCountInString(in.Name) > 40 { |
| 25 | validation.SetError("name", "名称最大长度40个字符") | 26 | validation.SetError("name", "名称最大长度40个字符") |
| 26 | return | 27 | return |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | - if len(in.Remark) > 100 { | 30 | + if utf8.RuneCountInString(in.Remark) > 100 { |
| 30 | validation.SetError("remark", "备注不能超过100个字符") | 31 | validation.SetError("remark", "备注不能超过100个字符") |
| 31 | return | 32 | return |
| 32 | } | 33 | } |
| @@ -51,6 +51,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac | @@ -51,6 +51,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac | ||
| 51 | CompanyId: in.CompanyId, | 51 | CompanyId: in.CompanyId, |
| 52 | CreatorId: in.CreatorId, | 52 | CreatorId: in.CreatorId, |
| 53 | Type: in.Type, | 53 | Type: in.Type, |
| 54 | + SysType: domain.EvaluationSysTypeCommon, | ||
| 54 | Rating: in.Rating, | 55 | Rating: in.Rating, |
| 55 | Score: in.Score, | 56 | Score: in.Score, |
| 56 | } | 57 | } |
| @@ -147,6 +148,10 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac | @@ -147,6 +148,10 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac | ||
| 147 | if err != nil { | 148 | if err != nil { |
| 148 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 149 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 149 | } | 150 | } |
| 151 | + if rule.SysType == domain.EvaluationSysTypeSystem { | ||
| 152 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "系统默认规则不可删除") | ||
| 153 | + } | ||
| 154 | + | ||
| 150 | if _, err := ruleRepository.Remove(rule); err != nil { | 155 | if _, err := ruleRepository.Remove(rule); err != nil { |
| 151 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 156 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 152 | } | 157 | } |
| @@ -175,7 +180,7 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac | @@ -175,7 +180,7 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac | ||
| 175 | //} | 180 | //} |
| 176 | 181 | ||
| 177 | func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (interface{}, error) { | 182 | func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (interface{}, error) { |
| 178 | - transactionContext, err := factory.StartTransaction() | 183 | + transactionContext, err := factory.ValidateStartTransaction(in) |
| 179 | if err != nil { | 184 | if err != nil { |
| 180 | return nil, err | 185 | return nil, err |
| 181 | } | 186 | } |
| @@ -192,12 +197,31 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -192,12 +197,31 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
| 192 | 197 | ||
| 193 | ras := make([]*adapter.RuleAdapter, 0) | 198 | ras := make([]*adapter.RuleAdapter, 0) |
| 194 | creatorIds := make([]int64, 0) | 199 | creatorIds := make([]int64, 0) |
| 200 | + var havaSystemType = false | ||
| 195 | for i := range rules { | 201 | for i := range rules { |
| 196 | ra := &adapter.RuleAdapter{} | 202 | ra := &adapter.RuleAdapter{} |
| 197 | ra.EvaluationRule = rules[i] | 203 | ra.EvaluationRule = rules[i] |
| 198 | ras = append(ras, ra) | 204 | ras = append(ras, ra) |
| 199 | creatorIds = append(creatorIds, rules[i].CreatorId) | 205 | creatorIds = append(creatorIds, rules[i].CreatorId) |
| 206 | + | ||
| 207 | + if rules[i].SysType == domain.EvaluationSysTypeSystem { | ||
| 208 | + havaSystemType = true | ||
| 209 | + break | ||
| 210 | + } | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + // 如果不存在系统默认就生成一个 | ||
| 214 | + if !havaSystemType { | ||
| 215 | + newRule := domain.GenerateSysRule(in.CompanyId) | ||
| 216 | + rule, err := ruleRepository.Insert(newRule) | ||
| 217 | + if err != nil { | ||
| 218 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 219 | + } | ||
| 220 | + ra := &adapter.RuleAdapter{} | ||
| 221 | + ra.EvaluationRule = rule | ||
| 222 | + ras = append(ras, ra) | ||
| 200 | } | 223 | } |
| 224 | + | ||
| 201 | _, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)}) | 225 | _, users, _ := userRepository.Find(map[string]interface{}{"ids": creatorIds, "limit": len(creatorIds)}) |
| 202 | userNameMap := map[int64]string{} | 226 | userNameMap := map[int64]string{} |
| 203 | if users != nil { | 227 | if users != nil { |
| @@ -214,7 +238,7 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -214,7 +238,7 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
| 214 | } | 238 | } |
| 215 | 239 | ||
| 216 | func (rs *EvaluationRuleService) ListCreator(in *command.QueryCreatorCommand) (interface{}, error) { | 240 | func (rs *EvaluationRuleService) ListCreator(in *command.QueryCreatorCommand) (interface{}, error) { |
| 217 | - transactionContext, err := factory.StartTransaction() | 241 | + transactionContext, err := factory.ValidateStartTransaction(in) |
| 218 | if err != nil { | 242 | if err != nil { |
| 219 | return nil, err | 243 | return nil, err |
| 220 | } | 244 | } |
| @@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/core/validation" | 4 | "github.com/beego/beego/v2/core/validation" |
| 5 | + "unicode/utf8" | ||
| 5 | ) | 6 | ) |
| 6 | 7 | ||
| 7 | type CreateTemplateCommand struct { | 8 | type CreateTemplateCommand struct { |
| @@ -21,12 +22,13 @@ func (in *CreateTemplateCommand) Valid(validation *validation.Validation) { | @@ -21,12 +22,13 @@ func (in *CreateTemplateCommand) Valid(validation *validation.Validation) { | ||
| 21 | return | 22 | return |
| 22 | } | 23 | } |
| 23 | 24 | ||
| 24 | - if len(in.Name) > 40 { | 25 | + // 这个才是真正计算字符串文字长度的 utf8.RuneCountInString(in.Name) |
| 26 | + if utf8.RuneCountInString(in.Name) > 40 { | ||
| 25 | validation.SetError("name", "模板名称最大长度40个字符") | 27 | validation.SetError("name", "模板名称最大长度40个字符") |
| 26 | return | 28 | return |
| 27 | } | 29 | } |
| 28 | 30 | ||
| 29 | - if len(in.Describe) > 100 { | 31 | + if utf8.RuneCountInString(in.Describe) > 100 { |
| 30 | validation.SetError("describe", "备注最大长度100个字符") | 32 | validation.SetError("describe", "备注最大长度100个字符") |
| 31 | return | 33 | return |
| 32 | } | 34 | } |
| @@ -20,15 +20,15 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { | @@ -20,15 +20,15 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { | ||
| 20 | return | 20 | return |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | - if len(in.Name) > 40 { | ||
| 24 | - validation.SetError("name", "模板名称最大长度40个字符") | ||
| 25 | - return | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | - if len(in.Describe) > 100 { | ||
| 29 | - validation.SetError("describe", "备注最大长度100个字符") | ||
| 30 | - return | ||
| 31 | - } | 23 | + //if len(in.Name) > 40 { |
| 24 | + // validation.SetError("name", "模板名称最大长度40个字符") | ||
| 25 | + // return | ||
| 26 | + //} | ||
| 27 | + // | ||
| 28 | + //if len(in.Describe) > 100 { | ||
| 29 | + // validation.SetError("describe", "备注最大长度100个字符") | ||
| 30 | + // return | ||
| 31 | + //} | ||
| 32 | 32 | ||
| 33 | if len(in.LinkNodes) == 0 { | 33 | if len(in.LinkNodes) == 0 { |
| 34 | validation.SetError("linkNodes", "评估模板流程不能为空") | 34 | validation.SetError("linkNodes", "评估模板流程不能为空") |
| @@ -186,7 +186,7 @@ func (rs *EvaluationTemplateService) Remove(in *command.DeleteTemplateCommand) ( | @@ -186,7 +186,7 @@ func (rs *EvaluationTemplateService) Remove(in *command.DeleteTemplateCommand) ( | ||
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (interface{}, error) { | 188 | func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (interface{}, error) { |
| 189 | - transactionContext, err := factory.StartTransaction() | 189 | + transactionContext, err := factory.ValidateStartTransaction(in) |
| 190 | if err != nil { | 190 | if err != nil { |
| 191 | return nil, err | 191 | return nil, err |
| 192 | } | 192 | } |
| 1 | package command | 1 | package command |
| 2 | 2 | ||
| 3 | -import "github.com/beego/beego/v2/core/validation" | 3 | +import ( |
| 4 | + "github.com/beego/beego/v2/core/validation" | ||
| 5 | + "unicode/utf8" | ||
| 6 | +) | ||
| 4 | 7 | ||
| 5 | type CreateRoleCommand struct { | 8 | type CreateRoleCommand struct { |
| 6 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 9 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
| @@ -14,7 +17,7 @@ func (in *CreateRoleCommand) Valid(validation *validation.Validation) { | @@ -14,7 +17,7 @@ func (in *CreateRoleCommand) Valid(validation *validation.Validation) { | ||
| 14 | return | 17 | return |
| 15 | } | 18 | } |
| 16 | 19 | ||
| 17 | - if len(in.Name) > 30 { | 20 | + if utf8.RuneCountInString(in.Name) > 30 { |
| 18 | validation.SetError("name", "角色名称最大长度30个字符") | 21 | validation.SetError("name", "角色名称最大长度30个字符") |
| 19 | return | 22 | return |
| 20 | } | 23 | } |
| 1 | package command | 1 | package command |
| 2 | 2 | ||
| 3 | -import "github.com/beego/beego/v2/core/validation" | 3 | +import ( |
| 4 | + "github.com/beego/beego/v2/core/validation" | ||
| 5 | + "unicode/utf8" | ||
| 6 | +) | ||
| 4 | 7 | ||
| 5 | type UpdateRoleCommand struct { | 8 | type UpdateRoleCommand struct { |
| 6 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 9 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
| @@ -14,7 +17,7 @@ func (in *UpdateRoleCommand) Valid(validation *validation.Validation) { | @@ -14,7 +17,7 @@ func (in *UpdateRoleCommand) Valid(validation *validation.Validation) { | ||
| 14 | validation.SetError("companyId", "公司ID无效") | 17 | validation.SetError("companyId", "公司ID无效") |
| 15 | } | 18 | } |
| 16 | 19 | ||
| 17 | - if len(in.Name) > 30 { | 20 | + if utf8.RuneCountInString(in.Name) > 30 { |
| 18 | validation.SetError("name", "角色名称最大长度30个字符") | 21 | validation.SetError("name", "角色名称最大长度30个字符") |
| 19 | return | 22 | return |
| 20 | } | 23 | } |
| @@ -141,7 +141,7 @@ func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error | @@ -141,7 +141,7 @@ func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error | ||
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { | 143 | func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { |
| 144 | - transactionContext, err := factory.StartTransaction() | 144 | + transactionContext, err := factory.ValidateStartTransaction(in) |
| 145 | if err != nil { | 145 | if err != nil { |
| 146 | return nil, err | 146 | return nil, err |
| 147 | } | 147 | } |
| @@ -95,7 +95,7 @@ func (rs *RoleUserService) Remove(in *command.UserRoleDeleteCommand) (interface{ | @@ -95,7 +95,7 @@ func (rs *RoleUserService) Remove(in *command.UserRoleDeleteCommand) (interface{ | ||
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface{}, error) { | 97 | func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface{}, error) { |
| 98 | - transactionContext, err := factory.StartTransaction() | 98 | + transactionContext, err := factory.ValidateStartTransaction(in) |
| 99 | if err != nil { | 99 | if err != nil { |
| 100 | return nil, err | 100 | return nil, err |
| 101 | } | 101 | } |
| @@ -5,22 +5,22 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | @@ -5,22 +5,22 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 5 | //评估内容详情 | 5 | //评估内容详情 |
| 6 | type AssessInfoResp struct { | 6 | type AssessInfoResp struct { |
| 7 | AssessId int `json:"assessId"` | 7 | AssessId int `json:"assessId"` |
| 8 | - CycleId int64 `json:"cycleId"` //周期id | 8 | + CycleId int64 `json:"cycleId,string"` //周期id |
| 9 | CycleName string `json:"cycleName"` //周期名称 | 9 | CycleName string `json:"cycleName"` //周期名称 |
| 10 | EvaluationProjectId int `json:"evaluationProjectId"` //项目id | 10 | EvaluationProjectId int `json:"evaluationProjectId"` //项目id |
| 11 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | 11 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 |
| 12 | - LinkNodeId int `json:"linkNodeId"` | 12 | + LinkNodeId int `json:"linkNodeId,string"` |
| 13 | LinkNodeName string `json:"linkNodeName"` | 13 | LinkNodeName string `json:"linkNodeName"` |
| 14 | - BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
| 15 | - EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
| 16 | - Status string `json:"status"` //完成状态 | ||
| 17 | - TargetUserId int `json:"targetUser"` //目标用户 | ||
| 18 | - TargetUserName string `json:"targetUserName"` //目标用户名称 | ||
| 19 | - CompanyId int `json:"companyId,string,"` // | ||
| 20 | - CompanyName string `json:"companyName"` //公司名称 | ||
| 21 | - SupperUser string `json:"superUser"` //目标用户的上级 | ||
| 22 | - DutyTime string `json:"dutyTime"` //入职时间 // | ||
| 23 | - AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容 | 14 | + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 |
| 15 | + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
| 16 | + Status string `json:"status"` //完成状态 | ||
| 17 | + TargetUserId int `json:"targetUserId,string"` //目标用户 | ||
| 18 | + TargetUserName string `json:"targetUserName"` //目标用户名称 | ||
| 19 | + CompanyId int `json:"companyId,string,"` // | ||
| 20 | + CompanyName string `json:"companyName"` //公司名称 | ||
| 21 | + SupperUser string `json:"superUser"` //目标用户的上级 | ||
| 22 | + DutyTime string `json:"dutyTime"` //入职时间 // | ||
| 23 | + AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容 | ||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | type AssessContent struct { | 26 | type AssessContent struct { |
| 1 | package adapter | 1 | package adapter |
| 2 | 2 | ||
| 3 | type AssessTaskDescResp struct { | 3 | type AssessTaskDescResp struct { |
| 4 | - AssessTaskId int `json:"assessTaskId"` // | ||
| 5 | - EvaluationProjectId int `json:"evaluationProjectId"` //项目id | ||
| 6 | - EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
| 7 | - CycleName string `json:"cycleName"` //周期名称 | ||
| 8 | - BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
| 9 | - EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
| 10 | - StepList []AssessTaskStep `json:"stepList"` // 考评流程 | 4 | + AssessTaskId int `json:"assessTaskId"` // |
| 5 | + EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id | ||
| 6 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
| 7 | + CycleName string `json:"cycleName"` //周期名称 | ||
| 8 | + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
| 9 | + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
| 10 | + StepList []AssessTaskStep `json:"stepList"` // 考评流程 | ||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | type AssessTaskStep struct { | 13 | type AssessTaskStep struct { |
| @@ -2,7 +2,7 @@ package adapter | @@ -2,7 +2,7 @@ package adapter | ||
| 2 | 2 | ||
| 3 | type ListSupperAssessResp struct { | 3 | type ListSupperAssessResp struct { |
| 4 | AssessId int `json:"assessId"` // | 4 | AssessId int `json:"assessId"` // |
| 5 | - UsrId int `json:"userId"` | 5 | + UsrId int `json:"userId,string"` |
| 6 | UserName string `json:"userName"` //用户名称 | 6 | UserName string `json:"userName"` //用户名称 |
| 7 | EndTime string `json:"endTime"` //截止时间 | 7 | EndTime string `json:"endTime"` //截止时间 |
| 8 | InviteTotal int `json:"inviteTota"` //邀请总数 | 8 | InviteTotal int `json:"inviteTota"` //邀请总数 |
| @@ -2,8 +2,8 @@ package query | @@ -2,8 +2,8 @@ package query | ||
| 2 | 2 | ||
| 3 | //获取员工自评填写详情 | 3 | //获取员工自评填写详情 |
| 4 | type AssessSelfInfoQuery struct { | 4 | type AssessSelfInfoQuery struct { |
| 5 | - AssessTaskId int `json:"assessTaskId"` //assessTaskId 的id | ||
| 6 | - TargetUserId int `json:"targetUserId"` //被评估的人id | ||
| 7 | - CompanyId int `json:"companyId"` //公司id | 5 | + AssessTaskId int `json:"assessTaskId"` //assessTaskId 的id |
| 6 | + TargetUserId int `json:"targetUserId,string"` //被评估的人id | ||
| 7 | + CompanyId int `json:"companyId"` //公司id | ||
| 8 | 8 | ||
| 9 | } | 9 | } |
| @@ -3,7 +3,7 @@ package query | @@ -3,7 +3,7 @@ package query | ||
| 3 | //获取员工 被评估的列表 | 3 | //获取员工 被评估的列表 |
| 4 | type ListTargetUserAssessQuery struct { | 4 | type ListTargetUserAssessQuery struct { |
| 5 | AssessTaskId int `json:"assessTaskId"` | 5 | AssessTaskId int `json:"assessTaskId"` |
| 6 | - TargetUserId int `json:"targetUserId"` | 6 | + TargetUserId int `json:"targetUserId,string"` |
| 7 | CompanyId int `json:"companyId"` | 7 | CompanyId int `json:"companyId"` |
| 8 | Types []string `json:"tyspes"` | 8 | Types []string `json:"tyspes"` |
| 9 | } | 9 | } |
| @@ -164,10 +164,12 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) | @@ -164,10 +164,12 @@ func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) | ||
| 164 | if err != nil { | 164 | if err != nil { |
| 165 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | 165 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) |
| 166 | } | 166 | } |
| 167 | + if len(assessInviteData) > 0 { | ||
| 168 | + stepItem.Status = string(domain.StaffAssessCompleted) | ||
| 169 | + } | ||
| 167 | //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可 | 170 | //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可 |
| 168 | if len(assessInviteData) > 5 { | 171 | if len(assessInviteData) > 5 { |
| 169 | stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | 172 | stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) |
| 170 | - stepItem.Status = string(domain.StaffAssessCompleted) | ||
| 171 | } else { | 173 | } else { |
| 172 | stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData)) | 174 | stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData)) |
| 173 | stepItem.Status = string(domain.StaffAssessUncompleted) | 175 | stepItem.Status = string(domain.StaffAssessUncompleted) |
| @@ -1300,6 +1302,19 @@ func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteU | @@ -1300,6 +1302,19 @@ func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteU | ||
| 1300 | "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"), | 1302 | "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"), |
| 1301 | "assessId": strconv.Itoa(v.Id), | 1303 | "assessId": strconv.Itoa(v.Id), |
| 1302 | } | 1304 | } |
| 1305 | + switch v.Status { | ||
| 1306 | + case domain.StaffAssessCompleted: | ||
| 1307 | + m["status"] = "已经完成" | ||
| 1308 | + case domain.StaffAssessUncompleted: | ||
| 1309 | + m["status"] = "未完成" | ||
| 1310 | + } | ||
| 1311 | + | ||
| 1312 | + switch v.Types { | ||
| 1313 | + case domain.AssessInviteDiffSuper: | ||
| 1314 | + m["typs"] = "不同上级同事" | ||
| 1315 | + case domain.AssessInviteSameSuper: | ||
| 1316 | + m["types"] = "相同上级同事" | ||
| 1317 | + } | ||
| 1303 | if row, ok := changeableRows[v.TargetUser.UserId]; ok { | 1318 | if row, ok := changeableRows[v.TargetUser.UserId]; ok { |
| 1304 | for k, v := range row { | 1319 | for k, v := range row { |
| 1305 | m[k] = v | 1320 | m[k] = v |
| @@ -1405,7 +1420,25 @@ func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperA | @@ -1405,7 +1420,25 @@ func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperA | ||
| 1405 | log.Logger.Error("获取员工邀请的人完成情况" + err.Error()) | 1420 | log.Logger.Error("获取员工邀请的人完成情况" + err.Error()) |
| 1406 | } | 1421 | } |
| 1407 | } | 1422 | } |
| 1408 | - | 1423 | + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ |
| 1424 | + "transactionContext": transactionContext, | ||
| 1425 | + }) | ||
| 1426 | + assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{ | ||
| 1427 | + "id": param.AssessTaskId, | ||
| 1428 | + }) | ||
| 1429 | + if err != nil { | ||
| 1430 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error()) | ||
| 1431 | + } | ||
| 1432 | + //我评估别人,被邀请评估 | ||
| 1433 | + cnnt, _, err := assessRepo.Find(map[string]interface{}{ | ||
| 1434 | + "staffAssessTaskId": param.AssessTaskId, | ||
| 1435 | + "executorId": param.ExecutorId, | ||
| 1436 | + "typesList": []string{string(domain.AssessSuper)}, | ||
| 1437 | + "status": string(domain.StaffAssessUncompleted), | ||
| 1438 | + }) | ||
| 1439 | + if err != nil { | ||
| 1440 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 1441 | + } | ||
| 1409 | if err := transactionContext.CommitTransaction(); err != nil { | 1442 | if err := transactionContext.CommitTransaction(); err != nil { |
| 1410 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1443 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 1411 | } | 1444 | } |
| @@ -1450,7 +1483,18 @@ func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperA | @@ -1450,7 +1483,18 @@ func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperA | ||
| 1450 | } | 1483 | } |
| 1451 | resultList = append(resultList, item) | 1484 | resultList = append(resultList, item) |
| 1452 | } | 1485 | } |
| 1453 | - return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil | 1486 | + result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList) |
| 1487 | + result["linkNodeName"] = "" | ||
| 1488 | + result["linkNodeId"] = "" | ||
| 1489 | + result["lintNodeDesc"] = "" | ||
| 1490 | + for _, v := range assessTaskData.StepList { | ||
| 1491 | + if v.LinkNodeType == domain.LinkNodeSuperiorAssessment { | ||
| 1492 | + result["linkNodeName"] = v.LinkNodeName | ||
| 1493 | + result["linkNodeId"] = fmt.Sprintf("%d", v.LinkNodeId) | ||
| 1494 | + result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt) | ||
| 1495 | + } | ||
| 1496 | + } | ||
| 1497 | + return result, nil | ||
| 1454 | } | 1498 | } |
| 1455 | 1499 | ||
| 1456 | // 根据staffAssessId 获取评估的填写信息 | 1500 | // 根据staffAssessId 获取评估的填写信息 |
| @@ -1665,6 +1709,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma | @@ -1665,6 +1709,7 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma | ||
| 1665 | } | 1709 | } |
| 1666 | } | 1710 | } |
| 1667 | } | 1711 | } |
| 1712 | + | ||
| 1668 | //保存信息 | 1713 | //保存信息 |
| 1669 | for i := range assessContentList { | 1714 | for i := range assessContentList { |
| 1670 | _, err = assessContentRepo.Save(assessContentList[i]) | 1715 | _, err = assessContentRepo.Save(assessContentList[i]) |
| @@ -1672,6 +1717,12 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma | @@ -1672,6 +1717,12 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma | ||
| 1672 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error()) | 1717 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估填写内容"+err.Error()) |
| 1673 | } | 1718 | } |
| 1674 | } | 1719 | } |
| 1720 | + assessData.Status = domain.StaffAssessCompleted | ||
| 1721 | + assessData.UpdatedAt = time.Now() | ||
| 1722 | + _, err = assessReps.Save(assessData) | ||
| 1723 | + if err != nil { | ||
| 1724 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | ||
| 1725 | + } | ||
| 1675 | if err := transactionContext.CommitTransaction(); err != nil { | 1726 | if err := transactionContext.CommitTransaction(); err != nil { |
| 1676 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1727 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 1677 | } | 1728 | } |
| @@ -1700,6 +1751,7 @@ func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserA | @@ -1700,6 +1751,7 @@ func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserA | ||
| 1700 | "assessTaskId": param.AssessTaskId, | 1751 | "assessTaskId": param.AssessTaskId, |
| 1701 | "companyId": param.CompanyId, | 1752 | "companyId": param.CompanyId, |
| 1702 | "targetUserId": param.TargetUserId, | 1753 | "targetUserId": param.TargetUserId, |
| 1754 | + "typesList": param.Types, | ||
| 1703 | }) | 1755 | }) |
| 1704 | if err != nil { | 1756 | if err != nil { |
| 1705 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | 1757 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) |
| @@ -9,6 +9,11 @@ const ( | @@ -9,6 +9,11 @@ const ( | ||
| 9 | EvaluationTypeScore int = 1 // 评估方式-评分 | 9 | EvaluationTypeScore int = 1 // 评估方式-评分 |
| 10 | ) | 10 | ) |
| 11 | 11 | ||
| 12 | +const ( | ||
| 13 | + EvaluationSysTypeCommon int = 0 // 系统类型-系统添加 | ||
| 14 | + EvaluationSysTypeSystem int = 1 // 系统类型-系统预制(不可删除、编辑) | ||
| 15 | +) | ||
| 16 | + | ||
| 12 | type Rating struct { | 17 | type Rating struct { |
| 13 | Levels []*RatingLevel `json:"levels" comment:"配置等级"` | 18 | Levels []*RatingLevel `json:"levels" comment:"配置等级"` |
| 14 | } | 19 | } |
| @@ -42,6 +47,7 @@ type EvaluationRule struct { | @@ -42,6 +47,7 @@ type EvaluationRule struct { | ||
| 42 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` | 47 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` |
| 43 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` | 48 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` |
| 44 | Type int `json:"type" comment:"评估方式(0评级、1评分)"` | 49 | Type int `json:"type" comment:"评估方式(0评级、1评分)"` |
| 50 | + SysType int `json:"sysType" comment:"系统类型(0普通、1系统固定)" pg:",use_zero"` | ||
| 45 | Rating Rating `json:"rating" comment:"评级"` | 51 | Rating Rating `json:"rating" comment:"评级"` |
| 46 | Score Score `json:"score" comment:"评分"` | 52 | Score Score `json:"score" comment:"评分"` |
| 47 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 53 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
| @@ -49,6 +55,58 @@ type EvaluationRule struct { | @@ -49,6 +55,58 @@ type EvaluationRule struct { | ||
| 49 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 55 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
| 50 | } | 56 | } |
| 51 | 57 | ||
| 58 | +// GenerateSysRule 当前公司下的生成默认规则 | ||
| 59 | +func GenerateSysRule(companyId int64) *EvaluationRule { | ||
| 60 | + levels := make([]*RatingLevel, 0) | ||
| 61 | + levels = append(levels, &RatingLevel{ | ||
| 62 | + Code: "S", | ||
| 63 | + Name: "SS", | ||
| 64 | + Color: 1, | ||
| 65 | + QuantizedValue: 90, | ||
| 66 | + }) | ||
| 67 | + levels = append(levels, &RatingLevel{ | ||
| 68 | + Code: "A", | ||
| 69 | + Name: "AA", | ||
| 70 | + Color: 2, | ||
| 71 | + QuantizedValue: 80, | ||
| 72 | + }) | ||
| 73 | + levels = append(levels, &RatingLevel{ | ||
| 74 | + Code: "B", | ||
| 75 | + Name: "BB", | ||
| 76 | + Color: 3, | ||
| 77 | + QuantizedValue: 70, | ||
| 78 | + }) | ||
| 79 | + | ||
| 80 | + levels = append(levels, &RatingLevel{ | ||
| 81 | + Code: "C", | ||
| 82 | + Name: "CC", | ||
| 83 | + Color: 4, | ||
| 84 | + QuantizedValue: 60, | ||
| 85 | + }) | ||
| 86 | + | ||
| 87 | + levels = append(levels, &RatingLevel{ | ||
| 88 | + Code: "D", | ||
| 89 | + Name: "DD", | ||
| 90 | + Color: 5, | ||
| 91 | + QuantizedValue: 50, | ||
| 92 | + }) | ||
| 93 | + | ||
| 94 | + newRule := &EvaluationRule{ | ||
| 95 | + Id: 0, | ||
| 96 | + Name: "评级(默认)", | ||
| 97 | + Remark: "", | ||
| 98 | + CompanyId: companyId, | ||
| 99 | + CreatorId: 0, | ||
| 100 | + Type: EvaluationTypeRating, | ||
| 101 | + SysType: EvaluationSysTypeSystem, | ||
| 102 | + Rating: Rating{ | ||
| 103 | + Levels: levels, | ||
| 104 | + }, | ||
| 105 | + Score: Score{}, | ||
| 106 | + } | ||
| 107 | + return newRule | ||
| 108 | +} | ||
| 109 | + | ||
| 52 | type EvaluationRuleRepository interface { | 110 | type EvaluationRuleRepository interface { |
| 53 | Insert(rule *EvaluationRule) (*EvaluationRule, error) | 111 | Insert(rule *EvaluationRule) (*EvaluationRule, error) |
| 54 | Remove(rule *EvaluationRule) (*EvaluationRule, error) | 112 | Remove(rule *EvaluationRule) (*EvaluationRule, error) |
| @@ -40,7 +40,7 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask | @@ -40,7 +40,7 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask | ||
| 40 | WHERE staff_assess.target_user->>'userId' IN(?) | 40 | WHERE staff_assess.target_user->>'userId' IN(?) |
| 41 | AND staff_assess.types IN ('invite_same_super','invite_diff_super') | 41 | AND staff_assess.types IN ('invite_same_super','invite_diff_super') |
| 42 | AND staff_assess.staff_assess_task_id = ? | 42 | AND staff_assess.staff_assess_task_id = ? |
| 43 | - GROUP BY userId` | 43 | + GROUP BY target_user_id` |
| 44 | 44 | ||
| 45 | userIdList := []string{} | 45 | userIdList := []string{} |
| 46 | for _, v := range userIds { | 46 | for _, v := range userIds { |
| @@ -13,6 +13,7 @@ type EvaluationRule struct { | @@ -13,6 +13,7 @@ type EvaluationRule struct { | ||
| 13 | CompanyId int64 `comment:"公司ID"` | 13 | CompanyId int64 `comment:"公司ID"` |
| 14 | CreatorId int64 `comment:"创建人ID"` | 14 | CreatorId int64 `comment:"创建人ID"` |
| 15 | Type int `comment:"评估方式(0评级、1评分)" pg:",use_zero"` | 15 | Type int `comment:"评估方式(0评级、1评分)" pg:",use_zero"` |
| 16 | + SysType int `comment:"系统类型(0普通、1系统固定)" pg:",use_zero"` | ||
| 16 | Rating domain.Rating `comment:"评级"` | 17 | Rating domain.Rating `comment:"评级"` |
| 17 | Score domain.Score `comment:"评分"` | 18 | Score domain.Score `comment:"评分"` |
| 18 | CreatedAt time.Time `comment:"创建时间"` | 19 | CreatedAt time.Time `comment:"创建时间"` |
| @@ -28,6 +28,7 @@ func (repo *EvaluationRuleRepository) TransformToDomain(m *models.EvaluationRule | @@ -28,6 +28,7 @@ func (repo *EvaluationRuleRepository) TransformToDomain(m *models.EvaluationRule | ||
| 28 | CompanyId: m.CompanyId, | 28 | CompanyId: m.CompanyId, |
| 29 | CreatorId: m.CreatorId, | 29 | CreatorId: m.CreatorId, |
| 30 | Type: m.Type, | 30 | Type: m.Type, |
| 31 | + SysType: m.SysType, | ||
| 31 | Rating: m.Rating, | 32 | Rating: m.Rating, |
| 32 | Score: m.Score, | 33 | Score: m.Score, |
| 33 | CreatedAt: m.CreatedAt, | 34 | CreatedAt: m.CreatedAt, |
| @@ -44,6 +45,7 @@ func (repo *EvaluationRuleRepository) TransformToModel(d *domain.EvaluationRule) | @@ -44,6 +45,7 @@ func (repo *EvaluationRuleRepository) TransformToModel(d *domain.EvaluationRule) | ||
| 44 | CompanyId: d.CompanyId, | 45 | CompanyId: d.CompanyId, |
| 45 | CreatorId: d.CreatorId, | 46 | CreatorId: d.CreatorId, |
| 46 | Type: d.Type, | 47 | Type: d.Type, |
| 48 | + SysType: d.SysType, | ||
| 47 | Rating: d.Rating, | 49 | Rating: d.Rating, |
| 48 | Score: d.Score, | 50 | Score: d.Score, |
| 49 | CreatedAt: d.CreatedAt, | 51 | CreatedAt: d.CreatedAt, |
| @@ -143,6 +145,10 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -143,6 +145,10 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
| 143 | query.Where("type = ?", v) | 145 | query.Where("type = ?", v) |
| 144 | } | 146 | } |
| 145 | 147 | ||
| 148 | + if v, ok := queryOptions["sysType"]; ok && v.(int) >= 0 { | ||
| 149 | + query.Where("sys_type = ?", v) | ||
| 150 | + } | ||
| 151 | + | ||
| 146 | if v, ok := queryOptions["limit"].(int64); ok { | 152 | if v, ok := queryOptions["limit"].(int64); ok { |
| 147 | query.Limit(int(v)) | 153 | query.Limit(int(v)) |
| 148 | } | 154 | } |
| @@ -2,9 +2,14 @@ package controllers | @@ -2,9 +2,14 @@ package controllers | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/linmadan/egglib-go/core/application" | 4 | "github.com/linmadan/egglib-go/core/application" |
| 5 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
| 5 | "github.com/linmadan/egglib-go/web/beego" | 6 | "github.com/linmadan/egglib-go/web/beego" |
| 6 | "github.com/xuri/excelize/v2" | 7 | "github.com/xuri/excelize/v2" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
| 11 | + "strconv" | ||
| 12 | + "strings" | ||
| 8 | ) | 13 | ) |
| 9 | 14 | ||
| 10 | type ImportController struct { | 15 | type ImportController struct { |
| @@ -37,8 +42,82 @@ func (controller *ImportController) Import() { | @@ -37,8 +42,82 @@ func (controller *ImportController) Import() { | ||
| 37 | switch formType { | 42 | switch formType { |
| 38 | case "PerformanceDimension": | 43 | case "PerformanceDimension": |
| 39 | dimensions, _ := domain.LoadPerformanceDimensions(rows) | 44 | dimensions, _ := domain.LoadPerformanceDimensions(rows) |
| 40 | - controller.Response(dimensions, nil) | 45 | + list := controller.parseTemplateNodeContent(dimensions) |
| 46 | + controller.Response(tool_funs.SimpleWrapGridMap(int64(len(list)), list), nil) | ||
| 41 | default: | 47 | default: |
| 42 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, "请确认您导入的表单类型")) | 48 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, "请确认您导入的表单类型")) |
| 43 | } | 49 | } |
| 44 | } | 50 | } |
| 51 | + | ||
| 52 | +func (controller *ImportController) parseTemplateNodeContent(data []*domain.PerformanceDimension) []*domain.NodeContent { | ||
| 53 | + nodeContents := make([]*domain.NodeContent, 0) | ||
| 54 | + | ||
| 55 | + transactionContext, err := factory.StartTransaction() | ||
| 56 | + if err != nil { | ||
| 57 | + return nodeContents | ||
| 58 | + } | ||
| 59 | + defer func() { | ||
| 60 | + transactionContext.RollbackTransaction() | ||
| 61 | + }() | ||
| 62 | + // 获取当前公司下的默认规则 | ||
| 63 | + ua := middlewares.GetUser(controller.Ctx) | ||
| 64 | + ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 65 | + _, rules, err := ruleRepository.Find(map[string]interface{}{"companyId": ua.CompanyId, "sysType": domain.EvaluationSysTypeSystem, "limit": 1}) | ||
| 66 | + if err != nil { | ||
| 67 | + return nodeContents | ||
| 68 | + } | ||
| 69 | + var ruleId = int64(0) | ||
| 70 | + if len(rules) == 0 { | ||
| 71 | + newRule := domain.GenerateSysRule(ua.CompanyId) // 生成一个系统默认规则 | ||
| 72 | + if rule, err := ruleRepository.Insert(newRule); err != nil { | ||
| 73 | + return nodeContents | ||
| 74 | + } else { | ||
| 75 | + ruleId = rule.Id | ||
| 76 | + } | ||
| 77 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 78 | + return nodeContents | ||
| 79 | + } | ||
| 80 | + } else { | ||
| 81 | + ruleId = rules[0].Id | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + for i := range data { | ||
| 85 | + dimension := data[i] | ||
| 86 | + for i2 := range dimension.PerformanceModule { | ||
| 87 | + nc := &domain.NodeContent{} | ||
| 88 | + nc.Category = dimension.Name // 类别 | ||
| 89 | + | ||
| 90 | + module := dimension.PerformanceModule[i2] | ||
| 91 | + nc.Name = module.ModuleName // 名称 | ||
| 92 | + nc.RuleId = ruleId // 规则ID | ||
| 93 | + sIndex := strings.Index(module.Weight, "%") // 权重 | ||
| 94 | + if sIndex != -1 { | ||
| 95 | + iWeight, _ := strconv.Atoi(module.Weight[:sIndex]) | ||
| 96 | + nc.Weight = iWeight | ||
| 97 | + } else { | ||
| 98 | + nc.Weight = 0 | ||
| 99 | + } | ||
| 100 | + nc.PromptTitle = "" // 提示项标题 | ||
| 101 | + nc.PromptText = module.Standard // 提示项内容 | ||
| 102 | + nc.EntryItems = make([]*domain.EntryItem, 0) // 输入项 | ||
| 103 | + for i3 := range module.Target { | ||
| 104 | + target := module.Target[i3] | ||
| 105 | + nc.EntryItems = append(nc.EntryItems, &domain.EntryItem{ | ||
| 106 | + Title: target.Task, // 输入型标题 | ||
| 107 | + HintText: "", // 输入项提示文本 | ||
| 108 | + }) | ||
| 109 | + } | ||
| 110 | + // 没有任何输入项时,默认1个 | ||
| 111 | + if len(nc.EntryItems) == 0 { | ||
| 112 | + nc.EntryItems = append(nc.EntryItems, &domain.EntryItem{ | ||
| 113 | + Title: "填写反馈", | ||
| 114 | + HintText: "", | ||
| 115 | + }) | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + nodeContents = append(nodeContents, nc) | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + return nodeContents | ||
| 123 | +} |
| @@ -258,3 +258,21 @@ func (c *StaffAssessController) ListTargetUserInviteAssess() { | @@ -258,3 +258,21 @@ func (c *StaffAssessController) ListTargetUserInviteAssess() { | ||
| 258 | data, err := srv.ListTargetUserAssess(paramReq) | 258 | data, err := srv.ListTargetUserAssess(paramReq) |
| 259 | c.Response(data, err) | 259 | c.Response(data, err) |
| 260 | } | 260 | } |
| 261 | + | ||
| 262 | +func (c *StaffAssessController) ListTargetUserMeSupperAssess() { | ||
| 263 | + srv := service.NewStaffAssessServeice() | ||
| 264 | + paramReq := &query.ListTargetUserAssessQuery{} | ||
| 265 | + err := c.BindJSON(paramReq) | ||
| 266 | + if err != nil { | ||
| 267 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
| 268 | + c.Response(nil, e) | ||
| 269 | + return | ||
| 270 | + } | ||
| 271 | + // paramReq.CompanyId = 1 | ||
| 272 | + userReq := middlewares.GetUser(c.Ctx) | ||
| 273 | + paramReq.CompanyId = int(userReq.CompanyId) | ||
| 274 | + paramReq.Types = []string{string(domain.AssessSuper)} | ||
| 275 | + paramReq.TargetUserId = int(userReq.UserId) | ||
| 276 | + data, err := srv.ListTargetUserAssess(paramReq) | ||
| 277 | + c.Response(data, err) | ||
| 278 | +} |
| 1 | +package controllers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "io/ioutil" | ||
| 5 | + | ||
| 6 | + "github.com/linmadan/egglib-go/core/application" | ||
| 7 | + "github.com/linmadan/egglib-go/web/beego" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type TemplateImplController struct { | ||
| 11 | + beego.BaseController | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +func (controller *TemplateImplController) TemplateQuestion() { | ||
| 15 | + fileBytes, err := ioutil.ReadFile("./templates/tpl_template_question.xlsx") | ||
| 16 | + if err != nil { | ||
| 17 | + controller.Response(nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未读取到模板文件")) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + controller.WriteExcel(fileBytes, "评估导入模板.xlsx") | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func (controller *TemplateImplController) WriteExcel(fileBytes []byte, fileName string) { | ||
| 24 | + controller.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName) | ||
| 25 | + controller.Ctx.Output.Header("Content-Description", "FileTransfer") | ||
| 26 | + controller.Ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") | ||
| 27 | + controller.Ctx.Output.Header("Content-Transfer-Encoding", "binary") | ||
| 28 | + controller.Ctx.Output.Header("Expires", "0") | ||
| 29 | + _, _ = controller.Ctx.ResponseWriter.Write(fileBytes) | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +func (controller *TemplateImplController) WriteBinary(fileBytes []byte, fileName string) { | ||
| 33 | + controller.Ctx.Output.Header("Content-Disposition", "attachment;filename="+fileName) | ||
| 34 | + controller.Ctx.Output.Header("Content-Description", "FileTransfer") | ||
| 35 | + controller.Ctx.Output.Header("Content-Type", "application/octet-stream") | ||
| 36 | + controller.Ctx.Output.Header("Content-Transfer-Encoding", "binary") | ||
| 37 | + controller.Ctx.Output.Header("Expires", "0") | ||
| 38 | + _, _ = controller.Ctx.ResponseWriter.Write(fileBytes) | ||
| 39 | +} |
| @@ -17,17 +17,18 @@ func init() { | @@ -17,17 +17,18 @@ func init() { | ||
| 17 | // /v1/staff-assess/self/me/list | 17 | // /v1/staff-assess/self/me/list |
| 18 | assessNS := web.NewNamespace("/v1/staff-assess", | 18 | assessNS := web.NewNamespace("/v1/staff-assess", |
| 19 | web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), | 19 | web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), |
| 20 | - web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表 | ||
| 21 | - web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情 | ||
| 22 | - web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工 | ||
| 23 | - web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工 | ||
| 24 | - web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 | ||
| 25 | - web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表 | ||
| 26 | - web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表 | ||
| 27 | - web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情 | ||
| 28 | - web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情 | ||
| 29 | - web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工评估的详情 | ||
| 30 | - web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情 | 20 | + web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表 |
| 21 | + web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情 | ||
| 22 | + web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工 | ||
| 23 | + web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工 | ||
| 24 | + web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 | ||
| 25 | + web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表 | ||
| 26 | + web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表 | ||
| 27 | + web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情 | ||
| 28 | + web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情 | ||
| 29 | + web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表 | ||
| 30 | + web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表 | ||
| 31 | + web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情 | ||
| 31 | 32 | ||
| 32 | ) | 33 | ) |
| 33 | web.AddNamespace(assessTaskNS) | 34 | web.AddNamespace(assessTaskNS) |
pkg/port/beego/routers/template_router.go
0 → 100644
| 1 | +package routers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/beego/beego/v2/server/web" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +func init() { | ||
| 9 | + web.Router("/templates/tpl_template_question.xlsx", &controllers.TemplateImplController{}, "Get:TemplateQuestion") | ||
| 10 | +} |
templates/tpl_template_question.xlsx
0 → 100644
不能预览此文件类型
-
请 注册 或 登录 后发表评论