Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/performance into test
正在显示
76 个修改的文件
包含
2649 行增加
和
576 行删除
| @@ -11,7 +11,7 @@ type CreateCycleCommand struct { | @@ -11,7 +11,7 @@ type CreateCycleCommand struct { | ||
| 11 | Name string `cname:"周期名称" json:"name" valid:"Required"` | 11 | Name string `cname:"周期名称" json:"name" valid:"Required"` |
| 12 | TimeStart *time.Time `cname:"起始时间" json:"timeStart"` | 12 | TimeStart *time.Time `cname:"起始时间" json:"timeStart"` |
| 13 | TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` | 13 | TimeEnd *time.Time `cname:"截至时间" json:"timeEnd"` |
| 14 | - KpiCycle int `cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"` | 14 | + KpiCycle int `cname:"考核周期" json:"kpiCycle" valid:"Required"` |
| 15 | TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` | 15 | TemplateIds []string `cname:"周期使用模板ID" json:"templateIds"` |
| 16 | } | 16 | } |
| 17 | 17 |
| @@ -15,3 +15,12 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | @@ -15,3 +15,12 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | ||
| 15 | return | 15 | return |
| 16 | } | 16 | } |
| 17 | } | 17 | } |
| 18 | + | ||
| 19 | +type StatisticCycleProjectUserCommand struct { | ||
| 20 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
| 21 | + CycleId int64 `cname:"周期ID" json:"cycleId,string"` | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { | ||
| 25 | + | ||
| 26 | +} |
| @@ -30,6 +30,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -30,6 +30,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
| 30 | cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | 30 | cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 31 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 31 | cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 32 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 32 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 33 | + ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 33 | 34 | ||
| 34 | // 检测名称重复 | 35 | // 检测名称重复 |
| 35 | count, err := cycleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId}) | 36 | count, err := cycleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId}) |
| @@ -48,6 +49,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -48,6 +49,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
| 48 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择") | 49 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "模板不存在, 请重新选择") |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 52 | + // 生成新周期数据 | ||
| 51 | newCycle := &domain.EvaluationCycle{ | 53 | newCycle := &domain.EvaluationCycle{ |
| 52 | Id: 0, | 54 | Id: 0, |
| 53 | Name: in.Name, | 55 | Name: in.Name, |
| @@ -62,8 +64,41 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -62,8 +64,41 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
| 62 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 64 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 63 | } | 65 | } |
| 64 | 66 | ||
| 67 | + // 获取所有模板中的规则对象数据 | ||
| 68 | + ruleIds := make([]int64, 0) | ||
| 69 | + ruleMap := map[int64]*domain.EvaluationRule{} | ||
| 65 | for i := range templates { | 70 | for i := range templates { |
| 66 | v := templates[i] | 71 | v := templates[i] |
| 72 | + for j := range v.LinkNodes { | ||
| 73 | + node := v.LinkNodes[j] | ||
| 74 | + for k := range node.NodeContents { | ||
| 75 | + nodeContent := node.NodeContents[k] | ||
| 76 | + ruleIds = append(ruleIds, nodeContent.RuleId) | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + _, rules, err := ruleRepository.Find(map[string]interface{}{"ids": ruleIds, "companyId": in.CompanyId}) | ||
| 81 | + for i := range rules { | ||
| 82 | + ruleMap[rules[i].Id] = rules[i] | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + ctAdapter := &adapter.CycleTemplateAdapter{} | ||
| 86 | + ctAdapter.EvaluationCycle = cycle | ||
| 87 | + for i := range templates { | ||
| 88 | + v := templates[i] | ||
| 89 | + | ||
| 90 | + // 对评估模板中的评估规则进行数据赋值 | ||
| 91 | + for j := range v.LinkNodes { | ||
| 92 | + node := v.LinkNodes[j] | ||
| 93 | + for k := range node.NodeContents { | ||
| 94 | + nodeContent := node.NodeContents[k] | ||
| 95 | + if rule, ok := ruleMap[nodeContent.RuleId]; ok { | ||
| 96 | + nodeContent.Rule = rule | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + // 插入周期中的模板数据 | ||
| 67 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 102 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
| 68 | Id: 0, | 103 | Id: 0, |
| 69 | Name: v.Name, | 104 | Name: v.Name, |
| @@ -74,12 +109,19 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -74,12 +109,19 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
| 74 | if err != nil { | 109 | if err != nil { |
| 75 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 110 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 76 | } | 111 | } |
| 112 | + | ||
| 113 | + // 输出模板简单信息 | ||
| 114 | + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | ||
| 115 | + Id: cycleTemplate.Id, | ||
| 116 | + Name: cycleTemplate.Name, | ||
| 117 | + CreatedAt: cycleTemplate.CreatedAt, | ||
| 118 | + }) | ||
| 77 | } | 119 | } |
| 78 | 120 | ||
| 79 | if err := transactionContext.CommitTransaction(); err != nil { | 121 | if err := transactionContext.CommitTransaction(); err != nil { |
| 80 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 122 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 81 | } | 123 | } |
| 82 | - return cycle, nil | 124 | + return ctAdapter, nil |
| 83 | 125 | ||
| 84 | } | 126 | } |
| 85 | 127 | ||
| @@ -166,10 +208,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -166,10 +208,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
| 166 | if err != nil { | 208 | if err != nil { |
| 167 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 209 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 168 | } | 210 | } |
| 211 | + | ||
| 212 | + _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": cycle.Id}, "template") | ||
| 213 | + if err != nil { | ||
| 214 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + ctAdapter := &adapter.CycleTemplateAdapter{} | ||
| 218 | + ctAdapter.EvaluationCycle = cycle | ||
| 219 | + for i := range cycleTemplates { | ||
| 220 | + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | ||
| 221 | + Id: cycleTemplates[i].Id, | ||
| 222 | + Name: cycleTemplates[i].Name, | ||
| 223 | + CreatedAt: cycleTemplates[i].CreatedAt, | ||
| 224 | + }) | ||
| 225 | + } | ||
| 226 | + | ||
| 169 | if err := transactionContext.CommitTransaction(); err != nil { | 227 | if err := transactionContext.CommitTransaction(); err != nil { |
| 170 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 228 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 171 | } | 229 | } |
| 172 | - return cycle, nil | 230 | + return ctAdapter, nil |
| 173 | } | 231 | } |
| 174 | 232 | ||
| 175 | func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { | 233 | func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { |
| @@ -249,10 +307,57 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | @@ -249,10 +307,57 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | ||
| 249 | transactionContext.RollbackTransaction() | 307 | transactionContext.RollbackTransaction() |
| 250 | }() | 308 | }() |
| 251 | cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | 309 | cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 252 | - // FIXME 总数量是否使用Count获取一个总数量 | ||
| 253 | - count, cycles, err := cycleRepository.Find(tool_funs.SimpleStructToMap(in)) | 310 | + total, cycles, err := cycleRepository.Find(tool_funs.SimpleStructToMap(in)) |
| 311 | + if err != nil { | ||
| 312 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 313 | + } | ||
| 314 | + return tool_funs.SimpleWrapGridMap(total, cycles), nil | ||
| 315 | +} | ||
| 316 | + | ||
| 317 | +func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) { | ||
| 318 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 319 | + if err != nil { | ||
| 320 | + return nil, err | ||
| 321 | + } | ||
| 322 | + defer func() { | ||
| 323 | + transactionContext.RollbackTransaction() | ||
| 324 | + }() | ||
| 325 | + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 326 | + _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | ||
| 254 | if err != nil { | 327 | if err != nil { |
| 255 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 328 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 256 | } | 329 | } |
| 257 | - return tool_funs.SimpleWrapGridMap(count, cycles), nil | 330 | + |
| 331 | + userIds := make([]int64, 0) | ||
| 332 | + userIdMap := map[int64]int64{} | ||
| 333 | + for i := range projects { | ||
| 334 | + project := projects[i] | ||
| 335 | + for j := range project.Recipients { | ||
| 336 | + userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64) | ||
| 337 | + userIdMap[userId] = userId | ||
| 338 | + } | ||
| 339 | + } | ||
| 340 | + for _, v := range userIdMap { | ||
| 341 | + userIds = append(userIds, v) | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + userTotal := 0 | ||
| 345 | + departmentTotal := 0 | ||
| 346 | + if len(userIds) > 0 { | ||
| 347 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 348 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) | ||
| 349 | + departmentIdMap := map[int]int{} | ||
| 350 | + for i := range users { | ||
| 351 | + for _, v := range users[i].DepartmentId { | ||
| 352 | + departmentIdMap[v] = v | ||
| 353 | + } | ||
| 354 | + } | ||
| 355 | + userTotal = len(users) | ||
| 356 | + departmentTotal = len(departmentIdMap) | ||
| 357 | + } | ||
| 358 | + | ||
| 359 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 360 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 361 | + } | ||
| 362 | + return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | ||
| 258 | } | 363 | } |
| @@ -2,25 +2,19 @@ package command | @@ -2,25 +2,19 @@ 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 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 6 | ) | 5 | ) |
| 7 | 6 | ||
| 8 | -type StateProjectCommand struct { | 7 | +type ActivateProjectCommand struct { |
| 9 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | 8 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` |
| 10 | - State int `cname:"项目状态" json:"state"` | ||
| 11 | } | 9 | } |
| 12 | 10 | ||
| 13 | type CopyProjectCommand struct { | 11 | type CopyProjectCommand struct { |
| 12 | + CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
| 14 | Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` | 13 | Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` |
| 15 | } | 14 | } |
| 16 | 15 | ||
| 17 | -func (in *StateProjectCommand) Valid(validation *validation.Validation) { | ||
| 18 | - switch in.State { | ||
| 19 | - case domain.ProjectStateWaitConfig, domain.ProjectStateWaitActive, domain.ProjectStateEnable, domain.ProjectStateDisable: | ||
| 20 | - default: | ||
| 21 | - validation.SetError("state", "状态设置错误") | ||
| 22 | - return | ||
| 23 | - } | 16 | +func (in *ActivateProjectCommand) Valid(validation *validation.Validation) { |
| 17 | + | ||
| 24 | } | 18 | } |
| 25 | 19 | ||
| 26 | func (in *CopyProjectCommand) Valid(*validation.Validation) { | 20 | func (in *CopyProjectCommand) Valid(*validation.Validation) { |
| @@ -18,12 +18,3 @@ func (in *QueryProjectCommand) Valid(validation *validation.Validation) { | @@ -18,12 +18,3 @@ func (in *QueryProjectCommand) Valid(validation *validation.Validation) { | ||
| 18 | return | 18 | return |
| 19 | } | 19 | } |
| 20 | } | 20 | } |
| 21 | - | ||
| 22 | -type StatisticCycleProjectUserCommand struct { | ||
| 23 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
| 24 | - CycleId int64 `cname:"周期ID" json:"cycleId,string"` | ||
| 25 | -} | ||
| 26 | - | ||
| 27 | -func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { | ||
| 28 | - | ||
| 29 | -} |
| @@ -2,7 +2,7 @@ package command | @@ -2,7 +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 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 5 | + "time" |
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type UpdateProjectCommand struct { | 8 | type UpdateProjectCommand struct { |
| @@ -22,15 +22,18 @@ type UpdateProjectTemplateCommand struct { | @@ -22,15 +22,18 @@ type UpdateProjectTemplateCommand struct { | ||
| 22 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | 22 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` |
| 23 | TemplateId int64 `cname:"模板ID" json:"templateId,string"` | 23 | TemplateId int64 `cname:"模板ID" json:"templateId,string"` |
| 24 | Recipients []string `cname:"被评估人ID" json:"recipients"` | 24 | Recipients []string `cname:"被评估人ID" json:"recipients"` |
| 25 | + TimeStart *time.Time `cname:"自评起始时间" json:"timeStart" valid:"Required"` | ||
| 26 | + TimeEnd *time.Time `cname:"自评截止时间" json:"timeEnd" valid:"Required"` | ||
| 27 | + KpiCycle int `cname:"评估周期" json:"kpiCycle" valid:"Required"` | ||
| 28 | + KpiResultStart *time.Time `cname:"绩效结果开始查看时间" json:"kpiResultStart"` | ||
| 29 | + Activate int `cname:"启动项目" json:"activate"` | ||
| 25 | } | 30 | } |
| 26 | 31 | ||
| 27 | -type UpdateProjectTemplateNodeCommand struct { | 32 | +type CheckRecipientCommand struct { |
| 28 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 33 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
| 29 | CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | 34 | CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` |
| 30 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` | 35 | Id int64 `cname:"项目ID" json:"id,string" valid:"Required"` |
| 31 | - TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"` | ||
| 32 | - LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` | ||
| 33 | - Activate int `cname:"启动项目" json:"activate"` | 36 | + Recipients []string `cname:"被评估人ID" json:"recipients"` |
| 34 | } | 37 | } |
| 35 | 38 | ||
| 36 | func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { | 39 | func (in *UpdateProjectCommand) Valid(validation *validation.Validation) { |
| @@ -46,10 +49,3 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | @@ -46,10 +49,3 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation) | ||
| 46 | return | 49 | return |
| 47 | } | 50 | } |
| 48 | } | 51 | } |
| 49 | - | ||
| 50 | -func (in *UpdateProjectTemplateNodeCommand) Valid(validation *validation.Validation) { | ||
| 51 | - if len(in.LinkNodes) == 0 { | ||
| 52 | - validation.SetError("linkNodes", "请添加评估流程") | ||
| 53 | - return | ||
| 54 | - } | ||
| 55 | -} |
| @@ -55,10 +55,19 @@ func (rs *EvaluationProjectService) Create(in *command.CreateProjectCommand) (in | @@ -55,10 +55,19 @@ func (rs *EvaluationProjectService) Create(in *command.CreateProjectCommand) (in | ||
| 55 | if err != nil { | 55 | if err != nil { |
| 56 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 56 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 57 | } | 57 | } |
| 58 | + | ||
| 59 | + projectAdapter := &adapter.EvaluationProjectAdapter{} | ||
| 60 | + projectAdapter.EvaluationProject = project | ||
| 61 | + if len(project.PmpIds) > 0 { | ||
| 62 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 63 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": project.PmpIds, "limit": len(project.PmpIds)}) | ||
| 64 | + projectAdapter.TransformPmpAdapter(users) | ||
| 65 | + } | ||
| 66 | + | ||
| 58 | if err := transactionContext.CommitTransaction(); err != nil { | 67 | if err := transactionContext.CommitTransaction(); err != nil { |
| 59 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 68 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 60 | } | 69 | } |
| 61 | - return project, nil | 70 | + return projectAdapter, nil |
| 62 | 71 | ||
| 63 | } | 72 | } |
| 64 | 73 | ||
| @@ -96,10 +105,19 @@ func (rs *EvaluationProjectService) Update(in *command.UpdateProjectCommand) (in | @@ -96,10 +105,19 @@ func (rs *EvaluationProjectService) Update(in *command.UpdateProjectCommand) (in | ||
| 96 | if err != nil { | 105 | if err != nil { |
| 97 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 106 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 98 | } | 107 | } |
| 108 | + | ||
| 109 | + projectAdapter := &adapter.EvaluationProjectAdapter{} | ||
| 110 | + projectAdapter.EvaluationProject = project | ||
| 111 | + if len(project.PmpIds) > 0 { | ||
| 112 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 113 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": project.PmpIds, "limit": len(project.PmpIds)}) | ||
| 114 | + projectAdapter.TransformPmpAdapter(users) | ||
| 115 | + } | ||
| 116 | + | ||
| 99 | if err := transactionContext.CommitTransaction(); err != nil { | 117 | if err := transactionContext.CommitTransaction(); err != nil { |
| 100 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 118 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 101 | } | 119 | } |
| 102 | - return project, nil | 120 | + return projectAdapter, nil |
| 103 | } | 121 | } |
| 104 | 122 | ||
| 105 | func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemplateCommand) (interface{}, error) { | 123 | func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemplateCommand) (interface{}, error) { |
| @@ -145,48 +163,33 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -145,48 +163,33 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
| 145 | if err != nil { | 163 | if err != nil { |
| 146 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 164 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 147 | } | 165 | } |
| 166 | + | ||
| 148 | cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) | 167 | cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId, "includeDeleted": true}) |
| 149 | if err != nil { | 168 | if err != nil { |
| 150 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 169 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 151 | } | 170 | } |
| 152 | 171 | ||
| 153 | - project.Recipients = in.Recipients | ||
| 154 | - project.Template = cycleTemplate.Template | ||
| 155 | - | ||
| 156 | - project, err = projectRepository.Insert(project) | ||
| 157 | - if err != nil { | ||
| 158 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 172 | + // FIXME 启动时,需要激活定时任务 |
| 173 | + if in.Activate == 1 { | ||
| 174 | + if len(in.Recipients) == 0 { | ||
| 175 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | ||
| 159 | } | 176 | } |
| 160 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
| 161 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 177 | + project.State = domain.ProjectStateEnable |
| 162 | } | 178 | } |
| 163 | - return project, nil | ||
| 164 | -} | ||
| 165 | 179 | ||
| 166 | -func (rs *EvaluationProjectService) UpdateTemplateNode(in *command.UpdateProjectTemplateNodeCommand) (interface{}, error) { | ||
| 167 | - transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 168 | - if err != nil { | ||
| 169 | - return nil, err | ||
| 170 | - } | ||
| 171 | - defer func() { | ||
| 172 | - transactionContext.RollbackTransaction() | ||
| 173 | - }() | ||
| 174 | - | ||
| 175 | - projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 176 | - | ||
| 177 | - project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
| 178 | - if err != nil { | ||
| 179 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 180 | + project.Recipients = in.Recipients |
| 181 | + project.Template = cycleTemplate.Template | ||
| 182 | + for i := range project.Template.LinkNodes { | ||
| 183 | + node := project.Template.LinkNodes[i] | ||
| 184 | + node.KpiCycle = in.KpiCycle // 设置周期 | ||
| 185 | + if node.Type == domain.LinkNodeViewResult { | ||
| 186 | + if in.KpiResultStart != nil { | ||
| 187 | + node.TimeStart = in.KpiResultStart | ||
| 180 | } | 188 | } |
| 181 | - | ||
| 182 | - // FIXME 启动时,需要激活定时任务 | ||
| 183 | - if in.Activate == 1 { | ||
| 184 | - project.State = domain.ProjectStateEnable | 189 | + } else { |
| 190 | + node.TimeStart = in.TimeStart | ||
| 191 | + node.TimeEnd = in.TimeEnd | ||
| 185 | } | 192 | } |
| 186 | - for i := range in.LinkNodes { | ||
| 187 | - project.Template.LinkNodes[i].TimeStart = in.LinkNodes[i].TimeStart | ||
| 188 | - project.Template.LinkNodes[i].TimeEnd = in.LinkNodes[i].TimeEnd | ||
| 189 | - project.Template.LinkNodes[i].KpiCycle = in.LinkNodes[i].KpiCycle | ||
| 190 | } | 193 | } |
| 191 | 194 | ||
| 192 | project, err = projectRepository.Insert(project) | 195 | project, err = projectRepository.Insert(project) |
| @@ -268,8 +271,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | @@ -268,8 +271,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | ||
| 268 | }() | 271 | }() |
| 269 | 272 | ||
| 270 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 273 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 271 | - // FIXME 总数量是否使用Count获取一个总数量 | ||
| 272 | - count, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 274 | + total, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") |
| 273 | if err != nil { | 275 | if err != nil { |
| 274 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 276 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 275 | } | 277 | } |
| @@ -288,10 +290,10 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | @@ -288,10 +290,10 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | ||
| 288 | pmpUsers = users | 290 | pmpUsers = users |
| 289 | } | 291 | } |
| 290 | projectAdapters := adapter.TransformProjectListAdapter(projects, pmpUsers) | 292 | projectAdapters := adapter.TransformProjectListAdapter(projects, pmpUsers) |
| 291 | - return tool_funs.SimpleWrapGridMap(count, projectAdapters), nil | 293 | + return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil |
| 292 | } | 294 | } |
| 293 | 295 | ||
| 294 | -func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (interface{}, error) { | 296 | +func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) (interface{}, error) { |
| 295 | transactionContext, err := factory.ValidateStartTransaction(in) | 297 | transactionContext, err := factory.ValidateStartTransaction(in) |
| 296 | if err != nil { | 298 | if err != nil { |
| 297 | return nil, err | 299 | return nil, err |
| @@ -301,13 +303,20 @@ func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (inte | @@ -301,13 +303,20 @@ func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (inte | ||
| 301 | }() | 303 | }() |
| 302 | 304 | ||
| 303 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 305 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 304 | - | ||
| 305 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | 306 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) |
| 306 | if err != nil { | 307 | if err != nil { |
| 307 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 308 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 308 | } | 309 | } |
| 309 | 310 | ||
| 310 | - project.State = in.State | 311 | + if project.Template == nil { |
| 312 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加评估模板") | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + if len(project.Recipients) == 0 { | ||
| 316 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请添加被评估人") | ||
| 317 | + } | ||
| 318 | + | ||
| 319 | + project.State = domain.TemplateStateEnable | ||
| 311 | project, err = projectRepository.Insert(project) | 320 | project, err = projectRepository.Insert(project) |
| 312 | if err != nil { | 321 | if err != nil { |
| 313 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 322 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -333,6 +342,10 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -333,6 +342,10 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
| 333 | } | 342 | } |
| 334 | // ID重置 | 343 | // ID重置 |
| 335 | project.Id = 0 | 344 | project.Id = 0 |
| 345 | + project.Name = project.Name + " 副本" | ||
| 346 | + project.CreatorId = in.CreatorId | ||
| 347 | + project.Recipients = make([]string, 0) // 重置被评估人 | ||
| 348 | + | ||
| 336 | // 如果拷贝已经启用的模板,默认先设置为待启用 | 349 | // 如果拷贝已经启用的模板,默认先设置为待启用 |
| 337 | if project.State == domain.ProjectStateEnable { | 350 | if project.State == domain.ProjectStateEnable { |
| 338 | project.State = domain.ProjectStateWaitActive | 351 | project.State = domain.ProjectStateWaitActive |
| @@ -347,7 +360,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -347,7 +360,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
| 347 | return project, nil | 360 | return project, nil |
| 348 | } | 361 | } |
| 349 | 362 | ||
| 350 | -func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) { | 363 | +func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCommand) (interface{}, error) { |
| 351 | transactionContext, err := factory.ValidateStartTransaction(in) | 364 | transactionContext, err := factory.ValidateStartTransaction(in) |
| 352 | if err != nil { | 365 | if err != nil { |
| 353 | return nil, err | 366 | return nil, err |
| @@ -355,42 +368,41 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl | @@ -355,42 +368,41 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl | ||
| 355 | defer func() { | 368 | defer func() { |
| 356 | transactionContext.RollbackTransaction() | 369 | transactionContext.RollbackTransaction() |
| 357 | }() | 370 | }() |
| 371 | + | ||
| 358 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 372 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 359 | - _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 373 | + |
| 374 | + _, projects, err := projectRepository.Find(map[string]interface{}{"companyId": in.CompanyId, "cycleId": in.CycleId}, "linkNodes") | ||
| 360 | if err != nil { | 375 | if err != nil { |
| 361 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 376 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 362 | } | 377 | } |
| 363 | 378 | ||
| 364 | - userIds := make([]int64, 0) | ||
| 365 | - userIdMap := map[int64]int64{} | 379 | + // 周期内的所有项目,员工不能重复被评估 |
| 380 | + rids := map[string]bool{} | ||
| 366 | for i := range projects { | 381 | for i := range projects { |
| 367 | - project := projects[i] | ||
| 368 | - for j := range project.Recipients { | ||
| 369 | - userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64) | ||
| 370 | - userIdMap[userId] = userId | ||
| 371 | - } | 382 | + // 排除当前项目 |
| 383 | + if in.Id != projects[i].Id { | ||
| 384 | + ids := projects[i].Recipients | ||
| 385 | + for j := range ids { | ||
| 386 | + rids[ids[j]] = true | ||
| 372 | } | 387 | } |
| 373 | - for _, v := range userIdMap { | ||
| 374 | - userIds = append(userIds, v) | ||
| 375 | } | 388 | } |
| 376 | - | ||
| 377 | - userTotal := 0 | ||
| 378 | - departmentTotal := 0 | ||
| 379 | - if len(userIds) > 0 { | ||
| 380 | - userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 381 | - _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) | ||
| 382 | - departmentIdMap := map[int]int{} | ||
| 383 | - for i := range users { | ||
| 384 | - for _, v := range users[i].DepartmentId { | ||
| 385 | - departmentIdMap[v] = v | ||
| 386 | } | 389 | } |
| 390 | + repeatNum := 0 | ||
| 391 | + for i := range in.Recipients { | ||
| 392 | + id := in.Recipients[i] | ||
| 393 | + if _, ok := rids[id]; ok { | ||
| 394 | + repeatNum++ | ||
| 387 | } | 395 | } |
| 388 | - userTotal = len(users) | ||
| 389 | - departmentTotal = len(departmentIdMap) | ||
| 390 | } | 396 | } |
| 397 | + //if repeatNum > 0 { | ||
| 398 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum)) | ||
| 399 | + //} | ||
| 391 | 400 | ||
| 401 | + if err != nil { | ||
| 402 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 403 | + } | ||
| 392 | if err := transactionContext.CommitTransaction(); err != nil { | 404 | if err := transactionContext.CommitTransaction(); err != nil { |
| 393 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 405 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 394 | } | 406 | } |
| 395 | - return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | 407 | + return repeatNum, nil |
| 396 | } | 408 | } |
| @@ -11,8 +11,8 @@ type CreateRuleCommand struct { | @@ -11,8 +11,8 @@ type CreateRuleCommand struct { | ||
| 11 | Name string `cname:"规则名称" json:"name" valid:"Required"` | 11 | Name string `cname:"规则名称" json:"name" valid:"Required"` |
| 12 | Remark string `cname:"规则备注" json:"remark"` | 12 | Remark string `cname:"规则备注" json:"remark"` |
| 13 | Type int `cname:"评估方式" json:"type"` | 13 | Type int `cname:"评估方式" json:"type"` |
| 14 | - Rating *domain.Rating `cname:"评级" json:"rating"` | ||
| 15 | - Score *domain.Score `cname:"评分" json:"score"` | 14 | + Rating domain.Rating `cname:"评级" json:"rating"` |
| 15 | + Score domain.Score `cname:"评分" json:"score"` | ||
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | func (in *CreateRuleCommand) Valid(validation *validation.Validation) { | 18 | func (in *CreateRuleCommand) Valid(validation *validation.Validation) { |
| @@ -26,20 +26,23 @@ func (in *CreateRuleCommand) Valid(validation *validation.Validation) { | @@ -26,20 +26,23 @@ func (in *CreateRuleCommand) Valid(validation *validation.Validation) { | ||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | if len(in.Name) > 40 { | 28 | if len(in.Name) > 40 { |
| 29 | - validation.SetError("name", "角色名称最大长度40个字符") | 29 | + validation.SetError("name", "名称最大长度40个字符") |
| 30 | + return | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + if len(in.Remark) > 100 { | ||
| 34 | + validation.SetError("remark", "备注不能超过100个字符") | ||
| 30 | return | 35 | return |
| 31 | } | 36 | } |
| 32 | 37 | ||
| 33 | if in.Type == domain.EvaluationTypeRating { | 38 | if in.Type == domain.EvaluationTypeRating { |
| 34 | - if nil == in.Rating || len(in.Rating.Levels) == 0 { | 39 | + if len(in.Rating.Levels) == 0 { |
| 35 | validation.SetError("rating", "评级内容不能为空") | 40 | validation.SetError("rating", "评级内容不能为空") |
| 36 | return | 41 | return |
| 37 | } | 42 | } |
| 38 | - } | ||
| 39 | - | ||
| 40 | - if in.Type == domain.EvaluationTypeScore { | ||
| 41 | - if nil == in.Score { | ||
| 42 | - validation.SetError("rating", "评分内容不能为空") | 43 | + } else if in.Type == domain.EvaluationTypeScore { |
| 44 | + if len(in.Score.Levels) == 0 { | ||
| 45 | + validation.SetError("score", "评分内容不能为空") | ||
| 43 | return | 46 | return |
| 44 | } | 47 | } |
| 45 | } | 48 | } |
| @@ -5,6 +5,8 @@ import "github.com/beego/beego/v2/core/validation" | @@ -5,6 +5,8 @@ import "github.com/beego/beego/v2/core/validation" | ||
| 5 | type QueryRuleCommand struct { | 5 | type QueryRuleCommand struct { |
| 6 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 6 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
| 7 | NameOrRemark string `cname:"规则名称或备注" json:"nameOrRemark"` | 7 | NameOrRemark string `cname:"规则名称或备注" json:"nameOrRemark"` |
| 8 | + Type int `cname:"评估方式(0评级、1评分)" json:"type"` | ||
| 9 | + CreatorId int64 `cname:"创建人ID" json:"creatorId,string"` | ||
| 8 | PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | 10 | PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` |
| 9 | PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 11 | PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` |
| 10 | } | 12 | } |
| @@ -12,8 +12,8 @@ type UpdateRuleCommand struct { | @@ -12,8 +12,8 @@ type UpdateRuleCommand struct { | ||
| 12 | Name string `cname:"规则名称" json:"name" valid:"Required"` | 12 | Name string `cname:"规则名称" json:"name" valid:"Required"` |
| 13 | Remark string `cname:"规则备注" json:"remark"` | 13 | Remark string `cname:"规则备注" json:"remark"` |
| 14 | Type int `cname:"评估方式" json:"type"` | 14 | Type int `cname:"评估方式" json:"type"` |
| 15 | - Rating *domain.Rating `cname:"评级" json:"rating"` | ||
| 16 | - Score *domain.Score `cname:"评分" json:"score"` | 15 | + Rating domain.Rating `cname:"评级" json:"rating"` |
| 16 | + Score domain.Score `cname:"评分" json:"score"` | ||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | 19 | func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { |
| @@ -27,20 +27,23 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | @@ -27,20 +27,23 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { | ||
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | if len(in.Name) > 40 { | 29 | if len(in.Name) > 40 { |
| 30 | - validation.SetError("name", "角色名称最大长度40个字符") | 30 | + validation.SetError("name", "名称最大长度40个字符") |
| 31 | + return | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + if len(in.Remark) > 100 { | ||
| 35 | + validation.SetError("remark", "备注不能超过100个字符") | ||
| 31 | return | 36 | return |
| 32 | } | 37 | } |
| 33 | 38 | ||
| 34 | if in.Type == domain.EvaluationTypeRating { | 39 | if in.Type == domain.EvaluationTypeRating { |
| 35 | - if nil == in.Rating || len(in.Rating.Levels) == 0 { | 40 | + if len(in.Rating.Levels) == 0 { |
| 36 | validation.SetError("rating", "评级内容不能为空") | 41 | validation.SetError("rating", "评级内容不能为空") |
| 37 | return | 42 | return |
| 38 | } | 43 | } |
| 39 | - } | ||
| 40 | - | ||
| 41 | - if in.Type == domain.EvaluationTypeScore { | ||
| 42 | - if nil == in.Score { | ||
| 43 | - validation.SetError("rating", "评分内容不能为空") | 44 | + } else if in.Type == domain.EvaluationTypeScore { |
| 45 | + if len(in.Score.Levels) == 0 { | ||
| 46 | + validation.SetError("score", "评分内容不能为空") | ||
| 44 | return | 47 | return |
| 45 | } | 48 | } |
| 46 | } | 49 | } |
| @@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_rule/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_rule/command" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 10 | + "sort" | ||
| 10 | ) | 11 | ) |
| 11 | 12 | ||
| 12 | type EvaluationRuleService struct { | 13 | type EvaluationRuleService struct { |
| @@ -36,6 +37,13 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac | @@ -36,6 +37,13 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac | ||
| 36 | if count > 0 { | 37 | if count > 0 { |
| 37 | return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") | 38 | return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") |
| 38 | } | 39 | } |
| 40 | + | ||
| 41 | + if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序 | ||
| 42 | + sort.SliceStable(in.Rating.Levels, func(i, j int) bool { | ||
| 43 | + return in.Rating.Levels[i].QuantizedValue < in.Rating.Levels[j].QuantizedValue | ||
| 44 | + }) | ||
| 45 | + } | ||
| 46 | + | ||
| 39 | newRule := &domain.EvaluationRule{ | 47 | newRule := &domain.EvaluationRule{ |
| 40 | Id: 0, | 48 | Id: 0, |
| 41 | Name: in.Name, | 49 | Name: in.Name, |
| @@ -82,6 +90,12 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac | @@ -82,6 +90,12 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac | ||
| 82 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 90 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 83 | } | 91 | } |
| 84 | 92 | ||
| 93 | + if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序 | ||
| 94 | + sort.SliceStable(in.Rating.Levels, func(i, j int) bool { | ||
| 95 | + return in.Rating.Levels[i].QuantizedValue < in.Rating.Levels[j].QuantizedValue | ||
| 96 | + }) | ||
| 97 | + } | ||
| 98 | + | ||
| 85 | rule.Name = in.Name | 99 | rule.Name = in.Name |
| 86 | rule.Remark = in.Remark | 100 | rule.Remark = in.Remark |
| 87 | rule.Type = in.Type | 101 | rule.Type = in.Type |
| @@ -143,22 +157,22 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac | @@ -143,22 +157,22 @@ func (rs *EvaluationRuleService) Remove(in *command.DeleteRuleCommand) (interfac | ||
| 143 | return rule, nil | 157 | return rule, nil |
| 144 | } | 158 | } |
| 145 | 159 | ||
| 146 | -func (rs *EvaluationRuleService) List(in *command.QueryRuleCommand) (interface{}, error) { | ||
| 147 | - transactionContext, err := factory.StartTransaction() | ||
| 148 | - if err != nil { | ||
| 149 | - return nil, err | ||
| 150 | - } | ||
| 151 | - defer func() { | ||
| 152 | - transactionContext.RollbackTransaction() | ||
| 153 | - }() | ||
| 154 | - ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 155 | - // FIXME 总数量是否使用Count获取一个总数量 | ||
| 156 | - count, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in)) | ||
| 157 | - if err != nil { | ||
| 158 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 159 | - } | ||
| 160 | - return tool_funs.SimpleWrapGridMap(count, rules), nil | ||
| 161 | -} | 160 | +//func (rs *EvaluationRuleService) List(in *command.QueryRuleCommand) (interface{}, error) { |
| 161 | +// transactionContext, err := factory.StartTransaction() | ||
| 162 | +// if err != nil { | ||
| 163 | +// return nil, err | ||
| 164 | +// } | ||
| 165 | +// defer func() { | ||
| 166 | +// transactionContext.RollbackTransaction() | ||
| 167 | +// }() | ||
| 168 | +// ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 169 | +// | ||
| 170 | +// total, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in)) | ||
| 171 | +// if err != nil { | ||
| 172 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 173 | +// } | ||
| 174 | +// return tool_funs.SimpleWrapGridMap(total, rules), nil | ||
| 175 | +//} | ||
| 162 | 176 | ||
| 163 | func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (interface{}, error) { | 177 | func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (interface{}, error) { |
| 164 | transactionContext, err := factory.StartTransaction() | 178 | transactionContext, err := factory.StartTransaction() |
| @@ -171,8 +185,7 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -171,8 +185,7 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
| 171 | ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) | 185 | ruleRepository := factory.CreateEvaluationRuleRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 172 | userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 186 | userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 173 | 187 | ||
| 174 | - // FIXME 总数量是否使用Count获取一个总数量 | ||
| 175 | - count, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in)) | 188 | + total, rules, err := ruleRepository.Find(tool_funs.SimpleStructToMap(in)) |
| 176 | if err != nil { | 189 | if err != nil { |
| 177 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 190 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 178 | } | 191 | } |
| @@ -197,5 +210,5 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | @@ -197,5 +210,5 @@ func (rs *EvaluationRuleService) ListRelCreator(in *command.QueryRuleCommand) (i | ||
| 197 | ras[i].CreatorName = v | 210 | ras[i].CreatorName = v |
| 198 | } | 211 | } |
| 199 | } | 212 | } |
| 200 | - return tool_funs.SimpleWrapGridMap(count, ras), nil | 213 | + return tool_funs.SimpleWrapGridMap(total, ras), nil |
| 201 | } | 214 | } |
| @@ -8,7 +8,7 @@ type CreateTemplateCommand struct { | @@ -8,7 +8,7 @@ type CreateTemplateCommand struct { | ||
| 8 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 8 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
| 9 | CreatorId int64 `cname:"创建人ID" json:"creatorId"` | 9 | CreatorId int64 `cname:"创建人ID" json:"creatorId"` |
| 10 | Name string `cname:"模板名称" json:"name" valid:"Required"` | 10 | Name string `cname:"模板名称" json:"name" valid:"Required"` |
| 11 | - Describe string `cname:"模板描述" json:"remark"` | 11 | + Describe string `cname:"模板描述" json:"describe"` |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | func (in *CreateTemplateCommand) Valid(validation *validation.Validation) { | 14 | func (in *CreateTemplateCommand) Valid(validation *validation.Validation) { |
| @@ -25,4 +25,9 @@ func (in *CreateTemplateCommand) Valid(validation *validation.Validation) { | @@ -25,4 +25,9 @@ func (in *CreateTemplateCommand) Valid(validation *validation.Validation) { | ||
| 25 | validation.SetError("name", "模板名称最大长度40个字符") | 25 | validation.SetError("name", "模板名称最大长度40个字符") |
| 26 | return | 26 | return |
| 27 | } | 27 | } |
| 28 | + | ||
| 29 | + if len(in.Describe) > 100 { | ||
| 30 | + validation.SetError("describe", "备注最大长度100个字符") | ||
| 31 | + return | ||
| 32 | + } | ||
| 28 | } | 33 | } |
| @@ -6,11 +6,14 @@ import ( | @@ -6,11 +6,14 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type StateTemplateCommand struct { | 8 | type StateTemplateCommand struct { |
| 9 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
| 9 | Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` | 10 | Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` |
| 10 | State int `cname:"模板状态" json:"state"` | 11 | State int `cname:"模板状态" json:"state"` |
| 11 | } | 12 | } |
| 12 | 13 | ||
| 13 | type CopyTemplateCommand struct { | 14 | type CopyTemplateCommand struct { |
| 15 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
| 16 | + CreatorId int64 `cname:"创建人ID" json:"creatorId"` | ||
| 14 | Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` | 17 | Id int64 `cname:"模板ID" json:"id,string" valid:"Required"` |
| 15 | } | 18 | } |
| 16 | 19 |
| 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 | + "time" | ||
| 6 | +) | ||
| 4 | 7 | ||
| 5 | type QueryTemplateCommand struct { | 8 | type QueryTemplateCommand struct { |
| 6 | CompanyId int64 `cname:"公司ID" json:"companyId"` | 9 | CompanyId int64 `cname:"公司ID" json:"companyId"` |
| 7 | Name string `cname:"模板名称" json:"name"` | 10 | Name string `cname:"模板名称" json:"name"` |
| 11 | + State int `cname:"模板状态" json:"state"` | ||
| 12 | + CreatedAt *time.Time `cname:"创建时间" json:"createdAt"` | ||
| 8 | PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` | 13 | PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"` |
| 9 | PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 14 | PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` |
| 10 | } | 15 | } |
| @@ -16,14 +21,14 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | @@ -16,14 +21,14 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { | ||
| 16 | } | 21 | } |
| 17 | } | 22 | } |
| 18 | 23 | ||
| 19 | -// AllEnableTemplateCommand 查询所有已启用的模板 | ||
| 20 | -type AllEnableTemplateCommand struct { | ||
| 21 | - CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
| 22 | -} | ||
| 23 | - | ||
| 24 | -func (in *AllEnableTemplateCommand) Valid(validation *validation.Validation) { | ||
| 25 | - if in.CompanyId == 0 { | ||
| 26 | - validation.SetError("companyId", "公司ID无效") | ||
| 27 | - return | ||
| 28 | - } | ||
| 29 | -} | 24 | +//// AllEnableTemplateCommand 查询所有已启用的模板 |
| 25 | +//type AllEnableTemplateCommand struct { | ||
| 26 | +// CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
| 27 | +//} | ||
| 28 | +// | ||
| 29 | +//func (in *AllEnableTemplateCommand) Valid(validation *validation.Validation) { | ||
| 30 | +// if in.CompanyId == 0 { | ||
| 31 | +// validation.SetError("companyId", "公司ID无效") | ||
| 32 | +// return | ||
| 33 | +// } | ||
| 34 | +//} |
| @@ -9,7 +9,7 @@ type UpdateTemplateCommand struct { | @@ -9,7 +9,7 @@ type UpdateTemplateCommand 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 | Name string `cname:"模板名称" json:"name" valid:"Required"` | 11 | Name string `cname:"模板名称" json:"name" valid:"Required"` |
| 12 | - Describe string `cname:"模板描述" json:"remark"` | 12 | + Describe string `cname:"模板描述" json:"describe"` |
| 13 | LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` | 13 | LinkNodes []*domain.LinkNode `cname:"评估流程" json:"linkNodes"` |
| 14 | } | 14 | } |
| 15 | 15 | ||
| @@ -24,6 +24,11 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { | @@ -24,6 +24,11 @@ func (in *UpdateTemplateCommand) Valid(validation *validation.Validation) { | ||
| 24 | return | 24 | return |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | + if len(in.Describe) > 100 { | ||
| 28 | + validation.SetError("describe", "备注最大长度100个字符") | ||
| 29 | + return | ||
| 30 | + } | ||
| 31 | + | ||
| 27 | if len(in.LinkNodes) == 0 { | 32 | if len(in.LinkNodes) == 0 { |
| 28 | validation.SetError("linkNodes", "评估模板流程不能为空") | 33 | validation.SetError("linkNodes", "评估模板流程不能为空") |
| 29 | return | 34 | return |
| @@ -184,35 +184,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int | @@ -184,35 +184,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int | ||
| 184 | transactionContext.RollbackTransaction() | 184 | transactionContext.RollbackTransaction() |
| 185 | }() | 185 | }() |
| 186 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | 186 | templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 187 | - | ||
| 188 | - // FIXME 总数量是否使用Count获取一个总数量 | ||
| 189 | - count, templates, err := templateRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | 187 | + total, templates, err := templateRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") |
| 190 | if err != nil { | 188 | if err != nil { |
| 191 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 189 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 192 | } | 190 | } |
| 193 | - return tool_funs.SimpleWrapGridMap(count, templates), nil | ||
| 194 | -} | ||
| 195 | - | ||
| 196 | -func (rs *EvaluationTemplateService) ListForEnable(in *command.AllEnableTemplateCommand) (interface{}, error) { | ||
| 197 | - transactionContext, err := factory.StartTransaction() | ||
| 198 | - if err != nil { | ||
| 199 | - return nil, err | ||
| 200 | - } | ||
| 201 | - defer func() { | ||
| 202 | - transactionContext.RollbackTransaction() | ||
| 203 | - }() | ||
| 204 | - templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 205 | - | ||
| 206 | - count, templates, err := templateRepository.Find(map[string]interface{}{ | ||
| 207 | - "companyId": in.CompanyId, | ||
| 208 | - "state": domain.TemplateStateEnable, | ||
| 209 | - "offset": 0, | ||
| 210 | - "limit": 9999999, | ||
| 211 | - }, "linkNodes") | ||
| 212 | - if err != nil { | ||
| 213 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 191 | + if err := transactionContext.CommitTransaction(); err != nil { |
| 192 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 214 | } | 193 | } |
| 215 | - return tool_funs.SimpleWrapGridMap(count, templates), nil | 194 | + return tool_funs.SimpleWrapGridMap(total, templates), nil |
| 216 | } | 195 | } |
| 217 | 196 | ||
| 218 | func (rs *EvaluationTemplateService) State(in *command.StateTemplateCommand) (interface{}, error) { | 197 | func (rs *EvaluationTemplateService) State(in *command.StateTemplateCommand) (interface{}, error) { |
| @@ -257,10 +236,20 @@ func (rs *EvaluationTemplateService) Copy(in *command.CopyTemplateCommand) (inte | @@ -257,10 +236,20 @@ func (rs *EvaluationTemplateService) Copy(in *command.CopyTemplateCommand) (inte | ||
| 257 | } | 236 | } |
| 258 | // ID重置 | 237 | // ID重置 |
| 259 | template.Id = 0 | 238 | template.Id = 0 |
| 239 | + template.Name = template.Name + " 副本" | ||
| 240 | + template.CreatorId = in.CreatorId | ||
| 241 | + | ||
| 260 | // 如果拷贝已经启用的模板,默认先设置为待启用 | 242 | // 如果拷贝已经启用的模板,默认先设置为待启用 |
| 261 | if template.State == domain.TemplateStateEnable { | 243 | if template.State == domain.TemplateStateEnable { |
| 262 | template.State = domain.TemplateStateWaitActive | 244 | template.State = domain.TemplateStateWaitActive |
| 263 | } | 245 | } |
| 246 | + | ||
| 247 | + // 流程环节ID重置 | ||
| 248 | + sid, _ := utils.NewSnowflakeId() | ||
| 249 | + for i := range template.LinkNodes { | ||
| 250 | + template.LinkNodes[i].Id = sid + int64(i+1) | ||
| 251 | + } | ||
| 252 | + | ||
| 264 | template, err = templateRepository.Insert(template) | 253 | template, err = templateRepository.Insert(template) |
| 265 | if err != nil { | 254 | if err != nil { |
| 266 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 255 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -128,3 +128,27 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev | @@ -128,3 +128,27 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev | ||
| 128 | } | 128 | } |
| 129 | return repository.NewEvaluationProjectRepository(transactionContext) | 129 | return repository.NewEvaluationProjectRepository(transactionContext) |
| 130 | } | 130 | } |
| 131 | + | ||
| 132 | +func CreateStaffAssessRepository(options map[string]interface{}) domain.StaffAssessRepository { | ||
| 133 | + var transactionContext *pg.TransactionContext | ||
| 134 | + if value, ok := options["transactionContext"]; ok { | ||
| 135 | + transactionContext = value.(*pg.TransactionContext) | ||
| 136 | + } | ||
| 137 | + return repository.NewStaffAssessRepository(transactionContext) | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +func CreateStaffAssessContentRepository(options map[string]interface{}) domain.StaffAssessContentRepository { | ||
| 141 | + var transactionContext *pg.TransactionContext | ||
| 142 | + if value, ok := options["transactionContext"]; ok { | ||
| 143 | + transactionContext = value.(*pg.TransactionContext) | ||
| 144 | + } | ||
| 145 | + return repository.NewStaffAssessContentRepository(transactionContext) | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.StaffAssessTaskRepository { | ||
| 149 | + var transactionContext *pg.TransactionContext | ||
| 150 | + if value, ok := options["transactionContext"]; ok { | ||
| 151 | + transactionContext = value.(*pg.TransactionContext) | ||
| 152 | + } | ||
| 153 | + return repository.NewStaffAssessTaskRepository(transactionContext) | ||
| 154 | +} |
| @@ -6,7 +6,6 @@ import ( | @@ -6,7 +6,6 @@ import ( | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/adapter" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/adapter" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" |
| 9 | - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 10 | ) | 9 | ) |
| 11 | 10 | ||
| 12 | type RoleService struct { | 11 | type RoleService struct { |
| @@ -17,122 +16,122 @@ func NewRoleService() *RoleService { | @@ -17,122 +16,122 @@ func NewRoleService() *RoleService { | ||
| 17 | return newRoleService | 16 | return newRoleService |
| 18 | } | 17 | } |
| 19 | 18 | ||
| 20 | -// Create 创建 | ||
| 21 | -func (rs *RoleService) Create(in *command.CreateRoleCommand) (interface{}, error) { | ||
| 22 | - transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 23 | - if err != nil { | ||
| 24 | - return nil, err | ||
| 25 | - } | ||
| 26 | - defer func() { | ||
| 27 | - transactionContext.RollbackTransaction() | ||
| 28 | - }() | ||
| 29 | - roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 30 | - | ||
| 31 | - // 检测名称重复 | ||
| 32 | - count, err := roleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId}) | ||
| 33 | - if err != nil { | ||
| 34 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 35 | - } | ||
| 36 | - if count > 0 { | ||
| 37 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "角色名称已存在") | ||
| 38 | - } | ||
| 39 | - newRole := &domain.Role{ | ||
| 40 | - Id: 0, | ||
| 41 | - Name: in.Name, | ||
| 42 | - Type: domain.RoleTypeCommon, | ||
| 43 | - Description: in.Description, | ||
| 44 | - CompanyId: in.CompanyId, | ||
| 45 | - } | ||
| 46 | - role, err := roleRepository.Insert(newRole) | ||
| 47 | - if err != nil { | ||
| 48 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 49 | - } | ||
| 50 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
| 51 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 52 | - } | ||
| 53 | - return role, nil | ||
| 54 | - | ||
| 55 | -} | ||
| 56 | - | ||
| 57 | -func (rs *RoleService) Update(in *command.UpdateRoleCommand) (interface{}, error) { | ||
| 58 | - transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 59 | - if err != nil { | ||
| 60 | - return nil, err | ||
| 61 | - } | ||
| 62 | - defer func() { | ||
| 63 | - transactionContext.RollbackTransaction() | ||
| 64 | - }() | ||
| 65 | - | ||
| 66 | - roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 67 | - | ||
| 68 | - // 检测名称重复(排除自己) | ||
| 69 | - count, err := roleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId, "notId": in.Id}) | ||
| 70 | - if err != nil { | ||
| 71 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 72 | - } | ||
| 73 | - if count > 0 { | ||
| 74 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "角色名称已存在") | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
| 78 | - if err != nil { | ||
| 79 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - role.Name = in.Name | ||
| 83 | - role.Name = in.Description | ||
| 84 | - | ||
| 85 | - role, err = roleRepository.Insert(role) | ||
| 86 | - if err != nil { | ||
| 87 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 88 | - } | ||
| 89 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
| 90 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 91 | - } | ||
| 92 | - return role, nil | ||
| 93 | -} | ||
| 94 | - | ||
| 95 | -func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error) { | ||
| 96 | - transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 97 | - if err != nil { | ||
| 98 | - return nil, err | ||
| 99 | - } | ||
| 100 | - defer func() { | ||
| 101 | - transactionContext.RollbackTransaction() | ||
| 102 | - }() | ||
| 103 | - | ||
| 104 | - roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 105 | - roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 106 | - | ||
| 107 | - role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
| 108 | - if err != nil { | ||
| 109 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 110 | - } | ||
| 111 | - if _, err := roleRepository.Remove(role); err != nil { | ||
| 112 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - // 获取角色所有关联的用户,并删除 | ||
| 116 | - _, roleUsers, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.Id, "companyId": in.CompanyId}) | ||
| 117 | - if err != nil { | ||
| 118 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 119 | - } | ||
| 120 | - ids := make([]int64, 0) | ||
| 121 | - for i := range roleUsers { | ||
| 122 | - ids = append(ids, roleUsers[i].Id) | ||
| 123 | - } | ||
| 124 | - if len(ids) > 0 { | ||
| 125 | - err := roleUserRepository.BatchDeleteById(ids) | ||
| 126 | - if err != nil { | ||
| 127 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 128 | - } | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
| 132 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 133 | - } | ||
| 134 | - return role, nil | ||
| 135 | -} | 19 | +//// Create 创建 |
| 20 | +//func (rs *RoleService) Create(in *command.CreateRoleCommand) (interface{}, error) { | ||
| 21 | +// transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 22 | +// if err != nil { | ||
| 23 | +// return nil, err | ||
| 24 | +// } | ||
| 25 | +// defer func() { | ||
| 26 | +// transactionContext.RollbackTransaction() | ||
| 27 | +// }() | ||
| 28 | +// roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 29 | +// | ||
| 30 | +// // 检测名称重复 | ||
| 31 | +// count, err := roleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId}) | ||
| 32 | +// if err != nil { | ||
| 33 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 34 | +// } | ||
| 35 | +// if count > 0 { | ||
| 36 | +// return nil, application.ThrowError(application.BUSINESS_ERROR, "角色名称已存在") | ||
| 37 | +// } | ||
| 38 | +// newRole := &domain.Role{ | ||
| 39 | +// Id: 0, | ||
| 40 | +// Name: in.Name, | ||
| 41 | +// Type: domain.RoleTypeCommon, | ||
| 42 | +// Description: in.Description, | ||
| 43 | +// CompanyId: in.CompanyId, | ||
| 44 | +// } | ||
| 45 | +// role, err := roleRepository.Insert(newRole) | ||
| 46 | +// if err != nil { | ||
| 47 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 48 | +// } | ||
| 49 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 50 | +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 51 | +// } | ||
| 52 | +// return role, nil | ||
| 53 | +// | ||
| 54 | +//} | ||
| 55 | +// | ||
| 56 | +//func (rs *RoleService) Update(in *command.UpdateRoleCommand) (interface{}, error) { | ||
| 57 | +// transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 58 | +// if err != nil { | ||
| 59 | +// return nil, err | ||
| 60 | +// } | ||
| 61 | +// defer func() { | ||
| 62 | +// transactionContext.RollbackTransaction() | ||
| 63 | +// }() | ||
| 64 | +// | ||
| 65 | +// roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 66 | +// | ||
| 67 | +// // 检测名称重复(排除自己) | ||
| 68 | +// count, err := roleRepository.Count(map[string]interface{}{"name": in.Name, "companyId": in.CompanyId, "notId": in.Id}) | ||
| 69 | +// if err != nil { | ||
| 70 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 71 | +// } | ||
| 72 | +// if count > 0 { | ||
| 73 | +// return nil, application.ThrowError(application.BUSINESS_ERROR, "角色名称已存在") | ||
| 74 | +// } | ||
| 75 | +// | ||
| 76 | +// role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
| 77 | +// if err != nil { | ||
| 78 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 79 | +// } | ||
| 80 | +// | ||
| 81 | +// role.Name = in.Name | ||
| 82 | +// role.Description = in.Description | ||
| 83 | +// | ||
| 84 | +// role, err = roleRepository.Insert(role) | ||
| 85 | +// if err != nil { | ||
| 86 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 87 | +// } | ||
| 88 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 89 | +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 90 | +// } | ||
| 91 | +// return role, nil | ||
| 92 | +//} | ||
| 93 | +// | ||
| 94 | +//func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error) { | ||
| 95 | +// transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 96 | +// if err != nil { | ||
| 97 | +// return nil, err | ||
| 98 | +// } | ||
| 99 | +// defer func() { | ||
| 100 | +// transactionContext.RollbackTransaction() | ||
| 101 | +// }() | ||
| 102 | +// | ||
| 103 | +// roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 104 | +// roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 105 | +// | ||
| 106 | +// role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id}) | ||
| 107 | +// if err != nil { | ||
| 108 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 109 | +// } | ||
| 110 | +// if _, err := roleRepository.Remove(role); err != nil { | ||
| 111 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 112 | +// } | ||
| 113 | +// | ||
| 114 | +// // 获取角色所有关联的用户,并删除 | ||
| 115 | +// _, roleUsers, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.Id, "companyId": in.CompanyId}) | ||
| 116 | +// if err != nil { | ||
| 117 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 118 | +// } | ||
| 119 | +// ids := make([]int64, 0) | ||
| 120 | +// for i := range roleUsers { | ||
| 121 | +// ids = append(ids, roleUsers[i].Id) | ||
| 122 | +// } | ||
| 123 | +// if len(ids) > 0 { | ||
| 124 | +// err := roleUserRepository.BatchDeleteById(ids) | ||
| 125 | +// if err != nil { | ||
| 126 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 127 | +// } | ||
| 128 | +// } | ||
| 129 | +// | ||
| 130 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 131 | +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 132 | +// } | ||
| 133 | +// return role, nil | ||
| 134 | +//} | ||
| 136 | 135 | ||
| 137 | func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { | 136 | func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { |
| 138 | transactionContext, err := factory.StartTransaction() | 137 | transactionContext, err := factory.StartTransaction() |
| @@ -171,6 +170,5 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | @@ -171,6 +170,5 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ | ||
| 171 | roleUser.Users = tempList | 170 | roleUser.Users = tempList |
| 172 | adapterList = append(adapterList, roleUser) | 171 | adapterList = append(adapterList, roleUser) |
| 173 | } | 172 | } |
| 174 | - | ||
| 175 | - return map[string]interface{}{"list": adapterList}, nil | 173 | + return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil |
| 176 | } | 174 | } |
| @@ -2,6 +2,7 @@ package service | @@ -2,6 +2,7 @@ package service | ||
| 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 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role/command" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| @@ -88,47 +89,25 @@ func (rs *RoleUserService) Remove(in *command.UserRoleDeleteCommand) (interface{ | @@ -88,47 +89,25 @@ func (rs *RoleUserService) Remove(in *command.UserRoleDeleteCommand) (interface{ | ||
| 88 | return rus, nil | 89 | return rus, nil |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 91 | -//func (rs *RoleUserService) ListForUser(in *command.UserRoleQueryCommand) (interface{}, error) { | ||
| 92 | -// transactionContext, err := factory.StartTransaction() | ||
| 93 | -// if err != nil { | ||
| 94 | -// return nil, err | ||
| 95 | -// } | ||
| 96 | -// defer func() { | ||
| 97 | -// transactionContext.RollbackTransaction() | ||
| 98 | -// }() | ||
| 99 | -// roleRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 100 | -// userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 101 | -// | ||
| 102 | -// in.PageNumber = 1 | ||
| 103 | -// in.PageSize = 9999999 | ||
| 104 | -// | ||
| 105 | -// conditionMap := tool_funs.SimpleStructToMap(in) | ||
| 106 | -// _, roles, err := roleRepository.Find(conditionMap) | ||
| 107 | -// if err != nil { | ||
| 108 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 109 | -// } | ||
| 110 | -// if len(roles) == 0 { | ||
| 111 | -// return nil, application.ThrowError(application.BUSINESS_ERROR, "未找到角色数据") | ||
| 112 | -// } | ||
| 113 | -// | ||
| 114 | -// ids := make([]int64, 0) | ||
| 115 | -// for i := range roles { | ||
| 116 | -// ids = append(ids, roles[i].Id) | ||
| 117 | -// } | ||
| 118 | -// | ||
| 119 | -// _, users, err := userRepository.Find(conditionMap) | ||
| 120 | -// if err != nil { | ||
| 121 | -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 122 | -// } | ||
| 123 | -// | ||
| 124 | -// //for i := range users { | ||
| 125 | -// // users[i].RoleUserIds | ||
| 126 | -// //} | ||
| 127 | -// | ||
| 128 | -// //if err := transactionContext.CommitTransaction(); err != nil { | ||
| 129 | -// // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 130 | -// //} | ||
| 131 | -// //groupAdapter := &adapter.RoleUserAdapter{} | ||
| 132 | -// //newList := groupAdapter.TransformTree(groups) | ||
| 133 | -// return map[string]interface{}{"list": users}, nil | ||
| 134 | -//} | 92 | +func (rs *RoleUserService) ListRole(in *command.UserRoleQueryCommand) (interface{}, error) { |
| 93 | + transactionContext, err := factory.StartTransaction() | ||
| 94 | + if err != nil { | ||
| 95 | + return nil, err | ||
| 96 | + } | ||
| 97 | + defer func() { | ||
| 98 | + transactionContext.RollbackTransaction() | ||
| 99 | + }() | ||
| 100 | + ruRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 101 | + | ||
| 102 | + in.PageNumber = 1 | ||
| 103 | + in.PageSize = 9999999 | ||
| 104 | + | ||
| 105 | + tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, in.RoleId) | ||
| 106 | + if err != nil { | ||
| 107 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 108 | + } | ||
| 109 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 110 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 111 | + } | ||
| 112 | + return tool_funs.SimpleWrapGridMap(int64(len(tempList)), tempList), nil | ||
| 113 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 4 | + | ||
| 5 | +//评估内容详情 | ||
| 6 | +type AssessInfoResp struct { | ||
| 7 | + CycleId int64 `json:"cycleId"` //周期id | ||
| 8 | + CycleName string `json:"cycleName"` //周期名称 | ||
| 9 | + EvaluationProjectId int `json:"evaluationProjectId"` //项目id | ||
| 10 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
| 11 | + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
| 12 | + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 | ||
| 13 | + Status string `json:"status"` //完成状态 | ||
| 14 | + TargetUserId int `json:"targetUser"` // | ||
| 15 | + TargetUserName string `json:"targetUserName"` // | ||
| 16 | + AssessContent []AssessContent `json:"assessContent"` //评估内容 | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +type AssessContent struct { | ||
| 20 | + Category string `json:"category" comment:"类别"` | ||
| 21 | + Name string `json:"name" comment:"名称"` | ||
| 22 | + PromptTitle string `json:"promptTitle" comment:"提示项标题"` | ||
| 23 | + PromptText string `json:"promptText" comment:"提示项正文"` | ||
| 24 | + EntryItems []*domain.EntryItem `json:"entryItems" comment:"填写项"` | ||
| 25 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 4 | + | ||
| 5 | +type AssessInviteUserResp struct { | ||
| 6 | + LinkNodeId int `json:"linkNodeId"` | ||
| 7 | + LinkNodeName string `json:"linkNodeName"` | ||
| 8 | + BeginTime string `json:"beginTime"` | ||
| 9 | + EndTime string `json:"endTime"` | ||
| 10 | + AssessTaskId int `json:"assessTaskId"` | ||
| 11 | + InviteSameSuper []domain.StaffDesc `json:"inviteSameSuper"` | ||
| 12 | + InviteDiffSuper []domain.StaffDesc `json:"inviteDiffSuper"` | ||
| 13 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +type AssessSelfList struct { | ||
| 4 | + AssessId int `json:"assessId"` //用户执行的评估项id | ||
| 5 | + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 | ||
| 6 | + EndTime string `json:"endTime"` //开始时间 2006-01-02 15:04:05 | ||
| 7 | + CycleId int64 `json:"cycleId"` //周期id | ||
| 8 | + CycleName string `json:"cycleName"` //周期名称 | ||
| 9 | + EvaluationProjectId int `json:"evaluationProjectId"` //项目id | ||
| 10 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +type StaffInfo struct { | ||
| 14 | + UserName string `json:"userName"` //员工名称 | ||
| 15 | + CompanyName string `json:"companyName"` //公司名称 | ||
| 16 | + SupperUserName string `json:"supperUserName"` //上级名称 | ||
| 17 | + DutyTime string `json:"dutyTime"` //上岗时间 | ||
| 18 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 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"` // 考评流程 | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +type AssessTaskStep struct { | ||
| 14 | + SortBy int `json:"sortBy"` //排序 | ||
| 15 | + LinkNodeName string `json:"linkNodeName"` //流程名称 | ||
| 16 | + BeginTime string `json:"beginTime"` //开始时间时间 | ||
| 17 | + EndTime string `json:"endTime"` //结束时间 | ||
| 18 | + LinkNodeType int `json:"linkNodeType"` //流程类型 | ||
| 19 | + Desc string `json:"desc"` //情况描述 | ||
| 20 | + Status string `json:"status"` //流程是否完成 "":未参加,"uncompleted":未完成,"completed":完成 | ||
| 21 | +} |
| 1 | +package adapter | ||
| 2 | + | ||
| 3 | +type SearchAssessMeResp struct { | ||
| 4 | + AssessTaskId int `json:"assessTaskId"` | ||
| 5 | + BeginTime string `json:"beginTime"` | ||
| 6 | + EndTime string `json:"endTime"` | ||
| 7 | + CycleId int64 `json:"cycleId"` | ||
| 8 | + CycleName string `json:"cycleName"` | ||
| 9 | + EvaluationProjectId int `json:"evaluationProjectId"` | ||
| 10 | + EvaluationProjectName string `json:"evaluationProjectName"` | ||
| 11 | +} |
| 1 | +package command | ||
| 2 | + | ||
| 3 | +type CreateStaffAssessTask struct { | ||
| 4 | + CompanyId int `json:"companyId"` //公司id | ||
| 5 | + EvaluationProjectId int `json:"evaluationProjectId"` //项目id | ||
| 6 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
| 7 | + CycleId int64 `json:"cycleId"` //对应的周期id | ||
| 8 | + CycleName string `json:"cycleName"` //对应周期的名称 | ||
| 9 | + BeginTime string `json:"beginTime"` //绩效考核开始时间 | ||
| 10 | + EndTime string `json:"endTime"` //绩效考核截止时间 | ||
| 11 | + StepList []AssessTaskStep `json:"steps"` //考评的流程 | ||
| 12 | + ExecutorId []int `json:"executorId"` //参与此次考评的人 | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +type AssessTaskStep struct { | ||
| 16 | + SortBy int `json:"sortBy"` //排序 | ||
| 17 | + LinkNodeId int `json:"linkNodeId"` //考评的流程id | ||
| 18 | + LinkNodeName string `json:"linkNodeName"` //流程名称 | ||
| 19 | + LinkNodeType int `json:"linkNodeType"` //流程类型 同evaluation_template.go->LinkNode.Type | ||
| 20 | + BeginTime string `json:"beginTime"` //绩效考核开始时间 | ||
| 21 | + EndTime string `json:"endTime"` //绩效考核截止时间 | ||
| 22 | +} |
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "strconv" | ||
| 6 | + "time" | ||
| 7 | + | ||
| 8 | + "github.com/linmadan/egglib-go/core/application" | ||
| 9 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | ||
| 13 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | ||
| 14 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 15 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
| 16 | +) | ||
| 17 | + | ||
| 18 | +// 员工评绩效评估 | ||
| 19 | +type StaffAssessServeice struct { | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewStaffAssessServeice() *StaffAssessServeice { | ||
| 23 | + newService := &StaffAssessServeice{} | ||
| 24 | + return newService | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +// 获取我参与过的评估任务列表 | ||
| 28 | +func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) { | ||
| 29 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 30 | + if err != nil { | ||
| 31 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 32 | + } | ||
| 33 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 34 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 35 | + } | ||
| 36 | + defer func() { | ||
| 37 | + _ = transactionContext.RollbackTransaction() | ||
| 38 | + }() | ||
| 39 | + staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
| 40 | + "transactionContext": transactionContext, | ||
| 41 | + }) | ||
| 42 | + var limit int = 20 | ||
| 43 | + var offset int = 0 | ||
| 44 | + if param.PageSize > 0 { | ||
| 45 | + limit = param.PageSize | ||
| 46 | + } | ||
| 47 | + offset = (param.PageNumber - 1) * param.PageSize | ||
| 48 | + condition := map[string]interface{}{ | ||
| 49 | + "executorId": param.UserId, | ||
| 50 | + "companyId": param.CompanyId, | ||
| 51 | + "limit": limit, | ||
| 52 | + } | ||
| 53 | + if offset > 0 { | ||
| 54 | + condition["offset"] = offset | ||
| 55 | + } | ||
| 56 | + cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition) | ||
| 57 | + if err != nil { | ||
| 58 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error()) | ||
| 59 | + } | ||
| 60 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 61 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 62 | + } | ||
| 63 | + listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList)) | ||
| 64 | + var temp adapter.SearchAssessMeResp | ||
| 65 | + for _, v := range assessTaskList { | ||
| 66 | + temp = adapter.SearchAssessMeResp{ | ||
| 67 | + AssessTaskId: v.Id, | ||
| 68 | + BeginTime: v.BeginTime.Format("2006-01-02 15:04:05"), | ||
| 69 | + EndTime: v.EndTime.Format("2006-01-02 15:04:05"), | ||
| 70 | + CycleId: v.CycleId, | ||
| 71 | + CycleName: v.CycleName, | ||
| 72 | + EvaluationProjectId: v.EvaluationProjectId, | ||
| 73 | + EvaluationProjectName: v.EvaluationProjectName, | ||
| 74 | + } | ||
| 75 | + listData = append(listData, temp) | ||
| 76 | + } | ||
| 77 | + return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +// 获取项目评估进度描述 | ||
| 81 | +func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, error) { | ||
| 82 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 83 | + if err != nil { | ||
| 84 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 85 | + } | ||
| 86 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 87 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 88 | + } | ||
| 89 | + defer func() { | ||
| 90 | + _ = transactionContext.RollbackTransaction() | ||
| 91 | + }() | ||
| 92 | + // 获取评估任务 | ||
| 93 | + staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
| 94 | + "transactionContext": transactionContext, | ||
| 95 | + }) | ||
| 96 | + //获取个人参与的评估流程 | ||
| 97 | + staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 98 | + "transactionContext": transactionContext, | ||
| 99 | + }) | ||
| 100 | + assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{ | ||
| 101 | + "id": param.AssessTaskId, | ||
| 102 | + }) | ||
| 103 | + if err != nil { | ||
| 104 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error()) | ||
| 105 | + } | ||
| 106 | + //返回的数据结果 | ||
| 107 | + result := adapter.AssessTaskDescResp{ | ||
| 108 | + AssessTaskId: assessTaskData.Id, | ||
| 109 | + EvaluationProjectId: assessTaskData.EvaluationProjectId, | ||
| 110 | + EvaluationProjectName: assessTaskData.EvaluationProjectName, | ||
| 111 | + CycleName: assessTaskData.CycleName, | ||
| 112 | + BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"), | ||
| 113 | + EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"), | ||
| 114 | + StepList: []adapter.AssessTaskStep{}, | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + for _, v := range assessTaskData.StepList { | ||
| 118 | + stepItem := adapter.AssessTaskStep{ | ||
| 119 | + SortBy: v.SortBy, | ||
| 120 | + LinkNodeName: v.LinkNodeName, | ||
| 121 | + BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"), | ||
| 122 | + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
| 123 | + LinkNodeType: v.LinkNodeType, | ||
| 124 | + Desc: fmt.Sprintf("截止日期:%s", v.EndTime.Local().Format("2006-01-02 15:04:05")), | ||
| 125 | + Status: "", | ||
| 126 | + } | ||
| 127 | + switch v.LinkNodeType { | ||
| 128 | + case domain.LinkNodeSelfAssessment: | ||
| 129 | + //个人自评完成情况 | ||
| 130 | + _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{ | ||
| 131 | + "staffAssessTaskId": assessTaskData.Id, | ||
| 132 | + "executorId": param.UserId, | ||
| 133 | + "typesList": []string{string(domain.AssessSelf)}, | ||
| 134 | + }) | ||
| 135 | + if err != nil { | ||
| 136 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 137 | + } | ||
| 138 | + if len(assessSelfData) > 0 { | ||
| 139 | + stepItem.Status = string(assessSelfData[0].Status) | ||
| 140 | + } | ||
| 141 | + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | ||
| 142 | + case domain.LinkNodeAllInvite: | ||
| 143 | + //邀请别人评估自己 | ||
| 144 | + _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{ | ||
| 145 | + "staffAssessTaskId": assessTaskData.Id, | ||
| 146 | + "targetUserId": param.UserId, | ||
| 147 | + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
| 148 | + "limit": 5, | ||
| 149 | + }) | ||
| 150 | + if err != nil { | ||
| 151 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 152 | + } | ||
| 153 | + //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可 | ||
| 154 | + if len(assessInviteData) > 5 { | ||
| 155 | + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | ||
| 156 | + stepItem.Status = string(domain.StaffAssessCompleted) | ||
| 157 | + } else { | ||
| 158 | + stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData)) | ||
| 159 | + stepItem.Status = string(domain.StaffAssessUncompleted) | ||
| 160 | + } | ||
| 161 | + case domain.LinkNodeAllAssessment: | ||
| 162 | + //我评估别人,被邀请评估 | ||
| 163 | + _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{ | ||
| 164 | + "staffAssessTaskId": assessTaskData.Id, | ||
| 165 | + "executorId": param.UserId, | ||
| 166 | + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
| 167 | + }) | ||
| 168 | + if err != nil { | ||
| 169 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + if len(assessInviteList) > 0 { | ||
| 173 | + stepItem.Status = string(domain.StaffAssessCompleted) | ||
| 174 | + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | ||
| 175 | + for _, v := range assessInviteList { | ||
| 176 | + if v.Status == domain.StaffAssessUncompleted { | ||
| 177 | + stepItem.Status = string(domain.StaffAssessUncompleted) | ||
| 178 | + break | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + case domain.LinkNodeSuperiorAssessment: | ||
| 183 | + //我评估别人,上级评估 | ||
| 184 | + _, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{ | ||
| 185 | + "staffAssessTaskId": assessTaskData.Id, | ||
| 186 | + "executorId": param.UserId, | ||
| 187 | + "typesList": []string{string(domain.AssessSuper)}, | ||
| 188 | + }) | ||
| 189 | + if err != nil { | ||
| 190 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) | ||
| 191 | + } | ||
| 192 | + if len(assessSupperList) > 0 { | ||
| 193 | + stepItem.Status = string(domain.StaffAssessCompleted) | ||
| 194 | + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) | ||
| 195 | + uncompletedNum := 0 | ||
| 196 | + for _, v := range assessSupperList { | ||
| 197 | + if v.Status == domain.StaffAssessUncompleted { | ||
| 198 | + uncompletedNum += 1 | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + if uncompletedNum > 0 { | ||
| 202 | + stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum) | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | + result.StepList = append(result.StepList, stepItem) | ||
| 207 | + } | ||
| 208 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 209 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 210 | + } | ||
| 211 | + return &result, nil | ||
| 212 | +} | ||
| 213 | + | ||
| 214 | +// 获取个人的自评反馈历史记录列表 | ||
| 215 | +func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) (map[string]interface{}, error) { | ||
| 216 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 217 | + if err != nil { | ||
| 218 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 219 | + } | ||
| 220 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 221 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 222 | + } | ||
| 223 | + defer func() { | ||
| 224 | + _ = transactionContext.RollbackTransaction() | ||
| 225 | + }() | ||
| 226 | + //获取个人参与的评估流程 | ||
| 227 | + staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 228 | + "transactionContext": transactionContext, | ||
| 229 | + }) | ||
| 230 | + var limit int = 20 | ||
| 231 | + var offset int = 0 | ||
| 232 | + if param.PageSize > 0 { | ||
| 233 | + limit = param.PageSize | ||
| 234 | + } | ||
| 235 | + offset = (param.PageNumber - 1) * param.PageSize | ||
| 236 | + condition := map[string]interface{}{ | ||
| 237 | + "executorId": param.UserId, | ||
| 238 | + "companyId": param.CompanyId, | ||
| 239 | + "typesList": []string{string(domain.AssessSelf)}, | ||
| 240 | + "limit": limit, | ||
| 241 | + "status": string(domain.StaffAssessCompleted), | ||
| 242 | + } | ||
| 243 | + if offset > 0 { | ||
| 244 | + condition["offset"] = offset | ||
| 245 | + } | ||
| 246 | + //获取历史列表 | ||
| 247 | + cnt, assessList, err := staffAssessRepo.Find(condition) | ||
| 248 | + if err != nil { | ||
| 249 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务列表,"+err.Error()) | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + //获取公司数据 | ||
| 253 | + companyRep := factory.CreateCompanyRepository(map[string]interface{}{ | ||
| 254 | + "transactionContext": transactionContext, | ||
| 255 | + }) | ||
| 256 | + | ||
| 257 | + companyData, err := companyRep.FindOne(map[string]interface{}{ | ||
| 258 | + "id": param.CompanyId, | ||
| 259 | + }) | ||
| 260 | + if err != nil { | ||
| 261 | + log.Logger.Error("获取公司信息," + err.Error()) | ||
| 262 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error()) | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + //获取用户数据 | ||
| 266 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 267 | + "transactionContext": transactionContext, | ||
| 268 | + }) | ||
| 269 | + userData, err := userRepo.FindOne(map[string]interface{}{ | ||
| 270 | + "id": param.UserId, | ||
| 271 | + }) | ||
| 272 | + if err != nil { | ||
| 273 | + log.Logger.Error("获取用户信息," + err.Error()) | ||
| 274 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error()) | ||
| 275 | + } | ||
| 276 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
| 277 | + "transactionContext": transactionContext, | ||
| 278 | + }) | ||
| 279 | + var supperUserList []*domain.User | ||
| 280 | + if len(userData.DepartmentId) > 0 { | ||
| 281 | + _, departmentList, err := departmentRepo.Find(map[string]interface{}{ | ||
| 282 | + "ids": userData.DepartmentId, | ||
| 283 | + }) | ||
| 284 | + if err != nil { | ||
| 285 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取部门信息,"+err.Error()) | ||
| 286 | + } | ||
| 287 | + var chargeUserIds []int64 | ||
| 288 | + for _, v := range departmentList { | ||
| 289 | + chargeUserIds = append(chargeUserIds, v.ChargeUserIds...) | ||
| 290 | + } | ||
| 291 | + if len(chargeUserIds) > 0 { | ||
| 292 | + _, supperUserList, err = userRepo.Find(map[string]interface{}{ | ||
| 293 | + "ids": chargeUserIds, | ||
| 294 | + }) | ||
| 295 | + if err != nil { | ||
| 296 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取员工上级信息,"+err.Error()) | ||
| 297 | + } | ||
| 298 | + } | ||
| 299 | + } | ||
| 300 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 301 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 302 | + } | ||
| 303 | + listData := make([]adapter.AssessSelfList, 0, len(assessList)) | ||
| 304 | + var itemTemp adapter.AssessSelfList | ||
| 305 | + for _, v := range assessList { | ||
| 306 | + itemTemp = adapter.AssessSelfList{ | ||
| 307 | + AssessId: v.Id, | ||
| 308 | + BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"), | ||
| 309 | + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
| 310 | + CycleId: v.CycleId, | ||
| 311 | + CycleName: v.CycleName, | ||
| 312 | + EvaluationProjectId: v.EvaluationProjectId, | ||
| 313 | + EvaluationProjectName: v.EvaluationProjectName, | ||
| 314 | + } | ||
| 315 | + listData = append(listData, itemTemp) | ||
| 316 | + } | ||
| 317 | + userInfo := adapter.StaffInfo{ | ||
| 318 | + UserName: userData.Name, | ||
| 319 | + CompanyName: companyData.Name, | ||
| 320 | + SupperUserName: "", | ||
| 321 | + DutyTime: userData.CreatedAt.Local().Format("2006-01-02 15:04:05"), | ||
| 322 | + } | ||
| 323 | + for _, v := range supperUserList { | ||
| 324 | + userInfo.SupperUserName = userInfo.SupperUserName + v.Name + ";" | ||
| 325 | + } | ||
| 326 | + result := tool_funs.SimpleWrapGridMap(int64(cnt), listData) | ||
| 327 | + result["userInfo"] = userInfo | ||
| 328 | + return result, nil | ||
| 329 | +} | ||
| 330 | + | ||
| 331 | +// 更具项目评估的配置,创建员工的评估任务 | ||
| 332 | +func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffAssessTask) (map[string]interface{}, error) { | ||
| 333 | + | ||
| 334 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 335 | + if err != nil { | ||
| 336 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 337 | + } | ||
| 338 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 339 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 340 | + } | ||
| 341 | + defer func() { | ||
| 342 | + _ = transactionContext.RollbackTransaction() | ||
| 343 | + }() | ||
| 344 | + | ||
| 345 | + taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) | ||
| 346 | + if err != nil { | ||
| 347 | + return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime) | ||
| 348 | + } | ||
| 349 | + taskEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local) | ||
| 350 | + if err != nil { | ||
| 351 | + return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime) | ||
| 352 | + } | ||
| 353 | + nowTime := time.Now() | ||
| 354 | + //建立评估任务 | ||
| 355 | + assessTask := domain.StaffAssessTask{ | ||
| 356 | + Id: 0, | ||
| 357 | + CompanyId: param.CompanyId, | ||
| 358 | + EvaluationProjectId: param.EvaluationProjectId, | ||
| 359 | + EvaluationProjectName: param.EvaluationProjectName, | ||
| 360 | + CycleId: param.CycleId, | ||
| 361 | + CycleName: param.CycleName, | ||
| 362 | + BeginTime: taskBeginTime, | ||
| 363 | + EndTime: taskEndTime, | ||
| 364 | + StepList: []domain.AssessTaskStep{}, | ||
| 365 | + ExecutorId: nil, | ||
| 366 | + CreatedAt: nowTime, | ||
| 367 | + UpdatedAt: nowTime, | ||
| 368 | + DeletedAt: nil, | ||
| 369 | + } | ||
| 370 | + //填充评估环节 | ||
| 371 | + for _, v := range param.StepList { | ||
| 372 | + stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) | ||
| 373 | + if err != nil { | ||
| 374 | + return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime) | ||
| 375 | + } | ||
| 376 | + stepEndTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.EndTime, time.Local) | ||
| 377 | + if err != nil { | ||
| 378 | + return nil, application.ThrowError(application.ARG_ERROR, "评估环节结束时间填写错误,"+param.EndTime) | ||
| 379 | + } | ||
| 380 | + step := domain.AssessTaskStep{ | ||
| 381 | + SortBy: v.SortBy, | ||
| 382 | + LinkNodeId: v.LinkNodeId, | ||
| 383 | + LinkNodeName: v.LinkNodeName, | ||
| 384 | + LinkNodeType: v.LinkNodeType, | ||
| 385 | + BeginTime: stepBeginTime, | ||
| 386 | + EndTime: stepEndTime, | ||
| 387 | + } | ||
| 388 | + assessTask.StepList = append(assessTask.StepList, step) | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
| 392 | + "transactionContext": transactionContext, | ||
| 393 | + }) | ||
| 394 | + _, err = assessTaskRepo.Save(&assessTask) | ||
| 395 | + if err != nil { | ||
| 396 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | ||
| 397 | + } | ||
| 398 | + | ||
| 399 | + assessList, err := srv.createStaffAssess(transactionContext, &assessTask) | ||
| 400 | + if err != nil { | ||
| 401 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) | ||
| 402 | + } | ||
| 403 | + | ||
| 404 | + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 405 | + "transactionContext": transactionContext, | ||
| 406 | + }) | ||
| 407 | + | ||
| 408 | + for i := range assessList { | ||
| 409 | + _, err = assessRepo.Save(&assessList[i]) | ||
| 410 | + if err != nil { | ||
| 411 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) | ||
| 412 | + } | ||
| 413 | + } | ||
| 414 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 415 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 416 | + } | ||
| 417 | + return map[string]interface{}{ | ||
| 418 | + "assessTaskId": assessTask.Id, | ||
| 419 | + }, nil | ||
| 420 | +} | ||
| 421 | + | ||
| 422 | +// 添加自评节点任务 | ||
| 423 | +func (srv StaffAssessServeice) createStaffAssess(transactionContext application.TransactionContext, param *domain.StaffAssessTask) ([]domain.StaffAssess, error) { | ||
| 424 | + //评估的参与人 | ||
| 425 | + selfUserId := []int{} | ||
| 426 | + userIdMap := map[int]struct{}{} //过滤重复的用户 | ||
| 427 | + for _, v := range param.ExecutorId { | ||
| 428 | + if _, ok := userIdMap[v]; ok { | ||
| 429 | + continue | ||
| 430 | + } | ||
| 431 | + selfUserId = append(selfUserId, v) | ||
| 432 | + } | ||
| 433 | + // 获取用户的信息 | ||
| 434 | + if len(selfUserId) == 0 { | ||
| 435 | + return nil, application.ThrowError(application.ARG_ERROR, "未填写评估任务的执行人") | ||
| 436 | + } | ||
| 437 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 438 | + "transactionContext": transactionContext, | ||
| 439 | + }) | ||
| 440 | + //获取员工信息 | ||
| 441 | + _, userList, err := userRepo.Find(map[string]interface{}{ | ||
| 442 | + "ids": selfUserId, | ||
| 443 | + }) | ||
| 444 | + if err != nil { | ||
| 445 | + return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error()) | ||
| 446 | + } | ||
| 447 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
| 448 | + "transactionContext": transactionContext, | ||
| 449 | + }) | ||
| 450 | + //获取用户的部门 | ||
| 451 | + userDepartmentMap := map[int64][]*domain.Department{} | ||
| 452 | + for _, v := range userList { | ||
| 453 | + _, departmemtList, err := departmentRepo.Find(map[string]interface{}{ | ||
| 454 | + "ids": v.DepartmentId, | ||
| 455 | + }) | ||
| 456 | + if err != nil { | ||
| 457 | + return nil, application.ThrowError(application.ARG_ERROR, "获取员工的部门信息"+err.Error()) | ||
| 458 | + } | ||
| 459 | + userDepartmentMap[v.Id] = departmemtList | ||
| 460 | + } | ||
| 461 | + assessList := []domain.StaffAssess{} | ||
| 462 | + //数据样板 | ||
| 463 | + stepSelfTemp := domain.StaffAssess{ | ||
| 464 | + Id: 0, | ||
| 465 | + CompanyId: param.CompanyId, | ||
| 466 | + EvaluationProjectId: param.EvaluationProjectId, | ||
| 467 | + EvaluationProjectName: param.EvaluationProjectName, | ||
| 468 | + CycleId: param.CycleId, | ||
| 469 | + CycleName: param.CycleName, | ||
| 470 | + StaffAssessTaskId: param.Id, | ||
| 471 | + // TargetUser: domain.StaffDesc{}, | ||
| 472 | + // TargetDepartment: nil, | ||
| 473 | + // Executor: domain.StaffDesc{}, | ||
| 474 | + Types: domain.AssessSelf, | ||
| 475 | + // LinkNodeId: v.LinkNodeId, | ||
| 476 | + Status: domain.StaffAssessUncompleted, | ||
| 477 | + // BeginTime: time.Time{}, | ||
| 478 | + // EndTime: time.Time{}, | ||
| 479 | + CreatedAt: param.CreatedAt, | ||
| 480 | + UpdatedAt: param.UpdatedAt, | ||
| 481 | + DeletedAt: nil, | ||
| 482 | + } | ||
| 483 | + for _, v := range param.StepList { | ||
| 484 | + if v.LinkNodeType == domain.LinkNodeSelfAssessment { | ||
| 485 | + //员工自评 | ||
| 486 | + stepSelfTemp.BeginTime = v.BeginTime | ||
| 487 | + stepSelfTemp.EndTime = v.EndTime | ||
| 488 | + stepSelfTemp.LinkNodeId = v.LinkNodeId | ||
| 489 | + stepSelfTemp.LinkNodeName = v.LinkNodeName | ||
| 490 | + assessListTemp := srv.createStaffAssessSelf(stepSelfTemp, userList, userDepartmentMap) | ||
| 491 | + assessList = append(assessList, assessListTemp...) | ||
| 492 | + } | ||
| 493 | + if v.LinkNodeType == domain.LinkNodeSuperiorAssessment { | ||
| 494 | + // TODO | ||
| 495 | + stepSelfTemp.BeginTime = v.BeginTime | ||
| 496 | + stepSelfTemp.EndTime = v.EndTime | ||
| 497 | + stepSelfTemp.LinkNodeId = v.LinkNodeId | ||
| 498 | + stepSelfTemp.LinkNodeName = v.LinkNodeName | ||
| 499 | + assessListTemp, err := srv.createStaffAssessSupper(transactionContext, stepSelfTemp, userList, userDepartmentMap) | ||
| 500 | + if err != nil { | ||
| 501 | + return nil, err | ||
| 502 | + } | ||
| 503 | + assessList = append(assessList, assessListTemp...) | ||
| 504 | + } | ||
| 505 | + } | ||
| 506 | + return assessList, nil | ||
| 507 | +} | ||
| 508 | + | ||
| 509 | +// 构建员工自评 | ||
| 510 | +func (srv StaffAssessServeice) createStaffAssessSelf(assessTemp domain.StaffAssess, | ||
| 511 | + userList []*domain.User, userDepartmentMap map[int64][]*domain.Department) []domain.StaffAssess { | ||
| 512 | + result := []domain.StaffAssess{} | ||
| 513 | + for _, usr := range userList { | ||
| 514 | + assessTemp.TargetUser = domain.StaffDesc{ | ||
| 515 | + UserId: int(usr.Id), | ||
| 516 | + Account: usr.Account, | ||
| 517 | + UserName: usr.Account, | ||
| 518 | + } | ||
| 519 | + assessTemp.Executor = domain.StaffDesc{ | ||
| 520 | + UserId: int(usr.Id), | ||
| 521 | + Account: usr.Account, | ||
| 522 | + UserName: usr.Account, | ||
| 523 | + } | ||
| 524 | + if depList, ok := userDepartmentMap[usr.Id]; ok { | ||
| 525 | + for _, dep := range depList { | ||
| 526 | + assessTemp.TargetDepartment = append(assessTemp.TargetDepartment, domain.StaffDepartment{ | ||
| 527 | + DepartmentId: int(dep.Id), | ||
| 528 | + DepartmentName: dep.Name, | ||
| 529 | + }) | ||
| 530 | + } | ||
| 531 | + } | ||
| 532 | + result = append(result, assessTemp) | ||
| 533 | + } | ||
| 534 | + return result | ||
| 535 | +} | ||
| 536 | + | ||
| 537 | +// 构建员工上级评估 | ||
| 538 | +func (srv StaffAssessServeice) createStaffAssessSupper( | ||
| 539 | + transactionContext application.TransactionContext, | ||
| 540 | + assessTemp domain.StaffAssess, | ||
| 541 | + userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, | ||
| 542 | +) ([]domain.StaffAssess, error) { | ||
| 543 | + | ||
| 544 | + // 获取员工的上级用户 | ||
| 545 | + | ||
| 546 | + return nil, nil | ||
| 547 | +} | ||
| 548 | + | ||
| 549 | +// 获取某个员工360邀请的人员 | ||
| 550 | +func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) { | ||
| 551 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 552 | + if err != nil { | ||
| 553 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 554 | + } | ||
| 555 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 556 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 557 | + } | ||
| 558 | + defer func() { | ||
| 559 | + _ = transactionContext.RollbackTransaction() | ||
| 560 | + }() | ||
| 561 | + | ||
| 562 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 563 | + "transactionContext": transactionContext, | ||
| 564 | + }) | ||
| 565 | + | ||
| 566 | + assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
| 567 | + "transactionContext": transactionContext, | ||
| 568 | + }) | ||
| 569 | + assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{ | ||
| 570 | + "id": param.AssessTaskId, | ||
| 571 | + }) | ||
| 572 | + if err != nil { | ||
| 573 | + return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error()) | ||
| 574 | + } | ||
| 575 | + _, assessList, err := assessReps.Find(map[string]interface{}{ | ||
| 576 | + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
| 577 | + "staffAssessTaskId": param.AssessTaskId, | ||
| 578 | + "targetUserId": param.UsrId, | ||
| 579 | + }) | ||
| 580 | + if err != nil { | ||
| 581 | + return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error()) | ||
| 582 | + } | ||
| 583 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 584 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 585 | + } | ||
| 586 | + | ||
| 587 | + result := adapter.AssessInviteUserResp{ | ||
| 588 | + AssessTaskId: assessTaskData.Id, | ||
| 589 | + } | ||
| 590 | + for _, v := range assessTaskData.StepList { | ||
| 591 | + if v.LinkNodeType != domain.LinkNodeAllInvite { | ||
| 592 | + continue | ||
| 593 | + } | ||
| 594 | + result.LinkNodeId = v.LinkNodeId | ||
| 595 | + result.LinkNodeName = v.LinkNodeName | ||
| 596 | + result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05") | ||
| 597 | + result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05") | ||
| 598 | + break | ||
| 599 | + } | ||
| 600 | + for _, v := range assessList { | ||
| 601 | + if v.Types == domain.AssessInviteDiffSuper { | ||
| 602 | + result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor) | ||
| 603 | + } | ||
| 604 | + if v.Types == domain.AssessInviteSameSuper { | ||
| 605 | + result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor) | ||
| 606 | + } | ||
| 607 | + } | ||
| 608 | + return &result, nil | ||
| 609 | +} | ||
| 610 | + | ||
| 611 | +// 获取某个员工360邀请的人员 | ||
| 612 | +func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) { | ||
| 613 | + inviteSameSuperId := []int{} | ||
| 614 | + InviteDiffSuperId := []int{} | ||
| 615 | + for _, v := range param.InviteDiffSuper { | ||
| 616 | + id, err := strconv.Atoi(v) | ||
| 617 | + if err != nil { | ||
| 618 | + return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误") | ||
| 619 | + } | ||
| 620 | + InviteDiffSuperId = append(InviteDiffSuperId, id) | ||
| 621 | + } | ||
| 622 | + for _, v := range param.InviteSameSuper { | ||
| 623 | + id, err := strconv.Atoi(v) | ||
| 624 | + if err != nil { | ||
| 625 | + return nil, application.ThrowError(application.ARG_ERROR, "用户填写错误") | ||
| 626 | + } | ||
| 627 | + inviteSameSuperId = append(inviteSameSuperId, id) | ||
| 628 | + } | ||
| 629 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 630 | + if err != nil { | ||
| 631 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 632 | + } | ||
| 633 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 634 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 635 | + } | ||
| 636 | + defer func() { | ||
| 637 | + _ = transactionContext.RollbackTransaction() | ||
| 638 | + }() | ||
| 639 | + | ||
| 640 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 641 | + "transactionContext": transactionContext, | ||
| 642 | + }) | ||
| 643 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 644 | + "transactionContext": transactionContext, | ||
| 645 | + }) | ||
| 646 | + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{ | ||
| 647 | + "transactionContext": transactionContext, | ||
| 648 | + }) | ||
| 649 | + | ||
| 650 | + assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
| 651 | + "transactionContext": transactionContext, | ||
| 652 | + }) | ||
| 653 | + assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{ | ||
| 654 | + "id": param.AssessTaskId, | ||
| 655 | + }) | ||
| 656 | + if err != nil { | ||
| 657 | + return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error()) | ||
| 658 | + } | ||
| 659 | + | ||
| 660 | + targetUser, err := userRepo.FindOne(map[string]interface{}{ | ||
| 661 | + "id": param.TargetUserId, | ||
| 662 | + }) | ||
| 663 | + if err != nil { | ||
| 664 | + return nil, application.ThrowError(application.ARG_ERROR, "获取被评估员工"+err.Error()) | ||
| 665 | + } | ||
| 666 | + //被评估人的部门 | ||
| 667 | + var targetUserDepartment []domain.StaffDepartment | ||
| 668 | + if len(targetUser.DepartmentId) > 0 { | ||
| 669 | + _, departmentList, err := departmentRepo.Find(map[string]interface{}{ | ||
| 670 | + "ids": targetUser.DepartmentId, | ||
| 671 | + }) | ||
| 672 | + if err != nil { | ||
| 673 | + return nil, application.ThrowError(application.ARG_ERROR, "获取部门信息"+err.Error()) | ||
| 674 | + } | ||
| 675 | + for _, v := range departmentList { | ||
| 676 | + targetUserDepartment = append(targetUserDepartment, domain.StaffDepartment{ | ||
| 677 | + DepartmentId: int(v.Id), | ||
| 678 | + DepartmentName: v.Name, | ||
| 679 | + }) | ||
| 680 | + } | ||
| 681 | + } | ||
| 682 | + //邀请的相同上级的员工 | ||
| 683 | + var inviteSameSuper []domain.StaffDesc | ||
| 684 | + if len(inviteSameSuperId) > 0 { | ||
| 685 | + _, userList, err := userRepo.Find(map[string]interface{}{ | ||
| 686 | + "ids": inviteSameSuperId, | ||
| 687 | + }) | ||
| 688 | + if err != nil { | ||
| 689 | + return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error()) | ||
| 690 | + } | ||
| 691 | + for _, v := range userList { | ||
| 692 | + inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{ | ||
| 693 | + UserId: int(v.Id), | ||
| 694 | + UserName: v.Name, | ||
| 695 | + Account: v.Account, | ||
| 696 | + }) | ||
| 697 | + } | ||
| 698 | + } | ||
| 699 | + //邀请的不同上级的员工 | ||
| 700 | + var inviteDiffSuper []domain.StaffDesc | ||
| 701 | + if len(InviteDiffSuperId) > 0 { | ||
| 702 | + _, userList, err := userRepo.Find(map[string]interface{}{ | ||
| 703 | + "ids": InviteDiffSuperId, | ||
| 704 | + }) | ||
| 705 | + if err != nil { | ||
| 706 | + return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error()) | ||
| 707 | + } | ||
| 708 | + for _, v := range userList { | ||
| 709 | + inviteDiffSuper = append(inviteDiffSuper, domain.StaffDesc{ | ||
| 710 | + UserId: int(v.Id), | ||
| 711 | + UserName: v.Name, | ||
| 712 | + Account: v.Account, | ||
| 713 | + }) | ||
| 714 | + } | ||
| 715 | + } | ||
| 716 | + _ = assessReps | ||
| 717 | + _ = inviteSameSuper | ||
| 718 | + _ = inviteDiffSuper | ||
| 719 | + _ = targetUserDepartment | ||
| 720 | + // _, assessList, err := assessReps.Find(map[string]interface{}{ | ||
| 721 | + // "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, | ||
| 722 | + // "staffAssessTaskId": param.AssessTaskId, | ||
| 723 | + // "targetUserId": param.TargetUserId, | ||
| 724 | + // }) | ||
| 725 | + // if err != nil { | ||
| 726 | + // return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error()) | ||
| 727 | + // } | ||
| 728 | + // TODO | ||
| 729 | + | ||
| 730 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 731 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 732 | + } | ||
| 733 | + | ||
| 734 | + result := adapter.AssessInviteUserResp{ | ||
| 735 | + AssessTaskId: assessTaskData.Id, | ||
| 736 | + } | ||
| 737 | + // for _, v := range assessTaskData.StepList { | ||
| 738 | + // if v.LinkNodeType != domain.LinkNodeAllInvite { | ||
| 739 | + // continue | ||
| 740 | + // } | ||
| 741 | + // result.LinkNodeId = v.LinkNodeId | ||
| 742 | + // result.LinkNodeName = v.LinkNodeName | ||
| 743 | + // result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05") | ||
| 744 | + // result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05") | ||
| 745 | + // break | ||
| 746 | + // } | ||
| 747 | + // for _, v := range assessList { | ||
| 748 | + // if v.Types == domain.AssessInviteDiffSuper { | ||
| 749 | + // result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor) | ||
| 750 | + // } | ||
| 751 | + // if v.Types == domain.AssessInviteSameSuper { | ||
| 752 | + // result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor) | ||
| 753 | + // } | ||
| 754 | + // } | ||
| 755 | + return &result, nil | ||
| 756 | +} | ||
| 757 | + | ||
| 758 | +// 获取员工自评的评估内容详情 | ||
| 759 | +func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) { | ||
| 760 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 761 | + if err != nil { | ||
| 762 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 763 | + } | ||
| 764 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 765 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 766 | + } | ||
| 767 | + defer func() { | ||
| 768 | + _ = transactionContext.RollbackTransaction() | ||
| 769 | + }() | ||
| 770 | + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ | ||
| 771 | + "transactionContext": transactionContext, | ||
| 772 | + }) | ||
| 773 | + | ||
| 774 | + //获取员工的评估 | ||
| 775 | + _, assessList, err := assessReps.Find(map[string]interface{}{ | ||
| 776 | + "companyId": param.CompanyId, | ||
| 777 | + "staffAssessTaskId": param.AssessTaskId, | ||
| 778 | + "targetUserId": param.TargetUserId, | ||
| 779 | + "typesList": []string{string(domain.AssessSelf)}, | ||
| 780 | + }) | ||
| 781 | + if err != nil { | ||
| 782 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) | ||
| 783 | + } | ||
| 784 | + if len(assessList) == 0 { | ||
| 785 | + return &adapter.AssessInfoResp{}, nil | ||
| 786 | + } | ||
| 787 | + assessData := assessList[0] | ||
| 788 | + projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
| 789 | + "transactionContext": transactionContext, | ||
| 790 | + }) | ||
| 791 | + projectData, err := projectRepo.FindOne(map[string]interface{}{ | ||
| 792 | + "id": assessData.EvaluationProjectId, | ||
| 793 | + }) | ||
| 794 | + if err != nil { | ||
| 795 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估配置"+err.Error()) | ||
| 796 | + } | ||
| 797 | + if projectData.Template == nil { | ||
| 798 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估配置模板") | ||
| 799 | + } | ||
| 800 | + var selfLinkNode *domain.LinkNode | ||
| 801 | + for _, v := range projectData.Template.LinkNodes { | ||
| 802 | + if v.Type == domain.LinkNodeSelfAssessment { | ||
| 803 | + selfLinkNode = v | ||
| 804 | + break | ||
| 805 | + } | ||
| 806 | + } | ||
| 807 | + if selfLinkNode == nil { | ||
| 808 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估自评配置") | ||
| 809 | + } | ||
| 810 | + //获取员工评估的填写内容 | ||
| 811 | + // assessContentReps := factory.CreateStaffAssessContentRepository(map[string]interface{}{ | ||
| 812 | + // "transactionContext": transactionContext, | ||
| 813 | + // }) | ||
| 814 | + // _, assessContentList, err := assessContentReps.Find(map[string]interface{}{ | ||
| 815 | + // "staffAssessId": assessData.Id, | ||
| 816 | + // }) | ||
| 817 | + // if err != nil { | ||
| 818 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估员工填写的内容"+err.Error()) | ||
| 819 | + // } | ||
| 820 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 821 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 822 | + } | ||
| 823 | + | ||
| 824 | + result := adapter.AssessInfoResp{ | ||
| 825 | + CycleId: assessData.CycleId, | ||
| 826 | + CycleName: assessData.CycleName, | ||
| 827 | + EvaluationProjectId: assessData.EvaluationProjectId, | ||
| 828 | + EvaluationProjectName: assessData.EvaluationProjectName, | ||
| 829 | + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"), | ||
| 830 | + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"), | ||
| 831 | + Status: string(assessData.Status), | ||
| 832 | + TargetUserId: assessData.TargetUser.UserId, | ||
| 833 | + TargetUserName: assessData.TargetUser.UserName, | ||
| 834 | + AssessContent: nil, | ||
| 835 | + } | ||
| 836 | + assessContent := make([]adapter.AssessContent, 0) | ||
| 837 | + for _, v := range selfLinkNode.NodeContents { | ||
| 838 | + assessContent = append(assessContent, adapter.AssessContent{ | ||
| 839 | + Category: v.Category, | ||
| 840 | + Name: v.Name, | ||
| 841 | + PromptTitle: v.PromptTitle, | ||
| 842 | + PromptText: v.PromptText, | ||
| 843 | + EntryItems: v.EntryItems, | ||
| 844 | + }) | ||
| 845 | + } | ||
| 846 | + result.AssessContent = assessContent | ||
| 847 | + return &result, nil | ||
| 848 | +} |
| @@ -4,6 +4,16 @@ import ( | @@ -4,6 +4,16 @@ import ( | ||
| 4 | "time" | 4 | "time" |
| 5 | ) | 5 | ) |
| 6 | 6 | ||
| 7 | +const ( | ||
| 8 | + KpiCycleDay int = 1 // 考核周期-日 | ||
| 9 | + KpiCycleWeek int = 2 // 考核周期-周 | ||
| 10 | + KpiCycleOneMonth int = 3 // 考核周期-月 | ||
| 11 | + KpiCycleTwoMonth int = 4 // 考核周期-双月 | ||
| 12 | + KpiCycleThreeMonth int = 5 // 考核周期-季度 | ||
| 13 | + KpiCycleSixMonth int = 6 // 考核周期-半年 | ||
| 14 | + KpiCycleYear int = 7 // 考核周期-年 | ||
| 15 | +) | ||
| 16 | + | ||
| 7 | type TemplateSimple struct { | 17 | type TemplateSimple struct { |
| 8 | Id int64 `json:"id,string" comment:"模板ID"` | 18 | Id int64 `json:"id,string" comment:"模板ID"` |
| 9 | Name string `json:"name" comment:"模板名称"` | 19 | Name string `json:"name" comment:"模板名称"` |
| @@ -17,7 +27,7 @@ type EvaluationCycle struct { | @@ -17,7 +27,7 @@ type EvaluationCycle struct { | ||
| 17 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` | 27 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` |
| 18 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` | 28 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` |
| 19 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` | 29 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` |
| 20 | - KpiCycle int `json:"state" comment:"考核周期(0日、1周、2月)"` | 30 | + KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"` |
| 21 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 31 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
| 22 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | 32 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` |
| 23 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 33 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
| @@ -42,8 +42,8 @@ type EvaluationRule struct { | @@ -42,8 +42,8 @@ type EvaluationRule struct { | ||
| 42 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` | 42 | CompanyId int64 `json:"companyId,string" comment:"公司ID"` |
| 43 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` | 43 | CreatorId int64 `json:"creatorId,string" comment:"创建人ID"` |
| 44 | Type int `json:"type" comment:"评估方式(0评级、1评分)"` | 44 | Type int `json:"type" comment:"评估方式(0评级、1评分)"` |
| 45 | - Rating *Rating `json:"rating" comment:"评级"` | ||
| 46 | - Score *Score `json:"score" comment:"评分"` | 45 | + Rating Rating `json:"rating" comment:"评级"` |
| 46 | + Score Score `json:"score" comment:"评分"` | ||
| 47 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 47 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
| 48 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` | 48 | UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` |
| 49 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` | 49 | DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` |
| @@ -24,12 +24,6 @@ const ( | @@ -24,12 +24,6 @@ const ( | ||
| 24 | 24 | ||
| 25 | ) | 25 | ) |
| 26 | 26 | ||
| 27 | -const ( | ||
| 28 | - KpiCycleDay int = 0 // 考核周期-日 | ||
| 29 | - KpiCycleWeek int = 1 // 考核周期-周 | ||
| 30 | - KpiCycleMonth int = 2 // 考核周期-月 | ||
| 31 | -) | ||
| 32 | - | ||
| 33 | type EntryItem struct { | 27 | type EntryItem struct { |
| 34 | Title string `json:"title" comment:"填写标题"` | 28 | Title string `json:"title" comment:"填写标题"` |
| 35 | HintText string `json:"hintText" comment:"文本内容提示"` | 29 | HintText string `json:"hintText" comment:"文本内容提示"` |
| @@ -40,16 +34,17 @@ type NodeContent struct { | @@ -40,16 +34,17 @@ type NodeContent struct { | ||
| 40 | Category string `json:"category" comment:"类别"` | 34 | Category string `json:"category" comment:"类别"` |
| 41 | Name string `json:"name" comment:"名称"` | 35 | Name string `json:"name" comment:"名称"` |
| 42 | RuleId int64 `json:"ruleId" comment:"评估规则ID"` | 36 | RuleId int64 `json:"ruleId" comment:"评估规则ID"` |
| 37 | + Rule *EvaluationRule `json:"rule" comment:"评估规则对象"` | ||
| 43 | PromptTitle string `json:"promptTitle" comment:"提示项标题"` | 38 | PromptTitle string `json:"promptTitle" comment:"提示项标题"` |
| 44 | PromptText string `json:"promptText" comment:"提示项正文"` | 39 | PromptText string `json:"promptText" comment:"提示项正文"` |
| 45 | EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` | 40 | EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` |
| 46 | } | 41 | } |
| 47 | 42 | ||
| 48 | -// NodeAllInvite 360°邀请 | ||
| 49 | -type NodeAllInvite struct { | ||
| 50 | - ParentDifferentIds []int64 `json:"parentDifferentIds" comment:"不同上级同事ID"` | ||
| 51 | - ParentSameIds []int64 `json:"parentSameIds" comment:"相同上级同事ID"` | ||
| 52 | -} | 43 | +//// NodeAllInvite 360°邀请 |
| 44 | +//type NodeAllInvite struct { | ||
| 45 | +// ParentDifferentIds []string `json:"parentDifferentIds" comment:"不同上级同事ID"` | ||
| 46 | +// ParentSameIds []string `json:"parentSameIds" comment:"相同上级同事ID"` | ||
| 47 | +//} | ||
| 53 | 48 | ||
| 54 | //// NodeKpiResult 绩效结果查看 | 49 | //// NodeKpiResult 绩效结果查看 |
| 55 | //type NodeKpiResult struct { | 50 | //type NodeKpiResult struct { |
| @@ -62,10 +57,11 @@ type LinkNode struct { | @@ -62,10 +57,11 @@ type LinkNode struct { | ||
| 62 | Name string `json:"name" comment:"环节名称"` | 57 | Name string `json:"name" comment:"环节名称"` |
| 63 | Describe string `json:"describe" comment:"环节描述"` | 58 | Describe string `json:"describe" comment:"环节描述"` |
| 64 | NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"` | 59 | NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"` |
| 65 | - NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"` | ||
| 66 | TimeStart *time.Time `json:"timeStart" comment:"起始时间"` | 60 | TimeStart *time.Time `json:"timeStart" comment:"起始时间"` |
| 67 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` | 61 | TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` |
| 68 | - KpiCycle int `json:"state" comment:"考核周期(0日、1周、2月)"` | 62 | + KpiCycle int `json:"state" comment:"考核周期(1日、2周、3月)"` |
| 63 | + //NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"` | ||
| 64 | + | ||
| 69 | } | 65 | } |
| 70 | 66 | ||
| 71 | // 评估模板 | 67 | // 评估模板 |
pkg/domain/staff_assess.go
0 → 100644
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +import "time" | ||
| 4 | + | ||
| 5 | +//填写评估的类型 | ||
| 6 | +type StaffAssessType string | ||
| 7 | + | ||
| 8 | +const ( | ||
| 9 | + AssessSelf StaffAssessType = "self" //自评 | ||
| 10 | + AssessSuper StaffAssessType = "super" //上级评估 | ||
| 11 | + AssessInviteSameSuper StaffAssessType = "invite_same_super" //360 邀请评估-相同上级的同事 | ||
| 12 | + AssessInviteDiffSuper StaffAssessType = "invite_diff_super" //360 邀请评估-不同上级的同事 | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +//填写评估的状态 | ||
| 16 | +type StaffAssessStatus string | ||
| 17 | + | ||
| 18 | +const ( | ||
| 19 | + StaffAssessUnstart StaffAssessStatus = "unstart" //未开始 | ||
| 20 | + StaffAssessUncompleted StaffAssessStatus = "uncompleted" //未完成 | ||
| 21 | + StaffAssessCompleted StaffAssessStatus = "completed" //已完成 | ||
| 22 | +) | ||
| 23 | + | ||
| 24 | +// 记录用户需要的评估项目 | ||
| 25 | +type StaffAssess struct { | ||
| 26 | + Id int `json:"id"` //id | ||
| 27 | + CompanyId int `json:"companyId"` //公司id | ||
| 28 | + EvaluationProjectId int `json:"evaluationProjectId"` //对应的项目id | ||
| 29 | + EvaluationProjectName string `json:"evaluationProjectName"` //对应的项目名称 | ||
| 30 | + CycleId int64 `json:"cycleId"` //对应的周期id | ||
| 31 | + CycleName string `json:"cycleName"` //对应的周期名称 | ||
| 32 | + StaffAssessTaskId int `json:"staffAssessTaskId"` //执行评估的任务id | ||
| 33 | + TargetUser StaffDesc `json:"targetUser"` //被评估的目标用户 | ||
| 34 | + TargetDepartment []StaffDepartment `json:"targetDepartment"` //被评估的目标用户所在的部门 | ||
| 35 | + Executor StaffDesc `json:"executor"` //填写评估的用户 | ||
| 36 | + Types StaffAssessType `json:"types"` //填写评估对应的类型 | ||
| 37 | + LinkNodeId int `json:"linkNodeId"` //评估环节对应的id,用于调取评估模板 | ||
| 38 | + LinkNodeName string `json:"linkNodeName"` //评估环节对应的id,用于调取评估模板 | ||
| 39 | + Status StaffAssessStatus `json:"status"` //评估的填写状态 | ||
| 40 | + BeginTime time.Time `json:"beginTime"` //开始时间 | ||
| 41 | + EndTime time.Time `json:"endTime"` //截止时间 | ||
| 42 | + CreatedAt time.Time `json:"createdAt"` //数据创建时间 | ||
| 43 | + UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 | ||
| 44 | + DeletedAt *time.Time `json:"deletedAt"` //数据删除时间 | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +type StaffAssessRepository interface { | ||
| 48 | + Save(param *StaffAssess) (*StaffAssess, error) | ||
| 49 | + Remove(id int) error | ||
| 50 | + FindOne(queryOptions map[string]interface{}) (*StaffAssess, error) | ||
| 51 | + Find(queryOptions map[string]interface{}) (int, []*StaffAssess, error) | ||
| 52 | +} |
pkg/domain/staff_assess_content.go
0 → 100644
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +import "time" | ||
| 4 | + | ||
| 5 | +//填写的评估内容 | ||
| 6 | +type StaffAssessContent struct { | ||
| 7 | + Id int `json:"id"` //id | ||
| 8 | + StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id | ||
| 9 | + SortBy int `json:"sortBy"` //排序 | ||
| 10 | + Category string `json:"category"` //类别 | ||
| 11 | + Title string `json:"title"` //问题标题 | ||
| 12 | + Remark string `json:"remark"` //填写的反馈 | ||
| 13 | + Rate string `json:"rate"` //评估填写的值 | ||
| 14 | + ReteResult string `json:"reteResult"` //评估的结果 | ||
| 15 | + CreatedAt time.Time `json:"createdAt"` //数据创建时间 | ||
| 16 | + UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 | ||
| 17 | + //TODO | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +type AssessContemtRemark struct { | ||
| 21 | + Title string `json:"title"` //comment:"填写标题" | ||
| 22 | + RemarkText string `json:"hintText"` // comment:"填写文本内容" | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +type StaffAssessContentRepository interface { | ||
| 26 | + Save(param *StaffAssessContent) (*StaffAssessContent, error) | ||
| 27 | + Remove(id int) error | ||
| 28 | + FindOne(queryOptions map[string]interface{}) (*StaffAssessContent, error) | ||
| 29 | + Find(queryOptions map[string]interface{}) (int, []*StaffAssessContent, error) | ||
| 30 | +} |
pkg/domain/staff_assess_task.go
0 → 100644
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +import "time" | ||
| 4 | + | ||
| 5 | +//评估任务重复执行的方式 | ||
| 6 | +// type AssessTaskRepeatWay string | ||
| 7 | + | ||
| 8 | +// const ( | ||
| 9 | +// AssessTaskRepeatDay AssessTaskRepeatWay = "day" //按天重复 | ||
| 10 | +// AssessTaskRepeatWeek AssessTaskRepeatWay = "week" //按周重复 | ||
| 11 | +// AssessTaskRepeatMonth AssessTaskRepeatWay = "month" //按月 | ||
| 12 | +// AssessTaskRepeatMonthDouble AssessTaskRepeatWay = "month_double" //按双月 | ||
| 13 | +// AssessTaskRepeatQuarter AssessTaskRepeatWay = "quarter" //按季度 | ||
| 14 | +// AssessTaskRepeatYearHalf AssessTaskRepeatWay = "year_half" //按半年 | ||
| 15 | +// AssessTaskRepeatYear AssessTaskRepeatWay = "year" //按年 | ||
| 16 | +// ) | ||
| 17 | + | ||
| 18 | +// 执行评估的任务列表 | ||
| 19 | +type StaffAssessTask struct { | ||
| 20 | + Id int `json:"id"` | ||
| 21 | + CompanyId int `json:"companyId"` //公司id | ||
| 22 | + EvaluationProjectId int `json:"evaluationProjectId"` //项目id | ||
| 23 | + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | ||
| 24 | + CycleId int64 `json:"cycleId"` //对应的周期id | ||
| 25 | + CycleName string `json:"cycleName"` //对应周期的名称 | ||
| 26 | + BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 | ||
| 27 | + EndTime time.Time `json:"endTime"` //绩效考核截止时间 | ||
| 28 | + StepList []AssessTaskStep `json:"stepList"` //考评的流程 | ||
| 29 | + ExecutorId []int `json:"executorId"` //参与此次考评的人 | ||
| 30 | + CreatedAt time.Time `json:"createdAt"` //数据创建时间 | ||
| 31 | + UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 | ||
| 32 | + DeletedAt *time.Time `json:"deletedAt"` //数据删除时间 | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +//考评的流程 | ||
| 36 | +type AssessTaskStep struct { | ||
| 37 | + SortBy int `json:"sortBy"` //排序 | ||
| 38 | + LinkNodeId int `json:"linkNodeId"` //考评的流程id | ||
| 39 | + LinkNodeName string `json:"linkNodeName"` //流程名称 | ||
| 40 | + LinkNodeType int `json:"linkNodeType"` //流程类型 同evaluation_template.go->LinkNode.Type | ||
| 41 | + BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 | ||
| 42 | + EndTime time.Time `json:"endTime"` //绩效考核截止时间 | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +type StaffAssessTaskRepository interface { | ||
| 46 | + Save(param *StaffAssessTask) (*StaffAssessTask, error) | ||
| 47 | + Remove(id int) error | ||
| 48 | + FindOne(queryOptions map[string]interface{}) (*StaffAssessTask, error) | ||
| 49 | + Find(queryOptions map[string]interface{}) (int, []*StaffAssessTask, error) | ||
| 50 | +} |
pkg/domain/staff_desc.go
0 → 100644
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +//员工基本信息描述 | ||
| 4 | +type StaffDesc struct { | ||
| 5 | + UserId int `json:"userId"` //用户id | ||
| 6 | + Account string `json:"account"` //用户的账号 | ||
| 7 | + UserName string `json:"userName"` //用户的名称 | ||
| 8 | +} | ||
| 9 | + | ||
| 10 | +//员工的部门 | ||
| 11 | +type StaffDepartment struct { | ||
| 12 | + DepartmentId int `json:"departmentId"` //部门id | ||
| 13 | + DepartmentName string `json:"departmentName"` //部门名称 | ||
| 14 | +} |
pkg/domain/staff_evaluation.go
已删除
100644 → 0
| 1 | -package domain | ||
| 2 | - | ||
| 3 | -import "time" | ||
| 4 | - | ||
| 5 | -type StaffEvaluationType string | ||
| 6 | - | ||
| 7 | -const ( | ||
| 8 | - EvaluationSelf StaffEvaluationType = "self" //自评 | ||
| 9 | - EvaluationSuper StaffEvaluationType = "super" //上级评估 | ||
| 10 | - EvaluationOverall StaffEvaluationType = "overall" //360评估 | ||
| 11 | -) | ||
| 12 | - | ||
| 13 | -// 需要填写评估的用户 | ||
| 14 | -type StaffEvaluation struct { | ||
| 15 | - Id int //id | ||
| 16 | - EvaluationProjectId int //对应的项目id | ||
| 17 | - CycleId int64 //对应的周期id | ||
| 18 | - TargetUserId int //被评估的目标用户 | ||
| 19 | - ExecutorId int //填写评估的用户 | ||
| 20 | - Types StaffEvaluationType //填写评估对应的类型 | ||
| 21 | - BeginTime time.Time //开始时间 | ||
| 22 | - EndTime time.Time //截止时间 | ||
| 23 | - CreatedAt time.Time //数据创建时间 | ||
| 24 | - UpdatedAt time.Time //数据更新时间 | ||
| 25 | -} | ||
| 26 | - | ||
| 27 | -//用户填写的评估 | ||
| 28 | -type StaffEvaluationContent struct { | ||
| 29 | -} |
| @@ -2,6 +2,7 @@ package pg | @@ -2,6 +2,7 @@ package pg | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | + | ||
| 5 | "github.com/go-pg/pg/v10" | 6 | "github.com/go-pg/pg/v10" |
| 6 | "github.com/go-pg/pg/v10/orm" | 7 | "github.com/go-pg/pg/v10/orm" |
| 7 | "github.com/linmadan/egglib-go/persistent/pg/comment" | 8 | "github.com/linmadan/egglib-go/persistent/pg/comment" |
| @@ -34,6 +35,13 @@ func init() { | @@ -34,6 +35,13 @@ func init() { | ||
| 34 | &models.Role{}, | 35 | &models.Role{}, |
| 35 | &models.RoleUser{}, | 36 | &models.RoleUser{}, |
| 36 | &models.Position{}, | 37 | &models.Position{}, |
| 38 | + &models.EvaluationRule{}, | ||
| 39 | + &models.EvaluationTemplate{}, | ||
| 40 | + &models.EvaluationCycle{}, | ||
| 41 | + &models.EvaluationCycleTemplate{}, | ||
| 42 | + &models.EvaluationProject{}, | ||
| 43 | + &models.StaffAssess{}, | ||
| 44 | + &models.StaffAssessTask{}, | ||
| 37 | } | 45 | } |
| 38 | for _, model := range tables { | 46 | for _, model := range tables { |
| 39 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ | 47 | err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ |
| @@ -5,14 +5,14 @@ import ( | @@ -5,14 +5,14 @@ import ( | ||
| 5 | ) | 5 | ) |
| 6 | 6 | ||
| 7 | type EvaluationCycle struct { | 7 | type EvaluationCycle struct { |
| 8 | - tableName struct{} `pg:"evaluation_cycle" comment:"评估周期"` | ||
| 9 | - Id int64 `pg:"pk:id" comment:"周期ID"` | 8 | + tableName struct{} `comment:"评估周期" pg:"evaluation_cycle"` |
| 9 | + Id int64 `comment:"周期ID" pg:"pk:id"` | ||
| 10 | Name string `comment:"名称"` | 10 | Name string `comment:"名称"` |
| 11 | TimeStart *time.Time `comment:"起始时间"` | 11 | TimeStart *time.Time `comment:"起始时间"` |
| 12 | TimeEnd *time.Time `comment:"截至时间"` | 12 | TimeEnd *time.Time `comment:"截至时间"` |
| 13 | CompanyId int64 `comment:"公司ID"` | 13 | CompanyId int64 `comment:"公司ID"` |
| 14 | CreatorId int64 `comment:"创建人ID"` | 14 | CreatorId int64 `comment:"创建人ID"` |
| 15 | - KpiCycle int `comment:"考核周期(0日、1周、2月)"` | 15 | + KpiCycle int `comment:"考核周期(1日、2周、3月)"` |
| 16 | CreatedAt time.Time `comment:"创建时间"` | 16 | CreatedAt time.Time `comment:"创建时间"` |
| 17 | UpdatedAt time.Time `comment:"更新时间"` | 17 | UpdatedAt time.Time `comment:"更新时间"` |
| 18 | DeletedAt *time.Time `comment:"删除时间"` | 18 | DeletedAt *time.Time `comment:"删除时间"` |
| @@ -6,8 +6,8 @@ import ( | @@ -6,8 +6,8 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type EvaluationCycleTemplate struct { | 8 | type EvaluationCycleTemplate struct { |
| 9 | - tableName struct{} `pg:"evaluation_cycle_template" comment:"评估周期模板"` | ||
| 10 | - Id int64 `pg:"pk:id" comment:"模板ID"` | 9 | + tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` |
| 10 | + Id int64 `comment:"模板ID" pg:"pk:id"` | ||
| 11 | Name string `comment:"模板名称"` | 11 | Name string `comment:"模板名称"` |
| 12 | Template *domain.EvaluationTemplate `comment:"模板数据"` | 12 | Template *domain.EvaluationTemplate `comment:"模板数据"` |
| 13 | CycleId int64 `comment:"周期ID"` | 13 | CycleId int64 `comment:"周期ID"` |
| @@ -6,14 +6,14 @@ import ( | @@ -6,14 +6,14 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type EvaluationProject struct { | 8 | type EvaluationProject struct { |
| 9 | - tableName struct{} `pg:"evaluation_project" comment:"评估项目"` | ||
| 10 | - Id int64 `pg:"pk:id" comment:"ID"` | 9 | + tableName struct{} `comment:"评估项目" pg:"evaluation_project"` |
| 10 | + Id int64 `comment:"ID" pg:"pk:id"` | ||
| 11 | Name string `comment:"名称"` | 11 | Name string `comment:"名称"` |
| 12 | Describe string `comment:"描述"` | 12 | Describe string `comment:"描述"` |
| 13 | CompanyId int64 `comment:"公司ID"` | 13 | CompanyId int64 `comment:"公司ID"` |
| 14 | CycleId int64 `comment:"周期ID"` | 14 | CycleId int64 `comment:"周期ID"` |
| 15 | CreatorId int64 `comment:"创建人ID"` | 15 | CreatorId int64 `comment:"创建人ID"` |
| 16 | - State int `comment:"状态(0待完成配置、1待启用、2启用、3停用)"` | 16 | + State int `comment:"状态(0待完成配置、1待启用、2启用、3停用)" pg:",use_zero"` |
| 17 | HrBp int `comment:"HR角色权限"` | 17 | HrBp int `comment:"HR角色权限"` |
| 18 | Pmp int `comment:"PM角色权限"` | 18 | Pmp int `comment:"PM角色权限"` |
| 19 | PmpIds []string `comment:"项目管理员ID"` | 19 | PmpIds []string `comment:"项目管理员ID"` |
| @@ -6,16 +6,16 @@ import ( | @@ -6,16 +6,16 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type EvaluationRule struct { | 8 | type EvaluationRule struct { |
| 9 | - tableName struct{} `pg:"evaluation_rule" comment:"评估规则"` | ||
| 10 | - Id int64 `pg:"pk:id" comment:"ID"` | 9 | + tableName struct{} `comment:"评估规则" pg:"evaluation_rule"` |
| 10 | + Id int64 `comment:"ID" pg:"pk:id"` | ||
| 11 | Name string `comment:"名称"` | 11 | Name string `comment:"名称"` |
| 12 | Remark string `comment:"备注"` | 12 | Remark string `comment:"备注"` |
| 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评分)"` | ||
| 16 | - Rating *domain.Rating `comment:"评级"` | ||
| 17 | - Score *domain.Score `comment:"评分"` | 15 | + Type int `comment:"评估方式(0评级、1评分)" pg:",use_zero"` |
| 16 | + Rating domain.Rating `comment:"评级"` | ||
| 17 | + Score domain.Score `comment:"评分"` | ||
| 18 | CreatedAt time.Time `comment:"创建时间"` | 18 | CreatedAt time.Time `comment:"创建时间"` |
| 19 | UpdatedAt time.Time `comment:"更新时间"` | 19 | UpdatedAt time.Time `comment:"更新时间"` |
| 20 | - DeletedAt *time.Time `comment:"删除时间"` | 20 | + DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` |
| 21 | } | 21 | } |
| @@ -6,13 +6,13 @@ import ( | @@ -6,13 +6,13 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type EvaluationTemplate struct { | 8 | type EvaluationTemplate struct { |
| 9 | - tableName struct{} `pg:"evaluation_template" comment:"评估模板"` | ||
| 10 | - Id int64 `comment:"ID"` | 9 | + tableName struct{} `comment:"评估模板" pg:"evaluation_template"` |
| 10 | + Id int64 `comment:"ID" pg:"pk:id"` | ||
| 11 | Name string `comment:"名称"` | 11 | Name string `comment:"名称"` |
| 12 | Describe string `comment:"描述"` | 12 | Describe string `comment:"描述"` |
| 13 | CompanyId int64 `comment:"公司ID"` | 13 | CompanyId int64 `comment:"公司ID"` |
| 14 | CreatorId int64 `comment:"创建人ID"` | 14 | CreatorId int64 `comment:"创建人ID"` |
| 15 | - State int `comment:"状态(0待完成配置、1待启用、2启用、3停用)"` | 15 | + State int `comment:"状态(0待完成配置、1待启用、2启用、3停用)" pg:",use_zero"` |
| 16 | LinkNodes []*domain.LinkNode `comment:"评估流程"` | 16 | LinkNodes []*domain.LinkNode `comment:"评估流程"` |
| 17 | CreatedAt time.Time `comment:"创建时间"` | 17 | CreatedAt time.Time `comment:"创建时间"` |
| 18 | UpdatedAt time.Time `comment:"更新时间"` | 18 | UpdatedAt time.Time `comment:"更新时间"` |
| @@ -6,7 +6,7 @@ type Role struct { | @@ -6,7 +6,7 @@ type Role struct { | ||
| 6 | tableName struct{} `pg:"role" comment:"角色"` | 6 | tableName struct{} `pg:"role" comment:"角色"` |
| 7 | Id int64 `pg:"pk:id" comment:"ID"` | 7 | Id int64 `pg:"pk:id" comment:"ID"` |
| 8 | Name string `comment:"角色名称"` | 8 | Name string `comment:"角色名称"` |
| 9 | - Type int `comment:"角色类型(0角色可删、1系统预置角色不可删)"` | 9 | + Type int `comment:"角色类型(0角色可删、1系统预置角色不可删)" pg:",use_zero"` |
| 10 | Description string `comment:"角色描述"` | 10 | Description string `comment:"角色描述"` |
| 11 | CompanyId int64 `comment:"公司ID"` | 11 | CompanyId int64 `comment:"公司ID"` |
| 12 | CreatedAt time.Time `comment:"创建时间"` | 12 | CreatedAt time.Time `comment:"创建时间"` |
pkg/infrastructure/pg/models/staff_assess.go
0 → 100644
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "time" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +// 记录用户需要的评估项 | ||
| 10 | +type StaffAssess struct { | ||
| 11 | + tableName struct{} `pg:"staff_assess" comment:"记录用户需要的评估项"` | ||
| 12 | + Id int `pg:",pk"` //id | ||
| 13 | + CompanyId int `comment:"公司id"` //公司id | ||
| 14 | + EvaluationProjectId int `comment:"对应的项目id"` //对应的项目id | ||
| 15 | + EvaluationProjectName string | ||
| 16 | + CycleId int64 `comment:"对应的周期id"` //对应的周期id | ||
| 17 | + CycleName string | ||
| 18 | + StaffAssessTaskId int | ||
| 19 | + TargetUser domain.StaffDesc `comment:"被评估的目标用户"` //被评估的目标用户 | ||
| 20 | + TargetDepartment []domain.StaffDepartment `comment:"被评估的用户所在的部门"` //被评估的用户所在的部门 | ||
| 21 | + Executor domain.StaffDesc `comment:"填写评估的用户"` //填写评估的用户 | ||
| 22 | + Types string `comment:"填写评估对应的类型"` //填写评估对应的类型 | ||
| 23 | + LinkNodeId int `comment:"评估环节id"` | ||
| 24 | + LinkNodeName string | ||
| 25 | + Status string `comment:"评估的填写状态"` //评估的填写状态 | ||
| 26 | + BeginTime time.Time `comment:"开始时间"` //开始时间 | ||
| 27 | + EndTime time.Time `comment:"截止时间"` //截止时间 | ||
| 28 | + CreatedAt time.Time `comment:"数据创建时间"` //数据创建时间 | ||
| 29 | + UpdatedAt time.Time `comment:"数据更新时间"` //数据更新时间 | ||
| 30 | + DeletedAt *time.Time `comment:"数据删除时间"` //数据删除时间 | ||
| 31 | +} |
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import "time" | ||
| 4 | + | ||
| 5 | +//填写的评估内容 | ||
| 6 | +type StaffAssessContent struct { | ||
| 7 | + tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"` | ||
| 8 | + Id int `pg:",pk"` //id | ||
| 9 | + StaffAssessId int //用户需要的评估项id | ||
| 10 | + SortBy int //排序 | ||
| 11 | + Category string //类别 | ||
| 12 | + Title string //问题标题 | ||
| 13 | + Remark string //填写的反馈 | ||
| 14 | + Rate string //评估填写的值 | ||
| 15 | + ReteResult string //评估的结果 | ||
| 16 | + CreatedAt time.Time //数据创建时间 | ||
| 17 | + UpdatedAt time.Time //数据更新时间 | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +type StaffAssessContentRepository interface { | ||
| 21 | + Save(param *StaffAssessContent) (*StaffAssessContent, error) | ||
| 22 | + Remove(id int) error | ||
| 23 | + FindOne(queryOptions map[string]interface{}) (*StaffAssessContent, error) | ||
| 24 | + Find(queryOptions map[string]interface{}) (int, []*StaffAssessContent, error) | ||
| 25 | +} |
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "time" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +// 执行评估的任务列表 | ||
| 10 | +type StaffAssessTask struct { | ||
| 11 | + tableName struct{} `pg:"staff_assess_task" comment:"执行评估的任务列表"` | ||
| 12 | + Id int `pg:",pk"` | ||
| 13 | + CompanyId int `` //公司id | ||
| 14 | + EvaluationProjectId int `` //项目id | ||
| 15 | + EvaluationProjectName string `` //项目名称 | ||
| 16 | + CycleId int64 //对应的周期id | ||
| 17 | + CycleName string //对应周期的名称 | ||
| 18 | + ExecutorId []int //参与考评的人 | ||
| 19 | + StepList []domain.AssessTaskStep `` //考评的流程 | ||
| 20 | + BeginTime time.Time //开始时间 | ||
| 21 | + EndTime time.Time //截止时间 | ||
| 22 | + CreatedAt time.Time //数据创建时间 | ||
| 23 | + UpdatedAt time.Time //数据更新时间 | ||
| 24 | + DeletedAt *time.Time //数据删除时间 | ||
| 25 | +} |
| @@ -91,9 +91,8 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( | @@ -91,9 +91,8 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( | ||
| 91 | 91 | ||
| 92 | func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) { | 92 | func (repo *DepartmentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.Department, error) { |
| 93 | tx := repo.transactionContext.PgTx | 93 | tx := repo.transactionContext.PgTx |
| 94 | - var dparmentModel []models.Department | ||
| 95 | - query := tx.Model(&dparmentModel). | ||
| 96 | - Limit(20) | 94 | + dparmentModel := []models.Department{} |
| 95 | + query := tx.Model(&dparmentModel).Where("delete_at isnull") | ||
| 97 | if v, ok := queryOptions["id"]; ok { | 96 | if v, ok := queryOptions["id"]; ok { |
| 98 | query.Where("id=?", v) | 97 | query.Where("id=?", v) |
| 99 | } | 98 | } |
| @@ -3,13 +3,14 @@ package repository | @@ -3,13 +3,14 @@ package repository | ||
| 3 | import ( | 3 | import ( |
| 4 | "errors" | 4 | "errors" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + "time" | ||
| 7 | + | ||
| 6 | "github.com/go-pg/pg/v10" | 8 | "github.com/go-pg/pg/v10" |
| 7 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" | 9 | "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" |
| 8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 10 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" | 13 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" |
| 12 | - "time" | ||
| 13 | ) | 14 | ) |
| 14 | 15 | ||
| 15 | type EvaluationCycleRepository struct { | 16 | type EvaluationCycleRepository struct { |
| @@ -133,6 +134,16 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | @@ -133,6 +134,16 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{}) | ||
| 133 | query.Offset(v) | 134 | query.Offset(v) |
| 134 | } | 135 | } |
| 135 | 136 | ||
| 137 | + if v, ok := queryOptions["timeStart"]; ok { | ||
| 138 | + t := v.(time.Time) | ||
| 139 | + query.Where("time_start<=?", t) | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + if v, ok := queryOptions["timeEnd"]; ok { | ||
| 143 | + t := v.(time.Time) | ||
| 144 | + query.Where("time_end>=?", t) | ||
| 145 | + } | ||
| 146 | + | ||
| 136 | count, err := query.SelectAndCount() | 147 | count, err := query.SelectAndCount() |
| 137 | if err != nil { | 148 | if err != nil { |
| 138 | return 0, nil, err | 149 | return 0, nil, err |
| @@ -58,9 +58,14 @@ func (repo *EvaluationCycleTemplateRepository) Insert(d *domain.EvaluationCycleT | @@ -58,9 +58,14 @@ func (repo *EvaluationCycleTemplateRepository) Insert(d *domain.EvaluationCycleT | ||
| 58 | d.Id = id | 58 | d.Id = id |
| 59 | d.CreatedAt = time.Now() | 59 | d.CreatedAt = time.Now() |
| 60 | d.UpdatedAt = d.CreatedAt | 60 | d.UpdatedAt = d.CreatedAt |
| 61 | + // 模板对象ID也更新 | ||
| 62 | + if d.Template != nil { | ||
| 63 | + d.Template.Id = id | ||
| 64 | + } | ||
| 61 | } else { | 65 | } else { |
| 62 | d.UpdatedAt = time.Now() | 66 | d.UpdatedAt = time.Now() |
| 63 | } | 67 | } |
| 68 | + | ||
| 64 | m := repo.TransformToModel(d) | 69 | m := repo.TransformToModel(d) |
| 65 | tx := repo.transactionContext.PgTx | 70 | tx := repo.transactionContext.PgTx |
| 66 | var err error | 71 | var err error |
| @@ -123,6 +123,10 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -123,6 +123,10 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
| 123 | query.Where("name LIKE ? or remark LIKE ?", v, v) | 123 | query.Where("name LIKE ? or remark LIKE ?", v, v) |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | + if v, ok := queryOptions["ids"]; ok { | ||
| 127 | + query.Where("id in(?)", pg.In(v)) | ||
| 128 | + } | ||
| 129 | + | ||
| 126 | if v, ok := queryOptions["name"]; ok { | 130 | if v, ok := queryOptions["name"]; ok { |
| 127 | query.Where("name = ?", v) | 131 | query.Where("name = ?", v) |
| 128 | } | 132 | } |
| @@ -131,6 +135,14 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | @@ -131,6 +135,14 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{}) | ||
| 131 | query.Where("company_id = ?", v) | 135 | query.Where("company_id = ?", v) |
| 132 | } | 136 | } |
| 133 | 137 | ||
| 138 | + if v, ok := queryOptions["creatorId"]; ok && v.(int64) > 0 { | ||
| 139 | + query.Where("creator_id = ?", v) | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + if v, ok := queryOptions["type"]; ok && v.(int) >= 0 { | ||
| 143 | + query.Where("type = ?", v) | ||
| 144 | + } | ||
| 145 | + | ||
| 134 | if v, ok := queryOptions["limit"].(int); ok { | 146 | if v, ok := queryOptions["limit"].(int); ok { |
| 135 | query.Limit(v) | 147 | query.Limit(v) |
| 136 | } | 148 | } |
| @@ -125,6 +125,10 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -125,6 +125,10 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | ||
| 125 | query.Where("id in(?)", pg.In(v)) | 125 | query.Where("id in(?)", pg.In(v)) |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | + if v, ok := queryOptions["notId"]; ok { | ||
| 129 | + query.Where("id != ?", v) | ||
| 130 | + } | ||
| 131 | + | ||
| 128 | if v, ok := queryOptions["name"]; ok && len(v.(string)) > 0 { | 132 | if v, ok := queryOptions["name"]; ok && len(v.(string)) > 0 { |
| 129 | query.Where("name LIKE ?", v) | 133 | query.Where("name LIKE ?", v) |
| 130 | } | 134 | } |
| @@ -133,10 +137,14 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | @@ -133,10 +137,14 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface | ||
| 133 | query.Where("company_id = ?", v) | 137 | query.Where("company_id = ?", v) |
| 134 | } | 138 | } |
| 135 | 139 | ||
| 136 | - if v, ok := queryOptions["state"]; ok { | 140 | + if v, ok := queryOptions["state"]; ok && v.(int) >= 0 { |
| 137 | query.Where("state = ?", v) | 141 | query.Where("state = ?", v) |
| 138 | } | 142 | } |
| 139 | 143 | ||
| 144 | + if v, ok := queryOptions["createdAt"]; ok { | ||
| 145 | + query.Where("created_at = ?", v) | ||
| 146 | + } | ||
| 147 | + | ||
| 140 | if v, ok := queryOptions["limit"].(int); ok { | 148 | if v, ok := queryOptions["limit"].(int); ok { |
| 141 | query.Limit(v) | 149 | query.Limit(v) |
| 142 | } | 150 | } |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "errors" | ||
| 5 | + "fmt" | ||
| 6 | + "time" | ||
| 7 | + | ||
| 8 | + "github.com/go-pg/pg/v10" | ||
| 9 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type StaffAssessContentRepository struct { | ||
| 15 | + transactionContext *pgTransaction.TransactionContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var _ domain.StaffAssessContentRepository = (*StaffAssessContentRepository)(nil) | ||
| 19 | + | ||
| 20 | +func NewStaffAssessContentRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentRepository { | ||
| 21 | + return &StaffAssessContentRepository{transactionContext: transactionContext} | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAssessContent) *domain.StaffAssessContent { | ||
| 25 | + return &domain.StaffAssessContent{} | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*domain.StaffAssessContent, error) { | ||
| 29 | + saveModel := models.StaffAssess{ | ||
| 30 | + Id: d.Id, | ||
| 31 | + } | ||
| 32 | + tx := repo.transactionContext.PgTx | ||
| 33 | + var err error | ||
| 34 | + if saveModel.Id == 0 { | ||
| 35 | + _, err = tx.Model(&saveModel).Insert() | ||
| 36 | + if err != nil { | ||
| 37 | + return nil, err | ||
| 38 | + } | ||
| 39 | + } else { | ||
| 40 | + _, err = tx.Model(&saveModel).WherePK().Update() | ||
| 41 | + if err != nil { | ||
| 42 | + return nil, err | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + d.Id = saveModel.Id | ||
| 46 | + return d, nil | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +func (repo *StaffAssessContentRepository) Remove(id int) error { | ||
| 50 | + tx := repo.transactionContext.PgTx | ||
| 51 | + nowTime := time.Now() | ||
| 52 | + _, err := tx.Model(&models.StaffAssessContent{}). | ||
| 53 | + Where("id=?", id). | ||
| 54 | + Set("deleted_at=?", nowTime). | ||
| 55 | + Update() | ||
| 56 | + return err | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +func (repo *StaffAssessContentRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssessContent, error) { | ||
| 60 | + tx := repo.transactionContext.PgTx | ||
| 61 | + m := new(models.StaffAssessContent) | ||
| 62 | + query := tx.Model(m) | ||
| 63 | + query.Where("deleted_at isnull") | ||
| 64 | + if id, ok := queryOptions["id"]; ok { | ||
| 65 | + query.Where("id=?", id) | ||
| 66 | + } | ||
| 67 | + if err := query.First(); err != nil { | ||
| 68 | + if errors.Is(err, pg.ErrNoRows) { | ||
| 69 | + return nil, fmt.Errorf("没有此资源") | ||
| 70 | + } else { | ||
| 71 | + return nil, err | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + u := repo.TransformToDomain(m) | ||
| 75 | + return u, nil | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssessContent, error) { | ||
| 79 | + tx := repo.transactionContext.PgTx | ||
| 80 | + var m []*models.StaffAssessContent | ||
| 81 | + query := tx.Model(&m). | ||
| 82 | + Where("deleted_at isnull").Limit(20) | ||
| 83 | + if companyId, ok := queryOptions["companyId"]; ok { | ||
| 84 | + query.Where("company_id = ?", companyId) | ||
| 85 | + } | ||
| 86 | + if v, ok := queryOptions["limit"].(int); ok { | ||
| 87 | + query.Limit(v) | ||
| 88 | + } | ||
| 89 | + if v, ok := queryOptions["offset"].(int); ok { | ||
| 90 | + query.Offset(v) | ||
| 91 | + } | ||
| 92 | + if v, ok := queryOptions["staffAssessId"]; ok { | ||
| 93 | + query.Where("staff_assess_id=?", v) | ||
| 94 | + } | ||
| 95 | + count, err := query.SelectAndCount() | ||
| 96 | + if err != nil { | ||
| 97 | + return 0, nil, err | ||
| 98 | + } | ||
| 99 | + var arrays []*domain.StaffAssessContent | ||
| 100 | + for _, v := range m { | ||
| 101 | + d := repo.TransformToDomain(v) | ||
| 102 | + arrays = append(arrays, d) | ||
| 103 | + } | ||
| 104 | + return count, arrays, nil | ||
| 105 | +} |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "errors" | ||
| 5 | + "fmt" | ||
| 6 | + "time" | ||
| 7 | + | ||
| 8 | + "github.com/go-pg/pg/v10" | ||
| 9 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type StaffAssessRepository struct { | ||
| 15 | + transactionContext *pgTransaction.TransactionContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var _ domain.StaffAssessRepository = (*StaffAssessRepository)(nil) | ||
| 19 | + | ||
| 20 | +func NewStaffAssessRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessRepository { | ||
| 21 | + return &StaffAssessRepository{transactionContext: transactionContext} | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func (repo *StaffAssessRepository) TransformToDomain(d *models.StaffAssess) *domain.StaffAssess { | ||
| 25 | + return &domain.StaffAssess{ | ||
| 26 | + Id: d.Id, | ||
| 27 | + CompanyId: d.CompanyId, | ||
| 28 | + EvaluationProjectId: d.EvaluationProjectId, | ||
| 29 | + EvaluationProjectName: d.EvaluationProjectName, | ||
| 30 | + CycleId: d.CycleId, | ||
| 31 | + CycleName: d.CycleName, | ||
| 32 | + StaffAssessTaskId: d.StaffAssessTaskId, | ||
| 33 | + TargetUser: d.TargetUser, | ||
| 34 | + TargetDepartment: d.TargetDepartment, | ||
| 35 | + Executor: d.Executor, | ||
| 36 | + Types: domain.StaffAssessType(d.Types), | ||
| 37 | + LinkNodeId: d.LinkNodeId, | ||
| 38 | + LinkNodeName: d.LinkNodeName, | ||
| 39 | + Status: domain.StaffAssessStatus(d.Status), | ||
| 40 | + BeginTime: d.BeginTime, | ||
| 41 | + EndTime: d.EndTime, | ||
| 42 | + CreatedAt: d.EndTime, | ||
| 43 | + UpdatedAt: d.CreatedAt, | ||
| 44 | + DeletedAt: d.DeletedAt, | ||
| 45 | + } | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +func (repo *StaffAssessRepository) Save(d *domain.StaffAssess) (*domain.StaffAssess, error) { | ||
| 49 | + saveModel := models.StaffAssess{ | ||
| 50 | + Id: d.Id, | ||
| 51 | + CompanyId: d.CompanyId, | ||
| 52 | + EvaluationProjectId: d.EvaluationProjectId, | ||
| 53 | + EvaluationProjectName: d.EvaluationProjectName, | ||
| 54 | + CycleId: d.CycleId, | ||
| 55 | + CycleName: d.CycleName, | ||
| 56 | + StaffAssessTaskId: d.StaffAssessTaskId, | ||
| 57 | + TargetUser: d.TargetUser, | ||
| 58 | + TargetDepartment: d.TargetDepartment, | ||
| 59 | + Executor: d.Executor, | ||
| 60 | + Types: string(d.Types), | ||
| 61 | + LinkNodeId: d.LinkNodeId, | ||
| 62 | + LinkNodeName: d.LinkNodeName, | ||
| 63 | + Status: string(d.Status), | ||
| 64 | + BeginTime: d.BeginTime, | ||
| 65 | + EndTime: d.EndTime, | ||
| 66 | + CreatedAt: d.EndTime, | ||
| 67 | + UpdatedAt: d.CreatedAt, | ||
| 68 | + DeletedAt: d.DeletedAt, | ||
| 69 | + } | ||
| 70 | + tx := repo.transactionContext.PgTx | ||
| 71 | + var err error | ||
| 72 | + if saveModel.Id == 0 { | ||
| 73 | + _, err = tx.Model(&saveModel).Insert() | ||
| 74 | + if err != nil { | ||
| 75 | + return nil, err | ||
| 76 | + } | ||
| 77 | + } else { | ||
| 78 | + _, err = tx.Model(&saveModel).WherePK().Update() | ||
| 79 | + if err != nil { | ||
| 80 | + return nil, err | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + d.Id = saveModel.Id | ||
| 84 | + return d, nil | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +func (repo *StaffAssessRepository) Remove(id int) error { | ||
| 88 | + tx := repo.transactionContext.PgTx | ||
| 89 | + nowTime := time.Now() | ||
| 90 | + _, err := tx.Model(&models.StaffAssess{}). | ||
| 91 | + Where("id=?", id). | ||
| 92 | + Set("deleted_at=?", nowTime). | ||
| 93 | + Update() | ||
| 94 | + return err | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +func (repo *StaffAssessRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssess, error) { | ||
| 98 | + tx := repo.transactionContext.PgTx | ||
| 99 | + m := new(models.StaffAssess) | ||
| 100 | + query := tx.Model(m) | ||
| 101 | + query.Where("deleted_at isnull") | ||
| 102 | + if id, ok := queryOptions["id"]; ok { | ||
| 103 | + query.Where("id=?", id) | ||
| 104 | + } | ||
| 105 | + if err := query.First(); err != nil { | ||
| 106 | + if errors.Is(err, pg.ErrNoRows) { | ||
| 107 | + return nil, fmt.Errorf("没有此资源") | ||
| 108 | + } else { | ||
| 109 | + return nil, err | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + u := repo.TransformToDomain(m) | ||
| 113 | + return u, nil | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssess, error) { | ||
| 117 | + tx := repo.transactionContext.PgTx | ||
| 118 | + var m []*models.StaffAssess | ||
| 119 | + query := tx.Model(&m). | ||
| 120 | + Where("deleted_at isnull") | ||
| 121 | + if companyId, ok := queryOptions["companyId"]; ok { | ||
| 122 | + query.Where("company_id = ?", companyId) | ||
| 123 | + } | ||
| 124 | + if v, ok := queryOptions["limit"].(int); ok { | ||
| 125 | + query.Limit(v) | ||
| 126 | + } | ||
| 127 | + if v, ok := queryOptions["offset"].(int); ok { | ||
| 128 | + query.Offset(v) | ||
| 129 | + } | ||
| 130 | + if v, ok := queryOptions["targetUserId"].(int); ok && v > 0 { | ||
| 131 | + query.Where(`target_user->>'userId'='?'`, v) | ||
| 132 | + } | ||
| 133 | + if v, ok := queryOptions["executorId"].(int); ok && v > 0 { | ||
| 134 | + query.Where(`executor->>'userId'='?'`, v) | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + if v, ok := queryOptions["cycleId"].(int64); ok && v > 0 { | ||
| 138 | + query.Where(`cycle_id=?`, v) | ||
| 139 | + } | ||
| 140 | + if v, ok := queryOptions["staffAssessTaskId"]; ok { | ||
| 141 | + query.Where(`staff_assess_task_id=?`, v) | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + if v, ok := queryOptions["typesList"].([]string); ok && len(v) > 0 { | ||
| 145 | + query.Where("types in(?)", pg.In(v)) | ||
| 146 | + } | ||
| 147 | + if v, ok := queryOptions["status"].(string); ok && len(v) > 0 { | ||
| 148 | + query.Where("status=?", v) | ||
| 149 | + } | ||
| 150 | + count, err := query.SelectAndCount() | ||
| 151 | + if err != nil { | ||
| 152 | + return 0, nil, err | ||
| 153 | + } | ||
| 154 | + var arrays []*domain.StaffAssess | ||
| 155 | + for _, v := range m { | ||
| 156 | + d := repo.TransformToDomain(v) | ||
| 157 | + arrays = append(arrays, d) | ||
| 158 | + } | ||
| 159 | + return count, arrays, nil | ||
| 160 | +} |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "errors" | ||
| 5 | + "fmt" | ||
| 6 | + "time" | ||
| 7 | + | ||
| 8 | + "github.com/go-pg/pg/v10" | ||
| 9 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type StaffAssessTaskRepository struct { | ||
| 15 | + transactionContext *pgTransaction.TransactionContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var _ domain.StaffAssessTaskRepository = (*StaffAssessTaskRepository)(nil) | ||
| 19 | + | ||
| 20 | +func NewStaffAssessTaskRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessTaskRepository { | ||
| 21 | + return &StaffAssessTaskRepository{transactionContext: transactionContext} | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTask) *domain.StaffAssessTask { | ||
| 25 | + return &domain.StaffAssessTask{ | ||
| 26 | + Id: d.Id, | ||
| 27 | + CompanyId: d.CompanyId, | ||
| 28 | + EvaluationProjectId: d.EvaluationProjectId, | ||
| 29 | + EvaluationProjectName: d.EvaluationProjectName, | ||
| 30 | + CycleId: d.CycleId, | ||
| 31 | + CycleName: d.CycleName, | ||
| 32 | + BeginTime: d.BeginTime, | ||
| 33 | + EndTime: d.EndTime, | ||
| 34 | + StepList: d.StepList, | ||
| 35 | + ExecutorId: d.ExecutorId, | ||
| 36 | + CreatedAt: d.EndTime, | ||
| 37 | + UpdatedAt: d.CreatedAt, | ||
| 38 | + DeletedAt: d.DeletedAt, | ||
| 39 | + } | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain.StaffAssessTask, error) { | ||
| 43 | + saveModel := models.StaffAssessTask{ | ||
| 44 | + Id: d.Id, | ||
| 45 | + CompanyId: d.CompanyId, | ||
| 46 | + EvaluationProjectId: d.EvaluationProjectId, | ||
| 47 | + EvaluationProjectName: d.EvaluationProjectName, | ||
| 48 | + CycleId: d.CycleId, | ||
| 49 | + CycleName: d.CycleName, | ||
| 50 | + ExecutorId: d.ExecutorId, | ||
| 51 | + StepList: d.StepList, | ||
| 52 | + BeginTime: d.BeginTime, | ||
| 53 | + EndTime: d.EndTime, | ||
| 54 | + CreatedAt: d.EndTime, | ||
| 55 | + UpdatedAt: d.CreatedAt, | ||
| 56 | + DeletedAt: d.DeletedAt, | ||
| 57 | + } | ||
| 58 | + tx := repo.transactionContext.PgTx | ||
| 59 | + var err error | ||
| 60 | + if saveModel.Id == 0 { | ||
| 61 | + _, err = tx.Model(&saveModel).Insert() | ||
| 62 | + if err != nil { | ||
| 63 | + return nil, err | ||
| 64 | + } | ||
| 65 | + } else { | ||
| 66 | + _, err = tx.Model(&saveModel).WherePK().Update() | ||
| 67 | + if err != nil { | ||
| 68 | + return nil, err | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + d.Id = saveModel.Id | ||
| 72 | + return d, nil | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +func (repo *StaffAssessTaskRepository) Remove(id int) error { | ||
| 76 | + tx := repo.transactionContext.PgTx | ||
| 77 | + nowTime := time.Now() | ||
| 78 | + _, err := tx.Model(&models.StaffAssessTask{}). | ||
| 79 | + Where("id=?", id). | ||
| 80 | + Set("deleted_at=?", nowTime). | ||
| 81 | + Update() | ||
| 82 | + return err | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +func (repo *StaffAssessTaskRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssessTask, error) { | ||
| 86 | + tx := repo.transactionContext.PgTx | ||
| 87 | + m := new(models.StaffAssessTask) | ||
| 88 | + query := tx.Model(m) | ||
| 89 | + query.Where("deleted_at isnull") | ||
| 90 | + if id, ok := queryOptions["id"]; ok { | ||
| 91 | + query.Where("id=?", id) | ||
| 92 | + } | ||
| 93 | + if err := query.First(); err != nil { | ||
| 94 | + if errors.Is(err, pg.ErrNoRows) { | ||
| 95 | + return nil, fmt.Errorf("没有此资源") | ||
| 96 | + } else { | ||
| 97 | + return nil, err | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + u := repo.TransformToDomain(m) | ||
| 101 | + return u, nil | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssessTask, error) { | ||
| 105 | + tx := repo.transactionContext.PgTx | ||
| 106 | + var m []*models.StaffAssessTask | ||
| 107 | + query := tx.Model(&m). | ||
| 108 | + Where("deleted_at isnull").Limit(20) | ||
| 109 | + if companyId, ok := queryOptions["companyId"]; ok { | ||
| 110 | + query.Where("company_id = ?", companyId) | ||
| 111 | + } | ||
| 112 | + if v, ok := queryOptions["limit"].(int); ok { | ||
| 113 | + query.Limit(v) | ||
| 114 | + } | ||
| 115 | + if v, ok := queryOptions["offset"].(int); ok { | ||
| 116 | + query.Offset(v) | ||
| 117 | + } | ||
| 118 | + if v, ok := queryOptions["executorId"].(int); ok && v > 0 { | ||
| 119 | + query.Where(`executor_id @>'[?]'`, v) | ||
| 120 | + } | ||
| 121 | + count, err := query.SelectAndCount() | ||
| 122 | + if err != nil { | ||
| 123 | + return 0, nil, err | ||
| 124 | + } | ||
| 125 | + var arrays []*domain.StaffAssessTask | ||
| 126 | + for _, v := range m { | ||
| 127 | + d := repo.TransformToDomain(v) | ||
| 128 | + arrays = append(arrays, d) | ||
| 129 | + } | ||
| 130 | + return count, arrays, nil | ||
| 131 | +} |
| @@ -77,7 +77,7 @@ func (repo *UserRepository) Remove(userId []int64) error { | @@ -77,7 +77,7 @@ func (repo *UserRepository) Remove(userId []int64) error { | ||
| 77 | func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domain.User, error) { | 77 | func (repo *UserRepository) FindOne(queryOptions map[string]interface{}) (*domain.User, error) { |
| 78 | tx := repo.transactionContext.PgTx | 78 | tx := repo.transactionContext.PgTx |
| 79 | userModel := models.User{} | 79 | userModel := models.User{} |
| 80 | - query := tx.Model(&userModel) | 80 | + query := tx.Model(&userModel).Where("deleted_at isnull") |
| 81 | if v, ok := queryOptions["id"]; ok { | 81 | if v, ok := queryOptions["id"]; ok { |
| 82 | query.Where("id=?", v) | 82 | query.Where("id=?", v) |
| 83 | } | 83 | } |
| @@ -12,14 +12,17 @@ type CycleController struct { | @@ -12,14 +12,17 @@ type CycleController struct { | ||
| 12 | beego.BaseController | 12 | beego.BaseController |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | -func (controller *RoleController) CreateCycle() { | 15 | +func (controller *CycleController) CreateCycle() { |
| 16 | ruService := service.NewEvaluationCycleService() | 16 | ruService := service.NewEvaluationCycleService() |
| 17 | in := &command.CreateCycleCommand{} | 17 | in := &command.CreateCycleCommand{} |
| 18 | if err := controller.Unmarshal(in); err != nil { | 18 | if err := controller.Unmarshal(in); err != nil { |
| 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 20 | } else { | 20 | } else { |
| 21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 22 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 21 | + ua := middlewares.GetUser(controller.Ctx) |
| 22 | + in.CompanyId = ua.CompanyId | ||
| 23 | + in.CreatorId = ua.UserId | ||
| 24 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 25 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
| 23 | controller.Response(ruService.Create(in)) | 26 | controller.Response(ruService.Create(in)) |
| 24 | } | 27 | } |
| 25 | } | 28 | } |
| @@ -30,7 +33,9 @@ func (controller *CycleController) UpdateCycle() { | @@ -30,7 +33,9 @@ func (controller *CycleController) UpdateCycle() { | ||
| 30 | if err := controller.Unmarshal(in); err != nil { | 33 | if err := controller.Unmarshal(in); err != nil { |
| 31 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 34 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 32 | } else { | 35 | } else { |
| 33 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 36 | + ua := middlewares.GetUser(controller.Ctx) |
| 37 | + in.CompanyId = ua.CompanyId | ||
| 38 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 34 | controller.Response(ruService.Update(in)) | 39 | controller.Response(ruService.Update(in)) |
| 35 | } | 40 | } |
| 36 | } | 41 | } |
| @@ -65,7 +70,20 @@ func (controller *CycleController) ListCycle() { | @@ -65,7 +70,20 @@ func (controller *CycleController) ListCycle() { | ||
| 65 | if len(in.Name) > 0 { | 70 | if len(in.Name) > 0 { |
| 66 | in.Name = "%" + in.Name + "%" | 71 | in.Name = "%" + in.Name + "%" |
| 67 | } | 72 | } |
| 68 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 73 | + ua := middlewares.GetUser(controller.Ctx) |
| 74 | + in.CompanyId = ua.CompanyId | ||
| 69 | controller.Response(ruService.List(in)) | 75 | controller.Response(ruService.List(in)) |
| 70 | } | 76 | } |
| 71 | } | 77 | } |
| 78 | + | ||
| 79 | +func (controller *CycleController) StatisticCycleUser() { | ||
| 80 | + ruService := service.NewEvaluationCycleService() | ||
| 81 | + in := &command.StatisticCycleProjectUserCommand{} | ||
| 82 | + if err := controller.Unmarshal(in); err != nil { | ||
| 83 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 84 | + } else { | ||
| 85 | + ua := middlewares.GetUser(controller.Ctx) | ||
| 86 | + in.CompanyId = ua.CompanyId | ||
| 87 | + controller.Response(ruService.StatisticCycleUser(in)) | ||
| 88 | + } | ||
| 89 | +} |
| @@ -12,14 +12,17 @@ type ProjectController struct { | @@ -12,14 +12,17 @@ type ProjectController struct { | ||
| 12 | beego.BaseController | 12 | beego.BaseController |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | -func (controller *RoleController) CreateProject() { | 15 | +func (controller *ProjectController) CreateProject() { |
| 16 | ruService := service.NewEvaluationProjectService() | 16 | ruService := service.NewEvaluationProjectService() |
| 17 | in := &command.CreateProjectCommand{} | 17 | in := &command.CreateProjectCommand{} |
| 18 | if err := controller.Unmarshal(in); err != nil { | 18 | if err := controller.Unmarshal(in); err != nil { |
| 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 20 | } else { | 20 | } else { |
| 21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 22 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 21 | + ua := middlewares.GetUser(controller.Ctx) |
| 22 | + in.CompanyId = ua.CompanyId | ||
| 23 | + in.CreatorId = ua.UserId | ||
| 24 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 25 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
| 23 | controller.Response(ruService.Create(in)) | 26 | controller.Response(ruService.Create(in)) |
| 24 | } | 27 | } |
| 25 | } | 28 | } |
| @@ -30,7 +33,9 @@ func (controller *ProjectController) UpdateProject() { | @@ -30,7 +33,9 @@ func (controller *ProjectController) UpdateProject() { | ||
| 30 | if err := controller.Unmarshal(in); err != nil { | 33 | if err := controller.Unmarshal(in); err != nil { |
| 31 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 34 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 32 | } else { | 35 | } else { |
| 33 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 36 | + ua := middlewares.GetUser(controller.Ctx) |
| 37 | + in.CompanyId = ua.CompanyId | ||
| 38 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 34 | controller.Response(ruService.Update(in)) | 39 | controller.Response(ruService.Update(in)) |
| 35 | } | 40 | } |
| 36 | } | 41 | } |
| @@ -41,22 +46,13 @@ func (controller *ProjectController) UpdateProjectForTemplate() { | @@ -41,22 +46,13 @@ func (controller *ProjectController) UpdateProjectForTemplate() { | ||
| 41 | if err := controller.Unmarshal(in); err != nil { | 46 | if err := controller.Unmarshal(in); err != nil { |
| 42 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 47 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 43 | } else { | 48 | } else { |
| 44 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 49 | + ua := middlewares.GetUser(controller.Ctx) |
| 50 | + in.CompanyId = ua.CompanyId | ||
| 51 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 45 | controller.Response(ruService.UpdateTemplate(in)) | 52 | controller.Response(ruService.UpdateTemplate(in)) |
| 46 | } | 53 | } |
| 47 | } | 54 | } |
| 48 | 55 | ||
| 49 | -func (controller *ProjectController) UpdateProjectForTemplateNode() { | ||
| 50 | - ruService := service.NewEvaluationProjectService() | ||
| 51 | - in := &command.UpdateProjectTemplateNodeCommand{} | ||
| 52 | - if err := controller.Unmarshal(in); err != nil { | ||
| 53 | - controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 54 | - } else { | ||
| 55 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 56 | - controller.Response(ruService.UpdateTemplateNode(in)) | ||
| 57 | - } | ||
| 58 | -} | ||
| 59 | - | ||
| 60 | func (controller *ProjectController) GetProject() { | 56 | func (controller *ProjectController) GetProject() { |
| 61 | ruService := service.NewEvaluationProjectService() | 57 | ruService := service.NewEvaluationProjectService() |
| 62 | in := &command.GetProjectCommand{} | 58 | in := &command.GetProjectCommand{} |
| @@ -88,18 +84,20 @@ func (controller *ProjectController) ListProject() { | @@ -88,18 +84,20 @@ func (controller *ProjectController) ListProject() { | ||
| 88 | if len(in.Name) > 0 { | 84 | if len(in.Name) > 0 { |
| 89 | in.Name = "%" + in.Name + "%" | 85 | in.Name = "%" + in.Name + "%" |
| 90 | } | 86 | } |
| 91 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 87 | + ua := middlewares.GetUser(controller.Ctx) |
| 88 | + in.CompanyId = ua.CompanyId | ||
| 89 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 92 | controller.Response(ruService.List(in)) | 90 | controller.Response(ruService.List(in)) |
| 93 | } | 91 | } |
| 94 | } | 92 | } |
| 95 | 93 | ||
| 96 | -func (controller *ProjectController) StateProject() { | 94 | +func (controller *ProjectController) ActivateProject() { |
| 97 | ruService := service.NewEvaluationProjectService() | 95 | ruService := service.NewEvaluationProjectService() |
| 98 | - in := &command.StateProjectCommand{} | 96 | + in := &command.ActivateProjectCommand{} |
| 99 | if err := controller.Unmarshal(in); err != nil { | 97 | if err := controller.Unmarshal(in); err != nil { |
| 100 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 98 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 101 | } else { | 99 | } else { |
| 102 | - controller.Response(ruService.State(in)) | 100 | + controller.Response(ruService.Activate(in)) |
| 103 | } | 101 | } |
| 104 | } | 102 | } |
| 105 | 103 | ||
| @@ -109,17 +107,20 @@ func (controller *ProjectController) CopyProject() { | @@ -109,17 +107,20 @@ func (controller *ProjectController) CopyProject() { | ||
| 109 | if err := controller.Unmarshal(in); err != nil { | 107 | if err := controller.Unmarshal(in); err != nil { |
| 110 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 108 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 111 | } else { | 109 | } else { |
| 110 | + ua := middlewares.GetUser(controller.Ctx) | ||
| 111 | + in.CreatorId = ua.UserId | ||
| 112 | controller.Response(ruService.Copy(in)) | 112 | controller.Response(ruService.Copy(in)) |
| 113 | } | 113 | } |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | -func (controller *ProjectController) StatisticCycleUser() { | 116 | +func (controller *ProjectController) CheckRecipients() { |
| 117 | ruService := service.NewEvaluationProjectService() | 117 | ruService := service.NewEvaluationProjectService() |
| 118 | - in := &command.StatisticCycleProjectUserCommand{} | 118 | + in := &command.CheckRecipientCommand{} |
| 119 | if err := controller.Unmarshal(in); err != nil { | 119 | if err := controller.Unmarshal(in); err != nil { |
| 120 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 120 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 121 | } else { | 121 | } else { |
| 122 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 123 | - controller.Response(ruService.StatisticCycleUser(in)) | 122 | + ua := middlewares.GetUser(controller.Ctx) |
| 123 | + in.CompanyId = ua.CompanyId | ||
| 124 | + controller.Response(ruService.CheckRecipients(in)) | ||
| 124 | } | 125 | } |
| 125 | } | 126 | } |
| @@ -12,14 +12,17 @@ type RuleController struct { | @@ -12,14 +12,17 @@ type RuleController struct { | ||
| 12 | beego.BaseController | 12 | beego.BaseController |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | -func (controller *RoleController) CreateRule() { | 15 | +func (controller *RuleController) CreateRule() { |
| 16 | ruService := service.NewEvaluationRuleService() | 16 | ruService := service.NewEvaluationRuleService() |
| 17 | in := &command.CreateRuleCommand{} | 17 | in := &command.CreateRuleCommand{} |
| 18 | if err := controller.Unmarshal(in); err != nil { | 18 | if err := controller.Unmarshal(in); err != nil { |
| 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 20 | } else { | 20 | } else { |
| 21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 22 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 21 | + ua := middlewares.GetUser(controller.Ctx) |
| 22 | + in.CompanyId = ua.CompanyId | ||
| 23 | + in.CreatorId = ua.UserId | ||
| 24 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 25 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
| 23 | controller.Response(ruService.Create(in)) | 26 | controller.Response(ruService.Create(in)) |
| 24 | } | 27 | } |
| 25 | } | 28 | } |
| @@ -30,8 +33,11 @@ func (controller *RuleController) UpdateRule() { | @@ -30,8 +33,11 @@ func (controller *RuleController) UpdateRule() { | ||
| 30 | if err := controller.Unmarshal(in); err != nil { | 33 | if err := controller.Unmarshal(in); err != nil { |
| 31 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 34 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 32 | } else { | 35 | } else { |
| 33 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 34 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 36 | + ua := middlewares.GetUser(controller.Ctx) |
| 37 | + in.CompanyId = ua.CompanyId | ||
| 38 | + in.CreatorId = ua.UserId | ||
| 39 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 40 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
| 35 | controller.Response(ruService.Update(in)) | 41 | controller.Response(ruService.Update(in)) |
| 36 | } | 42 | } |
| 37 | } | 43 | } |
| @@ -57,27 +63,34 @@ func (controller *RuleController) RemoveRule() { | @@ -57,27 +63,34 @@ func (controller *RuleController) RemoveRule() { | ||
| 57 | } | 63 | } |
| 58 | } | 64 | } |
| 59 | 65 | ||
| 60 | -func (controller *RuleController) ListRule() { | 66 | +//func (controller *RuleController) ListRule() { |
| 67 | +// ruService := service.NewEvaluationRuleService() | ||
| 68 | +// in := &command.QueryRuleCommand{} | ||
| 69 | +// in.Type = -1 | ||
| 70 | +// if err := controller.Unmarshal(in); err != nil { | ||
| 71 | +// controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 72 | +// } else { | ||
| 73 | +// if len(in.NameOrRemark) > 0 { | ||
| 74 | +// in.NameOrRemark = "%" + in.NameOrRemark + "%" | ||
| 75 | +// } | ||
| 76 | +// in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 77 | +// controller.Response(ruService.List(in)) | ||
| 78 | +// } | ||
| 79 | +//} | ||
| 80 | + | ||
| 81 | +func (controller *RuleController) ListRuleRelCreator() { | ||
| 61 | ruService := service.NewEvaluationRuleService() | 82 | ruService := service.NewEvaluationRuleService() |
| 62 | in := &command.QueryRuleCommand{} | 83 | in := &command.QueryRuleCommand{} |
| 84 | + in.Type = -1 | ||
| 63 | if err := controller.Unmarshal(in); err != nil { | 85 | if err := controller.Unmarshal(in); err != nil { |
| 64 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 86 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 65 | } else { | 87 | } else { |
| 66 | if len(in.NameOrRemark) > 0 { | 88 | if len(in.NameOrRemark) > 0 { |
| 67 | in.NameOrRemark = "%" + in.NameOrRemark + "%" | 89 | in.NameOrRemark = "%" + in.NameOrRemark + "%" |
| 68 | } | 90 | } |
| 69 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 70 | - controller.Response(ruService.List(in)) | ||
| 71 | - } | ||
| 72 | -} | ||
| 73 | - | ||
| 74 | -func (controller *RuleController) ListRuleRelCreator() { | ||
| 75 | - ruService := service.NewEvaluationRuleService() | ||
| 76 | - in := &command.QueryRuleCommand{} | ||
| 77 | - if err := controller.Unmarshal(in); err != nil { | ||
| 78 | - controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 79 | - } else { | ||
| 80 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 91 | + ua := middlewares.GetUser(controller.Ctx) |
| 92 | + in.CompanyId = ua.CompanyId | ||
| 93 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 81 | controller.Response(ruService.ListRelCreator(in)) | 94 | controller.Response(ruService.ListRelCreator(in)) |
| 82 | } | 95 | } |
| 83 | } | 96 | } |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | "github.com/linmadan/egglib-go/web/beego" | 5 | "github.com/linmadan/egglib-go/web/beego" |
| 6 | service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_template" | 6 | service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_template" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_template/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_template/command" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" |
| 9 | ) | 10 | ) |
| 10 | 11 | ||
| @@ -12,14 +13,17 @@ type TemplateController struct { | @@ -12,14 +13,17 @@ type TemplateController struct { | ||
| 12 | beego.BaseController | 13 | beego.BaseController |
| 13 | } | 14 | } |
| 14 | 15 | ||
| 15 | -func (controller *RoleController) CreateTemplate() { | 16 | +func (controller *TemplateController) CreateTemplate() { |
| 16 | ruService := service.NewEvaluationTemplateService() | 17 | ruService := service.NewEvaluationTemplateService() |
| 17 | in := &command.CreateTemplateCommand{} | 18 | in := &command.CreateTemplateCommand{} |
| 18 | if err := controller.Unmarshal(in); err != nil { | 19 | if err := controller.Unmarshal(in); err != nil { |
| 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 20 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 20 | } else { | 21 | } else { |
| 21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 22 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 22 | + ua := middlewares.GetUser(controller.Ctx) |
| 23 | + in.CompanyId = ua.CompanyId | ||
| 24 | + in.CreatorId = ua.UserId | ||
| 25 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 26 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
| 23 | controller.Response(ruService.Create(in)) | 27 | controller.Response(ruService.Create(in)) |
| 24 | } | 28 | } |
| 25 | } | 29 | } |
| @@ -30,7 +34,9 @@ func (controller *TemplateController) UpdateTemplate() { | @@ -30,7 +34,9 @@ func (controller *TemplateController) UpdateTemplate() { | ||
| 30 | if err := controller.Unmarshal(in); err != nil { | 34 | if err := controller.Unmarshal(in); err != nil { |
| 31 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 35 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 32 | } else { | 36 | } else { |
| 33 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 37 | + ua := middlewares.GetUser(controller.Ctx) |
| 38 | + in.CompanyId = ua.CompanyId | ||
| 39 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 34 | controller.Response(ruService.Update(in)) | 40 | controller.Response(ruService.Update(in)) |
| 35 | } | 41 | } |
| 36 | } | 42 | } |
| @@ -59,25 +65,33 @@ func (controller *TemplateController) RemoveTemplate() { | @@ -59,25 +65,33 @@ func (controller *TemplateController) RemoveTemplate() { | ||
| 59 | func (controller *TemplateController) ListTemplate() { | 65 | func (controller *TemplateController) ListTemplate() { |
| 60 | ruService := service.NewEvaluationTemplateService() | 66 | ruService := service.NewEvaluationTemplateService() |
| 61 | in := &command.QueryTemplateCommand{} | 67 | in := &command.QueryTemplateCommand{} |
| 68 | + in.State = -1 | ||
| 62 | if err := controller.Unmarshal(in); err != nil { | 69 | if err := controller.Unmarshal(in); err != nil { |
| 63 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 70 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 64 | } else { | 71 | } else { |
| 65 | if len(in.Name) > 0 { | 72 | if len(in.Name) > 0 { |
| 66 | in.Name = "%" + in.Name + "%" | 73 | in.Name = "%" + in.Name + "%" |
| 67 | } | 74 | } |
| 68 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 75 | + ua := middlewares.GetUser(controller.Ctx) |
| 76 | + in.CompanyId = ua.CompanyId | ||
| 77 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 69 | controller.Response(ruService.List(in)) | 78 | controller.Response(ruService.List(in)) |
| 70 | } | 79 | } |
| 71 | } | 80 | } |
| 72 | 81 | ||
| 73 | func (controller *TemplateController) ListEnableTemplate() { | 82 | func (controller *TemplateController) ListEnableTemplate() { |
| 74 | ruService := service.NewEvaluationTemplateService() | 83 | ruService := service.NewEvaluationTemplateService() |
| 75 | - in := &command.AllEnableTemplateCommand{} | 84 | + in := &command.QueryTemplateCommand{} |
| 85 | + in.State = domain.TemplateStateEnable | ||
| 86 | + in.PageNumber = 1 | ||
| 87 | + in.PageSize = 999999 | ||
| 76 | if err := controller.Unmarshal(in); err != nil { | 88 | if err := controller.Unmarshal(in); err != nil { |
| 77 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 89 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 78 | } else { | 90 | } else { |
| 79 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 80 | - controller.Response(ruService.ListForEnable(in)) | 91 | + ua := middlewares.GetUser(controller.Ctx) |
| 92 | + in.CompanyId = ua.CompanyId | ||
| 93 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 94 | + controller.Response(ruService.List(in)) | ||
| 81 | } | 95 | } |
| 82 | } | 96 | } |
| 83 | 97 | ||
| @@ -87,6 +101,9 @@ func (controller *TemplateController) StateTemplate() { | @@ -87,6 +101,9 @@ func (controller *TemplateController) StateTemplate() { | ||
| 87 | if err := controller.Unmarshal(in); err != nil { | 101 | if err := controller.Unmarshal(in); err != nil { |
| 88 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 102 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 89 | } else { | 103 | } else { |
| 104 | + ua := middlewares.GetUser(controller.Ctx) | ||
| 105 | + in.CompanyId = ua.CompanyId | ||
| 106 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 90 | controller.Response(ruService.State(in)) | 107 | controller.Response(ruService.State(in)) |
| 91 | } | 108 | } |
| 92 | } | 109 | } |
| @@ -97,6 +114,11 @@ func (controller *TemplateController) CopyTemplate() { | @@ -97,6 +114,11 @@ func (controller *TemplateController) CopyTemplate() { | ||
| 97 | if err := controller.Unmarshal(in); err != nil { | 114 | if err := controller.Unmarshal(in); err != nil { |
| 98 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 115 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 99 | } else { | 116 | } else { |
| 117 | + ua := middlewares.GetUser(controller.Ctx) | ||
| 118 | + in.CompanyId = ua.CompanyId | ||
| 119 | + in.CreatorId = ua.UserId | ||
| 120 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 121 | + //in.CreatorId = middlewares.GetUserId(controller.Ctx) | ||
| 100 | controller.Response(ruService.Copy(in)) | 122 | controller.Response(ruService.Copy(in)) |
| 101 | } | 123 | } |
| 102 | } | 124 | } |
pkg/port/beego/controllers/hello.go
已删除
100644 → 0
| 1 | -package controllers | ||
| 2 | - | ||
| 3 | -import ( | ||
| 4 | - "github.com/beego/beego/v2/server/web" | ||
| 5 | - "github.com/beego/beego/v2/server/web/context" | ||
| 6 | -) | ||
| 7 | - | ||
| 8 | -type HelloController struct { | ||
| 9 | - web.Controller | ||
| 10 | -} | ||
| 11 | - | ||
| 12 | -func (c *HelloController) Say() { | ||
| 13 | - c.JSONResp(map[string]string{ | ||
| 14 | - "msg": "hello", | ||
| 15 | - }) | ||
| 16 | -} | ||
| 17 | - | ||
| 18 | -func SayHello(c *context.Context) { | ||
| 19 | - c.JSONResp(map[string]string{ | ||
| 20 | - "msg": "hello", | ||
| 21 | - }) | ||
| 22 | -} |
| @@ -12,35 +12,48 @@ type RoleController struct { | @@ -12,35 +12,48 @@ type RoleController struct { | ||
| 12 | beego.BaseController | 12 | beego.BaseController |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | -func (controller *RoleController) CreateRole() { | ||
| 16 | - ruService := service.NewRoleService() | ||
| 17 | - in := &command.CreateRoleCommand{} | ||
| 18 | - if err := controller.Unmarshal(in); err != nil { | ||
| 19 | - controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 20 | - } else { | ||
| 21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 22 | - controller.Response(ruService.Create(in)) | ||
| 23 | - } | ||
| 24 | -} | ||
| 25 | - | ||
| 26 | -func (controller *RoleController) UpdateRole() { | ||
| 27 | - ruService := service.NewRoleService() | ||
| 28 | - in := &command.UpdateRoleCommand{} | ||
| 29 | - if err := controller.Unmarshal(in); err != nil { | ||
| 30 | - controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 31 | - } else { | ||
| 32 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 33 | - controller.Response(ruService.Update(in)) | ||
| 34 | - } | ||
| 35 | -} | 15 | +//func (controller *RoleController) CreateRole() { |
| 16 | +// ruService := service.NewRoleService() | ||
| 17 | +// in := &command.CreateRoleCommand{} | ||
| 18 | +// if err := controller.Unmarshal(in); err != nil { | ||
| 19 | +// controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 20 | +// } else { | ||
| 21 | +// in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 22 | +// controller.Response(ruService.Create(in)) | ||
| 23 | +// } | ||
| 24 | +//} | ||
| 25 | +// | ||
| 26 | +//func (controller *RoleController) UpdateRole() { | ||
| 27 | +// ruService := service.NewRoleService() | ||
| 28 | +// in := &command.UpdateRoleCommand{} | ||
| 29 | +// if err := controller.Unmarshal(in); err != nil { | ||
| 30 | +// controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 31 | +// } else { | ||
| 32 | +// in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 33 | +// controller.Response(ruService.Update(in)) | ||
| 34 | +// } | ||
| 35 | +//} | ||
| 36 | +// | ||
| 37 | +//func (controller *RoleController) RemoveRole() { | ||
| 38 | +// ruService := service.NewRoleService() | ||
| 39 | +// in := &command.DeleteRoleCommand{} | ||
| 40 | +// if err := controller.Unmarshal(in); err != nil { | ||
| 41 | +// controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 42 | +// } else { | ||
| 43 | +// in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 44 | +// controller.Response(ruService.Remove(in)) | ||
| 45 | +// } | ||
| 46 | +//} | ||
| 36 | 47 | ||
| 37 | -func (controller *RoleController) RemoveRole() { | 48 | +func (controller *RoleController) ListForUserRole() { |
| 38 | ruService := service.NewRoleService() | 49 | ruService := service.NewRoleService() |
| 39 | - in := &command.DeleteRoleCommand{} | 50 | + in := &command.QueryRoleUserCommand{} |
| 40 | if err := controller.Unmarshal(in); err != nil { | 51 | if err := controller.Unmarshal(in); err != nil { |
| 41 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 52 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 42 | } else { | 53 | } else { |
| 43 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 44 | - controller.Response(ruService.Remove(in)) | 54 | + ua := middlewares.GetUser(controller.Ctx) |
| 55 | + in.CompanyId = ua.CompanyId | ||
| 56 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 57 | + controller.Response(ruService.ListForUser(in)) | ||
| 45 | } | 58 | } |
| 46 | } | 59 | } |
| @@ -18,7 +18,9 @@ func (controller *RoleUserController) CreateRoleUser() { | @@ -18,7 +18,9 @@ func (controller *RoleUserController) CreateRoleUser() { | ||
| 18 | if err := controller.Unmarshal(in); err != nil { | 18 | if err := controller.Unmarshal(in); err != nil { |
| 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 19 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 20 | } else { | 20 | } else { |
| 21 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 21 | + ua := middlewares.GetUser(controller.Ctx) |
| 22 | + in.CompanyId = ua.CompanyId | ||
| 23 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 22 | controller.Response(ruService.Create(in)) | 24 | controller.Response(ruService.Create(in)) |
| 23 | } | 25 | } |
| 24 | } | 26 | } |
| @@ -29,7 +31,22 @@ func (controller *RoleUserController) RemoveRoleUser() { | @@ -29,7 +31,22 @@ func (controller *RoleUserController) RemoveRoleUser() { | ||
| 29 | if err := controller.Unmarshal(in); err != nil { | 31 | if err := controller.Unmarshal(in); err != nil { |
| 30 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 32 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 31 | } else { | 33 | } else { |
| 32 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 34 | + ua := middlewares.GetUser(controller.Ctx) |
| 35 | + in.CompanyId = ua.CompanyId | ||
| 36 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 33 | controller.Response(ruService.Remove(in)) | 37 | controller.Response(ruService.Remove(in)) |
| 34 | } | 38 | } |
| 35 | } | 39 | } |
| 40 | + | ||
| 41 | +func (controller *RoleUserController) ListRoleUser() { | ||
| 42 | + ruService := service.NewRoleUserService() | ||
| 43 | + in := &command.UserRoleQueryCommand{} | ||
| 44 | + if err := controller.Unmarshal(in); err != nil { | ||
| 45 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 46 | + } else { | ||
| 47 | + ua := middlewares.GetUser(controller.Ctx) | ||
| 48 | + in.CompanyId = ua.CompanyId | ||
| 49 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 50 | + controller.Response(ruService.ListRole(in)) | ||
| 51 | + } | ||
| 52 | +} |
| 1 | +package controllers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/linmadan/egglib-go/core/application" | ||
| 5 | + "github.com/linmadan/egglib-go/web/beego" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +type StaffAssessController struct { | ||
| 12 | + beego.BaseController | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +// 获取我的绩效任务列表 | ||
| 16 | +func (c *StaffAssessController) SearchAssessTaskMe() { | ||
| 17 | + srv := service.NewStaffAssessServeice() | ||
| 18 | + paramReq := &query.SearchAssessMeQuery{} | ||
| 19 | + err := c.BindJSON(paramReq) | ||
| 20 | + if err != nil { | ||
| 21 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
| 22 | + c.Response(nil, e) | ||
| 23 | + return | ||
| 24 | + } | ||
| 25 | + //TODO 获取当前用户信息 | ||
| 26 | + paramReq.CompanyId = 1 | ||
| 27 | + paramReq.UserId = 1 | ||
| 28 | + data, err := srv.SearchAssessTaskMe(paramReq) | ||
| 29 | + c.Response(data, err) | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +// 获取我的绩效任务各环节完成情况 | ||
| 33 | +func (c *StaffAssessController) AssessTaskMeDesc() { | ||
| 34 | + srv := service.NewStaffAssessServeice() | ||
| 35 | + paramReq := &query.AssessTaskDescQuery{} | ||
| 36 | + err := c.BindJSON(paramReq) | ||
| 37 | + if err != nil { | ||
| 38 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
| 39 | + c.Response(nil, e) | ||
| 40 | + return | ||
| 41 | + } | ||
| 42 | + //TODO 获取当前用户信息 | ||
| 43 | + paramReq.CompanyId = 1 | ||
| 44 | + paramReq.UserId = 1 | ||
| 45 | + data, err := srv.AssessTaskDesc(paramReq) | ||
| 46 | + c.Response(data, err) | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +// 获取个人的自评反馈历史记录列表 | ||
| 50 | +func (c *StaffAssessController) AssessSelfMeList() { | ||
| 51 | + srv := service.NewStaffAssessServeice() | ||
| 52 | + paramReq := &query.AssessSelfListQuery{} | ||
| 53 | + err := c.BindJSON(paramReq) | ||
| 54 | + if err != nil { | ||
| 55 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
| 56 | + c.Response(nil, e) | ||
| 57 | + return | ||
| 58 | + } | ||
| 59 | + //TODO 获取当前用户信息 | ||
| 60 | + paramReq.CompanyId = 1 | ||
| 61 | + paramReq.UserId = 1 | ||
| 62 | + data, err := srv.AssessSelfList(paramReq) | ||
| 63 | + c.Response(data, err) | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +// 更具项目评估的配置,创建员工的评估任务,(调试用) | ||
| 67 | +func (c *StaffAssessController) CreateStaffAssessTask() { | ||
| 68 | + srv := service.NewStaffAssessServeice() | ||
| 69 | + paramReq := &command.CreateStaffAssessTask{} | ||
| 70 | + err := c.BindJSON(paramReq) | ||
| 71 | + if err != nil { | ||
| 72 | + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) | ||
| 73 | + c.Response(nil, e) | ||
| 74 | + return | ||
| 75 | + } | ||
| 76 | + //服务调用,实际由定时任务触发 | ||
| 77 | + data, err := srv.CreateStaffAssessTask(paramReq) | ||
| 78 | + c.Response(data, err) | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +//获取员工自评详情 | ||
| 82 | + | ||
| 83 | +//保存员工自评填写内容 | ||
| 84 | + | ||
| 85 | +//获取员工邀请的人 | ||
| 86 | + | ||
| 87 | +//保持员工邀请的人 |
| @@ -6,6 +6,14 @@ import ( | @@ -6,6 +6,14 @@ import ( | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
| 7 | ) | 7 | ) |
| 8 | 8 | ||
| 9 | +func GetUser(ctx *context.Context) *domain.UserAuth { | ||
| 10 | + user := ctx.Input.GetData(domain.UserAuth{}) | ||
| 11 | + if user != nil { | ||
| 12 | + return user.(*domain.UserAuth) | ||
| 13 | + } | ||
| 14 | + return nil | ||
| 15 | +} | ||
| 16 | + | ||
| 9 | func CheckAdminToken() func(ctx *context.Context) { | 17 | func CheckAdminToken() func(ctx *context.Context) { |
| 10 | return func(ctx *context.Context) { | 18 | return func(ctx *context.Context) { |
| 11 | adminToken := ctx.Input.Header("x-admin-token") | 19 | adminToken := ctx.Input.Header("x-admin-token") |
| 1 | package middlewares | 1 | package middlewares |
| 2 | 2 | ||
| 3 | -import ( | ||
| 4 | - "github.com/beego/beego/v2/server/web/context" | ||
| 5 | -) | ||
| 6 | - | ||
| 7 | -func setUserId(userId int64, ctx *context.Context) { | ||
| 8 | - ctx.Input.SetData("_UserId", userId) | ||
| 9 | -} | ||
| 10 | - | ||
| 11 | -func GetUserId(ctx *context.Context) int64 { | ||
| 12 | - userId := ctx.Input.GetData("_UserId") | ||
| 13 | - return userId.(int64) | ||
| 14 | -} | ||
| 15 | - | ||
| 16 | -func setCompanyId(companyId int64, ctx *context.Context) { | ||
| 17 | - ctx.Input.SetData("_CompanyId", companyId) | ||
| 18 | -} | ||
| 19 | - | ||
| 20 | -func GetCompanyId(ctx *context.Context) int64 { | ||
| 21 | - companyId := ctx.Input.GetData("_CompanyId") | ||
| 22 | - return companyId.(int64) | ||
| 23 | -} | ||
| 24 | - | ||
| 25 | -func setCompanyType(companyId int, ctx *context.Context) { | ||
| 26 | - ctx.Input.SetData("_CompanyType", companyId) | ||
| 27 | -} | ||
| 28 | - | ||
| 29 | -func GetCompanyType(ctx *context.Context) int { | ||
| 30 | - companyId := ctx.Input.GetData("_CompanyType") | ||
| 31 | - return companyId.(int) | ||
| 32 | -} | ||
| 33 | - | ||
| 34 | -func invalidOrExpired(ctx *context.Context) { | ||
| 35 | - resp := map[string]interface{}{ | ||
| 36 | - "code": 902, | ||
| 37 | - "msg": "Authorization过期或无效,需要进行重新获取令牌", | ||
| 38 | - } | ||
| 39 | - _ = ctx.Output.JSON(resp, false, false) | ||
| 40 | -} | ||
| 41 | - | ||
| 42 | -func CheckToken() func(ctx *context.Context) { | ||
| 43 | - return func(ctx *context.Context) { | ||
| 44 | - tokenStr := ctx.Input.Header("x-mmm-accesstoken") | ||
| 45 | - if tokenStr == "" { //没有带token | ||
| 46 | - invalidOrExpired(ctx) | ||
| 47 | - return | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - //userServe := service.UserService{} | ||
| 51 | - //userTk, err := userServe.ValidLoginToken(tokenStr) | ||
| 52 | - //if err != nil { | ||
| 53 | - // invalidOrExpired(ctx) | ||
| 54 | - // return | ||
| 55 | - //} | ||
| 56 | - //setUserId(userTk.UserId, ctx) | ||
| 57 | - //setCompanyId(userTk.CompanyId, ctx) | ||
| 58 | - //setCompanyType(userTk.CompanyType, ctx) | ||
| 59 | - } | ||
| 60 | -} | 3 | +// |
| 4 | +//import ( | ||
| 5 | +// "github.com/beego/beego/v2/server/web/context" | ||
| 6 | +//) | ||
| 7 | +// | ||
| 8 | +//func setUserId(userId int64, ctx *context.Context) { | ||
| 9 | +// ctx.Input.SetData("_UserId", userId) | ||
| 10 | +//} | ||
| 11 | +// | ||
| 12 | +//func GetUserId(ctx *context.Context) int64 { | ||
| 13 | +// userId := ctx.Input.GetData("_UserId") | ||
| 14 | +// return userId.(int64) | ||
| 15 | +//} | ||
| 16 | +// | ||
| 17 | +//func setCompanyId(companyId int64, ctx *context.Context) { | ||
| 18 | +// ctx.Input.SetData("_CompanyId", companyId) | ||
| 19 | +//} | ||
| 20 | +// | ||
| 21 | +//func GetCompanyId(ctx *context.Context) int64 { | ||
| 22 | +// companyId := ctx.Input.GetData("_CompanyId") | ||
| 23 | +// return companyId.(int64) | ||
| 24 | +//} | ||
| 25 | +// | ||
| 26 | +//func setCompanyType(companyId int, ctx *context.Context) { | ||
| 27 | +// ctx.Input.SetData("_CompanyType", companyId) | ||
| 28 | +//} | ||
| 29 | +// | ||
| 30 | +//func GetCompanyType(ctx *context.Context) int { | ||
| 31 | +// companyId := ctx.Input.GetData("_CompanyType") | ||
| 32 | +// return companyId.(int) | ||
| 33 | +//} | ||
| 34 | +// | ||
| 35 | +//func invalidOrExpired(ctx *context.Context) { | ||
| 36 | +// resp := map[string]interface{}{ | ||
| 37 | +// "code": 902, | ||
| 38 | +// "msg": "Authorization过期或无效,需要进行重新获取令牌", | ||
| 39 | +// } | ||
| 40 | +// _ = ctx.Output.JSON(resp, false, false) | ||
| 41 | +//} | ||
| 42 | +// | ||
| 43 | +//func CheckToken() func(ctx *context.Context) { | ||
| 44 | +// return func(ctx *context.Context) { | ||
| 45 | +// tokenStr := ctx.Input.Header("x-mmm-accesstoken") | ||
| 46 | +// if tokenStr == "" { //没有带token | ||
| 47 | +// invalidOrExpired(ctx) | ||
| 48 | +// return | ||
| 49 | +// } | ||
| 50 | +// | ||
| 51 | +// //userServe := service.UserService{} | ||
| 52 | +// //userTk, err := userServe.ValidLoginToken(tokenStr) | ||
| 53 | +// //if err != nil { | ||
| 54 | +// // invalidOrExpired(ctx) | ||
| 55 | +// // return | ||
| 56 | +// //} | ||
| 57 | +// //setUserId(userTk.UserId, ctx) | ||
| 58 | +// //setCompanyId(userTk.CompanyId, ctx) | ||
| 59 | +// //setCompanyType(userTk.CompanyType, ctx) | ||
| 60 | +// } | ||
| 61 | +//} |
| 1 | +package routers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/beego/beego/v2/server/web" | ||
| 5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func init() { | ||
| 11 | + ns := web.NewNamespace("/v1/evaluation-cycle", | ||
| 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
| 13 | + web.NSRouter("/", &controllers.CycleController{}, "Post:CreateCycle"), | ||
| 14 | + web.NSRouter("/", &controllers.CycleController{}, "Put:UpdateCycle"), | ||
| 15 | + web.NSRouter("/", &controllers.CycleController{}, "Delete:RemoveCycle"), | ||
| 16 | + web.NSRouter("/:Id", &controllers.CycleController{}, "Get:GetCycle"), | ||
| 17 | + web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), | ||
| 18 | + web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), | ||
| 19 | + ) | ||
| 20 | + web.AddNamespace(ns) | ||
| 21 | +} |
| 1 | +package routers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/beego/beego/v2/server/web" | ||
| 5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func init() { | ||
| 11 | + ns := web.NewNamespace("/v1/evaluation-project", | ||
| 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
| 13 | + web.NSRouter("/", &controllers.ProjectController{}, "Post:CreateProject"), | ||
| 14 | + web.NSRouter("/", &controllers.ProjectController{}, "Put:UpdateProject"), | ||
| 15 | + web.NSRouter("/", &controllers.ProjectController{}, "Delete:RemoveProject"), | ||
| 16 | + web.NSRouter("/:Id", &controllers.ProjectController{}, "Get:GetProject"), | ||
| 17 | + web.NSRouter("/list", &controllers.ProjectController{}, "Post:ListProject"), | ||
| 18 | + web.NSRouter("/detail", &controllers.ProjectController{}, "Put:UpdateProjectForTemplate"), | ||
| 19 | + web.NSRouter("/check-recipients", &controllers.ProjectController{}, "Post:CheckRecipients"), | ||
| 20 | + web.NSRouter("/copy", &controllers.ProjectController{}, "Post:CopyProject"), | ||
| 21 | + web.NSRouter("/activate", &controllers.ProjectController{}, "Post:ActivateProject"), | ||
| 22 | + ) | ||
| 23 | + web.AddNamespace(ns) | ||
| 24 | +} |
| 1 | +package routers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/beego/beego/v2/server/web" | ||
| 5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func init() { | ||
| 11 | + ns := web.NewNamespace("/v1/evaluation-rule", | ||
| 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
| 13 | + web.NSRouter("/", &controllers.RuleController{}, "Post:CreateRule"), | ||
| 14 | + web.NSRouter("/", &controllers.RuleController{}, "Put:UpdateRule"), | ||
| 15 | + web.NSRouter("/", &controllers.RuleController{}, "Delete:RemoveRule"), | ||
| 16 | + web.NSRouter("/:Id", &controllers.RuleController{}, "Get:GetRule"), | ||
| 17 | + web.NSRouter("/list", &controllers.RuleController{}, "Post:ListRuleRelCreator"), | ||
| 18 | + ) | ||
| 19 | + web.AddNamespace(ns) | ||
| 20 | +} |
| 1 | +package routers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/beego/beego/v2/server/web" | ||
| 5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func init() { | ||
| 11 | + ns := web.NewNamespace("/v1/evaluation-template", | ||
| 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
| 13 | + web.NSRouter("/", &controllers.TemplateController{}, "Post:CreateTemplate"), | ||
| 14 | + web.NSRouter("/", &controllers.TemplateController{}, "Put:UpdateTemplate"), | ||
| 15 | + web.NSRouter("/", &controllers.TemplateController{}, "Delete:RemoveTemplate"), | ||
| 16 | + web.NSRouter("/:Id", &controllers.TemplateController{}, "Get:GetTemplate"), | ||
| 17 | + web.NSRouter("/list", &controllers.TemplateController{}, "Post:ListTemplate"), | ||
| 18 | + web.NSRouter("/list-enable", &controllers.TemplateController{}, "Post:ListEnableTemplate"), | ||
| 19 | + ) | ||
| 20 | + web.AddNamespace(ns) | ||
| 21 | +} |
pkg/port/beego/routers/role_router.go
0 → 100644
| 1 | +package routers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/beego/beego/v2/server/web" | ||
| 5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func init() { | ||
| 11 | + ns := web.NewNamespace("/v1/role", | ||
| 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
| 13 | + //web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"), | ||
| 14 | + //web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"), | ||
| 15 | + //web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"), | ||
| 16 | + //web.NSRouter("/:Id", &controllers.RoleController{}, "Get:GetRole"), | ||
| 17 | + web.NSRouter("/all", &controllers.RoleController{}, "Post:ListForUserRole"), | ||
| 18 | + ) | ||
| 19 | + web.AddNamespace(ns) | ||
| 20 | +} |
| @@ -2,14 +2,17 @@ package routers | @@ -2,14 +2,17 @@ package routers | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/beego/beego/v2/server/web" | 4 | "github.com/beego/beego/v2/server/web" |
| 5 | + "github.com/linmadan/egglib-go/web/beego/filters" | ||
| 5 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | ||
| 6 | ) | 8 | ) |
| 7 | 9 | ||
| 8 | func init() { | 10 | func init() { |
| 9 | - h1 := web.NewNamespace("/v1/demo", | ||
| 10 | - web.NSCtrlGet("/hello", (*controllers.HelloController).Say), | ||
| 11 | - web.NSCtrlGet("/hello2", (*controllers.HelloController).Say), | ||
| 12 | - // web.NSGet("/hello1", controllers.SayHello), | 11 | + ns := web.NewNamespace("/v1/role-user", |
| 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), | ||
| 13 | + web.NSRouter("/", &controllers.RoleUserController{}, "Post:CreateRoleUser"), | ||
| 14 | + web.NSRouter("/", &controllers.RoleUserController{}, "Delete:RemoveRoleUser"), | ||
| 15 | + web.NSRouter("/all", &controllers.RoleUserController{}, "Post:ListRoleUser"), | ||
| 13 | ) | 16 | ) |
| 14 | - web.AddNamespace(h1) | 17 | + web.AddNamespace(ns) |
| 15 | } | 18 | } |
| 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 | + assessTaskNS := web.NewNamespace("/v1/staff-assess-task", | ||
| 10 | + // web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | ||
| 11 | + web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表 | ||
| 12 | + web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述 | ||
| 13 | + web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务 | ||
| 14 | + ) | ||
| 15 | + // /v1/staff-assess/self/me/list | ||
| 16 | + assessNS := web.NewNamespace("/v1/staff-assess", | ||
| 17 | + // web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | ||
| 18 | + web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表 | ||
| 19 | + // web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).AssessSelfMeList), | ||
| 20 | + ) | ||
| 21 | + web.AddNamespace(assessTaskNS) | ||
| 22 | + web.AddNamespace(assessNS) | ||
| 23 | +} |
-
请 注册 或 登录 后发表评论