Merge branch 'test' into dev-tangxvhui
正在显示
31 个修改的文件
包含
593 行增加
和
223 行删除
| @@ -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 |
| @@ -9,9 +9,35 @@ type QueryCycleCommand struct { | @@ -9,9 +9,35 @@ type QueryCycleCommand struct { | ||
| 9 | PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` | 9 | PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | +type StatisticCycleProjectUserCommand struct { | ||
| 13 | + CompanyId int64 `cname:"公司ID" json:"companyId"` | ||
| 14 | + CycleId int64 `cname:"周期ID" json:"cycleId,string"` | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +type CycleTemplateListCommand struct { | ||
| 18 | + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +type CycleTemplateCommand struct { | ||
| 22 | + CycleId int64 `cname:"周期ID" json:"cycleId,string" valid:"Required"` | ||
| 23 | + TemplateId int64 `cname:"模板ID" json:"templateId,string" valid:"Required"` | ||
| 24 | +} | ||
| 25 | + | ||
| 12 | func (in *QueryCycleCommand) Valid(validation *validation.Validation) { | 26 | func (in *QueryCycleCommand) Valid(validation *validation.Validation) { |
| 13 | if in.CompanyId == 0 { | 27 | if in.CompanyId == 0 { |
| 14 | validation.SetError("companyId", "公司ID无效") | 28 | validation.SetError("companyId", "公司ID无效") |
| 15 | return | 29 | return |
| 16 | } | 30 | } |
| 17 | } | 31 | } |
| 32 | + | ||
| 33 | +func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { | ||
| 34 | + | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +func (in *CycleTemplateListCommand) Valid(*validation.Validation) { | ||
| 38 | + | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +func (in *CycleTemplateCommand) Valid(*validation.Validation) { | ||
| 42 | + | ||
| 43 | +} |
| @@ -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,11 +64,45 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -62,11 +64,45 @@ 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, |
| 105 | + TemplateCreatedAt: v.CreatedAt, | ||
| 70 | Template: v, | 106 | Template: v, |
| 71 | CycleId: cycle.Id, | 107 | CycleId: cycle.Id, |
| 72 | } | 108 | } |
| @@ -74,12 +110,19 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | @@ -74,12 +110,19 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf | ||
| 74 | if err != nil { | 110 | if err != nil { |
| 75 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 111 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 76 | } | 112 | } |
| 113 | + | ||
| 114 | + // 输出模板简单信息 | ||
| 115 | + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | ||
| 116 | + Id: cycleTemplate.Id, | ||
| 117 | + Name: cycleTemplate.Name, | ||
| 118 | + CreatedAt: cycleTemplate.TemplateCreatedAt, // 模板创建时间 | ||
| 119 | + }) | ||
| 77 | } | 120 | } |
| 78 | 121 | ||
| 79 | if err := transactionContext.CommitTransaction(); err != nil { | 122 | if err := transactionContext.CommitTransaction(); err != nil { |
| 80 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 123 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 81 | } | 124 | } |
| 82 | - return cycle, nil | 125 | + return ctAdapter, nil |
| 83 | 126 | ||
| 84 | } | 127 | } |
| 85 | 128 | ||
| @@ -148,6 +191,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -148,6 +191,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
| 148 | cycleTemplate := &domain.EvaluationCycleTemplate{ | 191 | cycleTemplate := &domain.EvaluationCycleTemplate{ |
| 149 | Id: 0, | 192 | Id: 0, |
| 150 | Name: v.Name, | 193 | Name: v.Name, |
| 194 | + TemplateCreatedAt: v.CreatedAt, | ||
| 151 | Template: v, | 195 | Template: v, |
| 152 | CycleId: cycle.Id, | 196 | CycleId: cycle.Id, |
| 153 | } | 197 | } |
| @@ -166,10 +210,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | @@ -166,10 +210,26 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf | ||
| 166 | if err != nil { | 210 | if err != nil { |
| 167 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 211 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 168 | } | 212 | } |
| 213 | + | ||
| 214 | + _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": cycle.Id}, "template") | ||
| 215 | + if err != nil { | ||
| 216 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + ctAdapter := &adapter.CycleTemplateAdapter{} | ||
| 220 | + ctAdapter.EvaluationCycle = cycle | ||
| 221 | + for i := range cycleTemplates { | ||
| 222 | + ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | ||
| 223 | + Id: cycleTemplates[i].Id, | ||
| 224 | + Name: cycleTemplates[i].Name, | ||
| 225 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, | ||
| 226 | + }) | ||
| 227 | + } | ||
| 228 | + | ||
| 169 | if err := transactionContext.CommitTransaction(); err != nil { | 229 | if err := transactionContext.CommitTransaction(); err != nil { |
| 170 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 230 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 171 | } | 231 | } |
| 172 | - return cycle, nil | 232 | + return ctAdapter, nil |
| 173 | } | 233 | } |
| 174 | 234 | ||
| 175 | func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { | 235 | func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, error) { |
| @@ -199,7 +259,7 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, | @@ -199,7 +259,7 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, | ||
| 199 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ | 259 | ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ |
| 200 | Id: cycleTemplates[i].Id, | 260 | Id: cycleTemplates[i].Id, |
| 201 | Name: cycleTemplates[i].Name, | 261 | Name: cycleTemplates[i].Name, |
| 202 | - CreatedAt: cycleTemplates[i].CreatedAt, | 262 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, |
| 203 | }) | 263 | }) |
| 204 | } | 264 | } |
| 205 | 265 | ||
| @@ -255,3 +315,101 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | @@ -255,3 +315,101 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface | ||
| 255 | } | 315 | } |
| 256 | return tool_funs.SimpleWrapGridMap(total, cycles), nil | 316 | return tool_funs.SimpleWrapGridMap(total, cycles), nil |
| 257 | } | 317 | } |
| 318 | + | ||
| 319 | +func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) { | ||
| 320 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 321 | + if err != nil { | ||
| 322 | + return nil, err | ||
| 323 | + } | ||
| 324 | + defer func() { | ||
| 325 | + transactionContext.RollbackTransaction() | ||
| 326 | + }() | ||
| 327 | + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 328 | + _, projects, err := projectRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") | ||
| 329 | + if err != nil { | ||
| 330 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 331 | + } | ||
| 332 | + | ||
| 333 | + userIds := make([]int64, 0) | ||
| 334 | + userIdMap := map[int64]int64{} | ||
| 335 | + for i := range projects { | ||
| 336 | + project := projects[i] | ||
| 337 | + for j := range project.Recipients { | ||
| 338 | + userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64) | ||
| 339 | + userIdMap[userId] = userId | ||
| 340 | + } | ||
| 341 | + } | ||
| 342 | + for _, v := range userIdMap { | ||
| 343 | + userIds = append(userIds, v) | ||
| 344 | + } | ||
| 345 | + | ||
| 346 | + userTotal := 0 | ||
| 347 | + departmentTotal := 0 | ||
| 348 | + if len(userIds) > 0 { | ||
| 349 | + userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 350 | + _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) | ||
| 351 | + departmentIdMap := map[int]int{} | ||
| 352 | + for i := range users { | ||
| 353 | + for _, v := range users[i].DepartmentId { | ||
| 354 | + departmentIdMap[v] = v | ||
| 355 | + } | ||
| 356 | + } | ||
| 357 | + userTotal = len(users) | ||
| 358 | + departmentTotal = len(departmentIdMap) | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 362 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 363 | + } | ||
| 364 | + return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | ||
| 365 | +} | ||
| 366 | + | ||
| 367 | +func (rs *EvaluationCycleService) CycleTemplateList(in *command.CycleTemplateListCommand) (interface{}, error) { | ||
| 368 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 369 | + if err != nil { | ||
| 370 | + return nil, err | ||
| 371 | + } | ||
| 372 | + defer func() { | ||
| 373 | + transactionContext.RollbackTransaction() | ||
| 374 | + }() | ||
| 375 | + | ||
| 376 | + cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 377 | + _, cycleTemplates, err := cycleTemplateRepository.Find(map[string]interface{}{"cycleId": in.CycleId}, "template") | ||
| 378 | + if err != nil { | ||
| 379 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + list := make([]*domain.TemplateSimple, 0) | ||
| 383 | + for i := range cycleTemplates { | ||
| 384 | + list = append(list, &domain.TemplateSimple{ | ||
| 385 | + Id: cycleTemplates[i].Id, | ||
| 386 | + Name: cycleTemplates[i].Name, | ||
| 387 | + CreatedAt: cycleTemplates[i].TemplateCreatedAt, | ||
| 388 | + }) | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 392 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 393 | + } | ||
| 394 | + return map[string]interface{}{"list": list}, nil | ||
| 395 | +} | ||
| 396 | + | ||
| 397 | +func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand) (interface{}, error) { | ||
| 398 | + transactionContext, err := factory.ValidateStartTransaction(in) | ||
| 399 | + if err != nil { | ||
| 400 | + return nil, err | ||
| 401 | + } | ||
| 402 | + defer func() { | ||
| 403 | + transactionContext.RollbackTransaction() | ||
| 404 | + }() | ||
| 405 | + | ||
| 406 | + cycleTemplateRepository := factory.CreateEvaluationCycleTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 407 | + cycleTemplate, err := cycleTemplateRepository.FindOne(map[string]interface{}{"id": in.TemplateId}) | ||
| 408 | + if err != nil { | ||
| 409 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 410 | + } | ||
| 411 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 412 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 413 | + } | ||
| 414 | + return cycleTemplate.Template, nil | ||
| 415 | +} |
| @@ -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) |
| @@ -290,7 +293,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | @@ -290,7 +293,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter | ||
| 290 | return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil | 293 | return tool_funs.SimpleWrapGridMap(total, projectAdapters), nil |
| 291 | } | 294 | } |
| 292 | 295 | ||
| 293 | -func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (interface{}, error) { | 296 | +func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) (interface{}, error) { |
| 294 | transactionContext, err := factory.ValidateStartTransaction(in) | 297 | transactionContext, err := factory.ValidateStartTransaction(in) |
| 295 | if err != nil { | 298 | if err != nil { |
| 296 | return nil, err | 299 | return nil, err |
| @@ -300,13 +303,20 @@ func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (inte | @@ -300,13 +303,20 @@ func (rs *EvaluationProjectService) State(in *command.StateProjectCommand) (inte | ||
| 300 | }() | 303 | }() |
| 301 | 304 | ||
| 302 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 305 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 303 | - | ||
| 304 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | 306 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) |
| 305 | if err != nil { | 307 | if err != nil { |
| 306 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 308 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 307 | } | 309 | } |
| 308 | 310 | ||
| 309 | - 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 | ||
| 310 | project, err = projectRepository.Insert(project) | 320 | project, err = projectRepository.Insert(project) |
| 311 | if err != nil { | 321 | if err != nil { |
| 312 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 322 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -332,6 +342,10 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -332,6 +342,10 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
| 332 | } | 342 | } |
| 333 | // ID重置 | 343 | // ID重置 |
| 334 | project.Id = 0 | 344 | project.Id = 0 |
| 345 | + project.Name = project.Name + " 副本" | ||
| 346 | + project.CreatorId = in.CreatorId | ||
| 347 | + project.Recipients = make([]string, 0) // 重置被评估人 | ||
| 348 | + | ||
| 335 | // 如果拷贝已经启用的模板,默认先设置为待启用 | 349 | // 如果拷贝已经启用的模板,默认先设置为待启用 |
| 336 | if project.State == domain.ProjectStateEnable { | 350 | if project.State == domain.ProjectStateEnable { |
| 337 | project.State = domain.ProjectStateWaitActive | 351 | project.State = domain.ProjectStateWaitActive |
| @@ -346,7 +360,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | @@ -346,7 +360,7 @@ func (rs *EvaluationProjectService) Copy(in *command.CopyProjectCommand) (interf | ||
| 346 | return project, nil | 360 | return project, nil |
| 347 | } | 361 | } |
| 348 | 362 | ||
| 349 | -func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycleProjectUserCommand) (interface{}, error) { | 363 | +func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCommand) (interface{}, error) { |
| 350 | transactionContext, err := factory.ValidateStartTransaction(in) | 364 | transactionContext, err := factory.ValidateStartTransaction(in) |
| 351 | if err != nil { | 365 | if err != nil { |
| 352 | return nil, err | 366 | return nil, err |
| @@ -354,42 +368,41 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl | @@ -354,42 +368,41 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl | ||
| 354 | defer func() { | 368 | defer func() { |
| 355 | transactionContext.RollbackTransaction() | 369 | transactionContext.RollbackTransaction() |
| 356 | }() | 370 | }() |
| 371 | + | ||
| 357 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 372 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
| 358 | - _, 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") | ||
| 359 | if err != nil { | 375 | if err != nil { |
| 360 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 376 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 361 | } | 377 | } |
| 362 | 378 | ||
| 363 | - userIds := make([]int64, 0) | ||
| 364 | - userIdMap := map[int64]int64{} | 379 | + // 周期内的所有项目,员工不能重复被评估 |
| 380 | + rids := map[string]bool{} | ||
| 365 | for i := range projects { | 381 | for i := range projects { |
| 366 | - project := projects[i] | ||
| 367 | - for j := range project.Recipients { | ||
| 368 | - userId, _ := strconv.ParseInt(project.Recipients[j], 10, 64) | ||
| 369 | - userIdMap[userId] = userId | ||
| 370 | - } | 382 | + // 排除当前项目 |
| 383 | + if in.Id != projects[i].Id { | ||
| 384 | + ids := projects[i].Recipients | ||
| 385 | + for j := range ids { | ||
| 386 | + rids[ids[j]] = true | ||
| 371 | } | 387 | } |
| 372 | - for _, v := range userIdMap { | ||
| 373 | - userIds = append(userIds, v) | ||
| 374 | } | 388 | } |
| 375 | - | ||
| 376 | - userTotal := 0 | ||
| 377 | - departmentTotal := 0 | ||
| 378 | - if len(userIds) > 0 { | ||
| 379 | - userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
| 380 | - _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) | ||
| 381 | - departmentIdMap := map[int]int{} | ||
| 382 | - for i := range users { | ||
| 383 | - for _, v := range users[i].DepartmentId { | ||
| 384 | - departmentIdMap[v] = v | ||
| 385 | } | 389 | } |
| 390 | + repeatNum := 0 | ||
| 391 | + for i := range in.Recipients { | ||
| 392 | + id := in.Recipients[i] | ||
| 393 | + if _, ok := rids[id]; ok { | ||
| 394 | + repeatNum++ | ||
| 386 | } | 395 | } |
| 387 | - userTotal = len(users) | ||
| 388 | - departmentTotal = len(departmentIdMap) | ||
| 389 | } | 396 | } |
| 397 | + //if repeatNum > 0 { | ||
| 398 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("有%d人已经在本周期其他项目内,需要将他们移除", repeatNum)) | ||
| 399 | + //} | ||
| 390 | 400 | ||
| 401 | + if err != nil { | ||
| 402 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 403 | + } | ||
| 391 | if err := transactionContext.CommitTransaction(); err != nil { | 404 | if err := transactionContext.CommitTransaction(); err != nil { |
| 392 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 405 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 393 | } | 406 | } |
| 394 | - return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil | 407 | + return repeatNum, nil |
| 395 | } | 408 | } |
pkg/application/user/command/batch_remove.go
0 → 100644
| @@ -62,6 +62,13 @@ func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) erro | @@ -62,6 +62,13 @@ func (srv SyncDataUserService) FromBusinessAdmin(param *domain.MessageBody) erro | ||
| 62 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 62 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 63 | } | 63 | } |
| 64 | err = srv.importUser(¶m4) | 64 | err = srv.importUser(¶m4) |
| 65 | + case "employee/batchRemove": | ||
| 66 | + batchRemove := &command.BatchRemove{} | ||
| 67 | + err = json.Unmarshal(param.Data, batchRemove) | ||
| 68 | + if err != nil { | ||
| 69 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 70 | + } | ||
| 71 | + err = srv.BatchRemove(batchRemove) | ||
| 65 | default: | 72 | default: |
| 66 | log.Logger.Error("action err:" + action) | 73 | log.Logger.Error("action err:" + action) |
| 67 | } | 74 | } |
| @@ -320,3 +327,38 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | @@ -320,3 +327,38 @@ func (srv SyncDataUserService) importUser(param *command.ImportUserCommand) erro | ||
| 320 | 327 | ||
| 321 | return nil | 328 | return nil |
| 322 | } | 329 | } |
| 330 | + | ||
| 331 | +// BatchRemove 调整部门 | ||
| 332 | +func (srv SyncDataUserService) BatchRemove(batchRemove *command.BatchRemove) error { | ||
| 333 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 334 | + if err != nil { | ||
| 335 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 336 | + } | ||
| 337 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 338 | + return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 339 | + } | ||
| 340 | + defer func() { | ||
| 341 | + _ = transactionContext.RollbackTransaction() | ||
| 342 | + }() | ||
| 343 | + userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
| 344 | + "transactionContext": transactionContext, | ||
| 345 | + }) | ||
| 346 | + if len(batchRemove.UserIds) > 0 { | ||
| 347 | + for _, item := range batchRemove.UserIds { | ||
| 348 | + user, err := userRepo.FindOne(map[string]interface{}{"id": item, "companyId": batchRemove.CompanyId}) | ||
| 349 | + if err != nil { | ||
| 350 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 351 | + } | ||
| 352 | + user.DepartmentId = batchRemove.DepartmentIds | ||
| 353 | + user.UpdatedAt = time.Now() | ||
| 354 | + _, err = userRepo.Update(user) | ||
| 355 | + if err != nil { | ||
| 356 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 357 | + } | ||
| 358 | + } | ||
| 359 | + } | ||
| 360 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 361 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 362 | + } | ||
| 363 | + return nil | ||
| 364 | +} |
| @@ -4,10 +4,20 @@ import ( | @@ -4,10 +4,20 @@ 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:"模板名称"` |
| 10 | - CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 20 | + CreatedAt time.Time `json:"createdAt" comment:"模板创建时间"` |
| 11 | } | 21 | } |
| 12 | 22 | ||
| 13 | type EvaluationCycle struct { | 23 | type EvaluationCycle struct { |
| @@ -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:"考核周期(1日、2周、3月)"` | 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:"删除时间"` |
| @@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
| 7 | type EvaluationCycleTemplate struct { | 7 | type EvaluationCycleTemplate struct { |
| 8 | Id int64 `json:"id,string" comment:"模板ID"` | 8 | Id int64 `json:"id,string" comment:"模板ID"` |
| 9 | Name string `json:"name" comment:"模板名称"` | 9 | Name string `json:"name" comment:"模板名称"` |
| 10 | + TemplateCreatedAt time.Time `json:"templateCreatedAt" comment:"模板创建时间"` | ||
| 10 | Template *EvaluationTemplate `json:"template" comment:"模板数据"` | 11 | Template *EvaluationTemplate `json:"template" comment:"模板数据"` |
| 11 | CycleId int64 `json:"cycleId,string" comment:"周期ID"` | 12 | CycleId int64 `json:"cycleId,string" comment:"周期ID"` |
| 12 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` | 13 | CreatedAt time.Time `json:"createdAt" comment:"创建时间"` |
| @@ -24,16 +24,6 @@ const ( | @@ -24,16 +24,6 @@ const ( | ||
| 24 | 24 | ||
| 25 | ) | 25 | ) |
| 26 | 26 | ||
| 27 | -const ( | ||
| 28 | - KpiCycleDay int = 1 // 考核周期-日 | ||
| 29 | - KpiCycleWeek int = 2 // 考核周期-周 | ||
| 30 | - KpiCycleOneMonth int = 3 // 考核周期-月 | ||
| 31 | - KpiCycleTwoMonth int = 4 // 考核周期-双月 | ||
| 32 | - KpiCycleThreeMonth int = 5 // 考核周期-季度 | ||
| 33 | - KpiCycleSixMonth int = 6 // 考核周期-半年 | ||
| 34 | - KpiCycleYear int = 7 // 考核周期-年 | ||
| 35 | -) | ||
| 36 | - | ||
| 37 | type EntryItem struct { | 27 | type EntryItem struct { |
| 38 | Title string `json:"title" comment:"填写标题"` | 28 | Title string `json:"title" comment:"填写标题"` |
| 39 | HintText string `json:"hintText" comment:"文本内容提示"` | 29 | HintText string `json:"hintText" comment:"文本内容提示"` |
| @@ -43,7 +33,8 @@ type EntryItem struct { | @@ -43,7 +33,8 @@ type EntryItem struct { | ||
| 43 | type NodeContent struct { | 33 | type NodeContent struct { |
| 44 | Category string `json:"category" comment:"类别"` | 34 | Category string `json:"category" comment:"类别"` |
| 45 | Name string `json:"name" comment:"名称"` | 35 | Name string `json:"name" comment:"名称"` |
| 46 | - RuleId string `json:"ruleId" comment:"评估规则ID"` | 36 | + RuleId int64 `json:"ruleId" comment:"评估规则ID"` |
| 37 | + Rule *EvaluationRule `json:"rule" comment:"评估规则对象"` | ||
| 47 | PromptTitle string `json:"promptTitle" comment:"提示项标题"` | 38 | PromptTitle string `json:"promptTitle" comment:"提示项标题"` |
| 48 | PromptText string `json:"promptText" comment:"提示项正文"` | 39 | PromptText string `json:"promptText" comment:"提示项正文"` |
| 49 | EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` | 40 | EntryItems []*EntryItem `json:"entryItems" comment:"填写项"` |
| @@ -9,6 +9,7 @@ type EvaluationCycleTemplate struct { | @@ -9,6 +9,7 @@ type EvaluationCycleTemplate struct { | ||
| 9 | tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` | 9 | tableName struct{} `comment:"评估周期模板" pg:"evaluation_cycle_template"` |
| 10 | Id int64 `comment:"模板ID" pg:"pk:id"` | 10 | Id int64 `comment:"模板ID" pg:"pk:id"` |
| 11 | Name string `comment:"模板名称"` | 11 | Name string `comment:"模板名称"` |
| 12 | + TemplateCreatedAt time.Time `comment:"模板创建时间"` | ||
| 12 | Template *domain.EvaluationTemplate `comment:"模板数据"` | 13 | Template *domain.EvaluationTemplate `comment:"模板数据"` |
| 13 | CycleId int64 `comment:"周期ID"` | 14 | CycleId int64 `comment:"周期ID"` |
| 14 | CreatedAt time.Time `comment:"创建时间"` | 15 | CreatedAt time.Time `comment:"创建时间"` |
| @@ -92,7 +92,7 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( | @@ -92,7 +92,7 @@ func (repo *DepartmentRepository) FindOne(queryOptions map[string]interface{}) ( | ||
| 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 | dparmentModel := []models.Department{} | 94 | dparmentModel := []models.Department{} |
| 95 | - query := tx.Model(&dparmentModel).Where("delete_at isnull") | 95 | + query := tx.Model(&dparmentModel) |
| 96 | if v, ok := queryOptions["id"]; ok { | 96 | if v, ok := queryOptions["id"]; ok { |
| 97 | query.Where("id=?", v) | 97 | query.Where("id=?", v) |
| 98 | } | 98 | } |
| @@ -24,6 +24,7 @@ func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.Evalu | @@ -24,6 +24,7 @@ func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.Evalu | ||
| 24 | return domain.EvaluationCycleTemplate{ | 24 | return domain.EvaluationCycleTemplate{ |
| 25 | Id: m.Id, | 25 | Id: m.Id, |
| 26 | Name: m.Name, | 26 | Name: m.Name, |
| 27 | + TemplateCreatedAt: m.TemplateCreatedAt, | ||
| 27 | Template: m.Template, | 28 | Template: m.Template, |
| 28 | CycleId: m.CycleId, | 29 | CycleId: m.CycleId, |
| 29 | CreatedAt: m.CreatedAt, | 30 | CreatedAt: m.CreatedAt, |
| @@ -36,6 +37,7 @@ func (repo *EvaluationCycleTemplateRepository) TransformToModel(d *domain.Evalua | @@ -36,6 +37,7 @@ func (repo *EvaluationCycleTemplateRepository) TransformToModel(d *domain.Evalua | ||
| 36 | return models.EvaluationCycleTemplate{ | 37 | return models.EvaluationCycleTemplate{ |
| 37 | Id: d.Id, | 38 | Id: d.Id, |
| 38 | Name: d.Name, | 39 | Name: d.Name, |
| 40 | + TemplateCreatedAt: d.TemplateCreatedAt, | ||
| 39 | Template: d.Template, | 41 | Template: d.Template, |
| 40 | CycleId: d.CycleId, | 42 | CycleId: d.CycleId, |
| 41 | CreatedAt: d.CreatedAt, | 43 | CreatedAt: d.CreatedAt, |
| @@ -58,9 +60,14 @@ func (repo *EvaluationCycleTemplateRepository) Insert(d *domain.EvaluationCycleT | @@ -58,9 +60,14 @@ func (repo *EvaluationCycleTemplateRepository) Insert(d *domain.EvaluationCycleT | ||
| 58 | d.Id = id | 60 | d.Id = id |
| 59 | d.CreatedAt = time.Now() | 61 | d.CreatedAt = time.Now() |
| 60 | d.UpdatedAt = d.CreatedAt | 62 | d.UpdatedAt = d.CreatedAt |
| 63 | + // 模板对象ID也更新 | ||
| 64 | + if d.Template != nil { | ||
| 65 | + d.Template.Id = id | ||
| 66 | + } | ||
| 61 | } else { | 67 | } else { |
| 62 | d.UpdatedAt = time.Now() | 68 | d.UpdatedAt = time.Now() |
| 63 | } | 69 | } |
| 70 | + | ||
| 64 | m := repo.TransformToModel(d) | 71 | m := repo.TransformToModel(d) |
| 65 | tx := repo.transactionContext.PgTx | 72 | tx := repo.transactionContext.PgTx |
| 66 | var err error | 73 | 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 | } |
| @@ -26,6 +26,8 @@ func (repo *UserRepository) Insert(user *domain.User) (*domain.User, error) { | @@ -26,6 +26,8 @@ func (repo *UserRepository) Insert(user *domain.User) (*domain.User, error) { | ||
| 26 | AvatarUrl: user.AvatarUrl, | 26 | AvatarUrl: user.AvatarUrl, |
| 27 | CompanyId: user.CompanyId, | 27 | CompanyId: user.CompanyId, |
| 28 | AdminType: user.AdminType, | 28 | AdminType: user.AdminType, |
| 29 | + DepartmentId: user.DepartmentId, | ||
| 30 | + PositionId: user.PositionId, | ||
| 29 | Name: user.Name, | 31 | Name: user.Name, |
| 30 | Status: user.Status, | 32 | Status: user.Status, |
| 31 | UpdatedAt: user.UpdatedAt, | 33 | UpdatedAt: user.UpdatedAt, |
| @@ -48,6 +50,8 @@ func (repo *UserRepository) Update(user *domain.User) (*domain.User, error) { | @@ -48,6 +50,8 @@ func (repo *UserRepository) Update(user *domain.User) (*domain.User, error) { | ||
| 48 | AvatarUrl: user.AvatarUrl, | 50 | AvatarUrl: user.AvatarUrl, |
| 49 | CompanyId: user.CompanyId, | 51 | CompanyId: user.CompanyId, |
| 50 | AdminType: user.AdminType, | 52 | AdminType: user.AdminType, |
| 53 | + DepartmentId: user.DepartmentId, | ||
| 54 | + PositionId: user.PositionId, | ||
| 51 | Name: user.Name, | 55 | Name: user.Name, |
| 52 | Email: user.Email, | 56 | Email: user.Email, |
| 53 | Status: user.Status, | 57 | Status: user.Status, |
| @@ -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,40 @@ func (controller *CycleController) ListCycle() { | @@ -65,7 +70,40 @@ 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 | +} | ||
| 90 | + | ||
| 91 | +func (controller *CycleController) CycleTemplateList() { | ||
| 92 | + ruService := service.NewEvaluationCycleService() | ||
| 93 | + in := &command.CycleTemplateListCommand{} | ||
| 94 | + if err := controller.Unmarshal(in); err != nil { | ||
| 95 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 96 | + } else { | ||
| 97 | + controller.Response(ruService.CycleTemplateList(in)) | ||
| 98 | + } | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +func (controller *CycleController) CycleTemplate() { | ||
| 102 | + ruService := service.NewEvaluationCycleService() | ||
| 103 | + in := &command.CycleTemplateCommand{} | ||
| 104 | + if err := controller.Unmarshal(in); err != nil { | ||
| 105 | + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | ||
| 106 | + } else { | ||
| 107 | + controller.Response(ruService.CycleTemplate(in)) | ||
| 108 | + } | ||
| 109 | +} |
| @@ -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 | } |
| @@ -18,8 +18,11 @@ func (controller *RuleController) CreateRule() { | @@ -18,8 +18,11 @@ func (controller *RuleController) CreateRule() { | ||
| 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 | } |
| @@ -82,7 +88,9 @@ func (controller *RuleController) ListRuleRelCreator() { | @@ -82,7 +88,9 @@ func (controller *RuleController) ListRuleRelCreator() { | ||
| 82 | if len(in.NameOrRemark) > 0 { | 88 | if len(in.NameOrRemark) > 0 { |
| 83 | in.NameOrRemark = "%" + in.NameOrRemark + "%" | 89 | in.NameOrRemark = "%" + in.NameOrRemark + "%" |
| 84 | } | 90 | } |
| 85 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 91 | + ua := middlewares.GetUser(controller.Ctx) |
| 92 | + in.CompanyId = ua.CompanyId | ||
| 93 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 86 | controller.Response(ruService.ListRelCreator(in)) | 94 | controller.Response(ruService.ListRelCreator(in)) |
| 87 | } | 95 | } |
| 88 | } | 96 | } |
| @@ -13,14 +13,17 @@ type TemplateController struct { | @@ -13,14 +13,17 @@ type TemplateController struct { | ||
| 13 | beego.BaseController | 13 | beego.BaseController |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | -func (controller *RoleController) CreateTemplate() { | 16 | +func (controller *TemplateController) CreateTemplate() { |
| 17 | ruService := service.NewEvaluationTemplateService() | 17 | ruService := service.NewEvaluationTemplateService() |
| 18 | in := &command.CreateTemplateCommand{} | 18 | in := &command.CreateTemplateCommand{} |
| 19 | if err := controller.Unmarshal(in); err != nil { | 19 | if err := controller.Unmarshal(in); err != nil { |
| 20 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 20 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 21 | } else { | 21 | } else { |
| 22 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 23 | - 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) | ||
| 24 | controller.Response(ruService.Create(in)) | 27 | controller.Response(ruService.Create(in)) |
| 25 | } | 28 | } |
| 26 | } | 29 | } |
| @@ -31,7 +34,9 @@ func (controller *TemplateController) UpdateTemplate() { | @@ -31,7 +34,9 @@ func (controller *TemplateController) UpdateTemplate() { | ||
| 31 | if err := controller.Unmarshal(in); err != nil { | 34 | if err := controller.Unmarshal(in); err != nil { |
| 32 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 35 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 33 | } else { | 36 | } else { |
| 34 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 37 | + ua := middlewares.GetUser(controller.Ctx) |
| 38 | + in.CompanyId = ua.CompanyId | ||
| 39 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 35 | controller.Response(ruService.Update(in)) | 40 | controller.Response(ruService.Update(in)) |
| 36 | } | 41 | } |
| 37 | } | 42 | } |
| @@ -67,7 +72,9 @@ func (controller *TemplateController) ListTemplate() { | @@ -67,7 +72,9 @@ func (controller *TemplateController) ListTemplate() { | ||
| 67 | if len(in.Name) > 0 { | 72 | if len(in.Name) > 0 { |
| 68 | in.Name = "%" + in.Name + "%" | 73 | in.Name = "%" + in.Name + "%" |
| 69 | } | 74 | } |
| 70 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 75 | + ua := middlewares.GetUser(controller.Ctx) |
| 76 | + in.CompanyId = ua.CompanyId | ||
| 77 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 71 | controller.Response(ruService.List(in)) | 78 | controller.Response(ruService.List(in)) |
| 72 | } | 79 | } |
| 73 | } | 80 | } |
| @@ -81,7 +88,9 @@ func (controller *TemplateController) ListEnableTemplate() { | @@ -81,7 +88,9 @@ func (controller *TemplateController) ListEnableTemplate() { | ||
| 81 | if err := controller.Unmarshal(in); err != nil { | 88 | if err := controller.Unmarshal(in); err != nil { |
| 82 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 89 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 83 | } else { | 90 | } else { |
| 84 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 91 | + ua := middlewares.GetUser(controller.Ctx) |
| 92 | + in.CompanyId = ua.CompanyId | ||
| 93 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 85 | controller.Response(ruService.List(in)) | 94 | controller.Response(ruService.List(in)) |
| 86 | } | 95 | } |
| 87 | } | 96 | } |
| @@ -92,7 +101,9 @@ func (controller *TemplateController) StateTemplate() { | @@ -92,7 +101,9 @@ func (controller *TemplateController) StateTemplate() { | ||
| 92 | if err := controller.Unmarshal(in); err != nil { | 101 | if err := controller.Unmarshal(in); err != nil { |
| 93 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 102 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 94 | } else { | 103 | } else { |
| 95 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 104 | + ua := middlewares.GetUser(controller.Ctx) |
| 105 | + in.CompanyId = ua.CompanyId | ||
| 106 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 96 | controller.Response(ruService.State(in)) | 107 | controller.Response(ruService.State(in)) |
| 97 | } | 108 | } |
| 98 | } | 109 | } |
| @@ -103,8 +114,11 @@ func (controller *TemplateController) CopyTemplate() { | @@ -103,8 +114,11 @@ func (controller *TemplateController) CopyTemplate() { | ||
| 103 | if err := controller.Unmarshal(in); err != nil { | 114 | if err := controller.Unmarshal(in); err != nil { |
| 104 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 115 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 105 | } else { | 116 | } else { |
| 106 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 107 | - in.CreatorId = middlewares.GetUserId(controller.Ctx) | 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) | ||
| 108 | controller.Response(ruService.Copy(in)) | 122 | controller.Response(ruService.Copy(in)) |
| 109 | } | 123 | } |
| 110 | } | 124 | } |
| @@ -51,7 +51,9 @@ func (controller *RoleController) ListForUserRole() { | @@ -51,7 +51,9 @@ func (controller *RoleController) ListForUserRole() { | ||
| 51 | if err := controller.Unmarshal(in); err != nil { | 51 | if err := controller.Unmarshal(in); err != nil { |
| 52 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 52 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 53 | } else { | 53 | } else { |
| 54 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 54 | + ua := middlewares.GetUser(controller.Ctx) |
| 55 | + in.CompanyId = ua.CompanyId | ||
| 56 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 55 | controller.Response(ruService.ListForUser(in)) | 57 | controller.Response(ruService.ListForUser(in)) |
| 56 | } | 58 | } |
| 57 | } | 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,9 @@ func (controller *RoleUserController) RemoveRoleUser() { | @@ -29,7 +31,9 @@ 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,7 +44,9 @@ func (controller *RoleUserController) ListRoleUser() { | @@ -40,7 +44,9 @@ func (controller *RoleUserController) ListRoleUser() { | ||
| 40 | if err := controller.Unmarshal(in); err != nil { | 44 | if err := controller.Unmarshal(in); err != nil { |
| 41 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) | 45 | controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error())) |
| 42 | } else { | 46 | } else { |
| 43 | - in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | 47 | + ua := middlewares.GetUser(controller.Ctx) |
| 48 | + in.CompanyId = ua.CompanyId | ||
| 49 | + //in.CompanyId = middlewares.GetCompanyId(controller.Ctx) | ||
| 44 | controller.Response(ruService.ListRole(in)) | 50 | controller.Response(ruService.ListRole(in)) |
| 45 | } | 51 | } |
| 46 | } | 52 | } |
| @@ -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 | + web.NSRouter("/templates", &controllers.CycleController{}, "Post:CycleTemplateList"), | ||
| 20 | + ) | ||
| 21 | + web.AddNamespace(ns) | ||
| 22 | +} |
| 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 | +} |
| @@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
| 9 | 9 | ||
| 10 | func init() { | 10 | func init() { |
| 11 | ns := web.NewNamespace("/v1/evaluation-rule", | 11 | ns := web.NewNamespace("/v1/evaluation-rule", |
| 12 | - web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
| 13 | web.NSRouter("/", &controllers.RuleController{}, "Post:CreateRule"), | 13 | web.NSRouter("/", &controllers.RuleController{}, "Post:CreateRule"), |
| 14 | web.NSRouter("/", &controllers.RuleController{}, "Put:UpdateRule"), | 14 | web.NSRouter("/", &controllers.RuleController{}, "Put:UpdateRule"), |
| 15 | web.NSRouter("/", &controllers.RuleController{}, "Delete:RemoveRule"), | 15 | web.NSRouter("/", &controllers.RuleController{}, "Delete:RemoveRule"), |
| @@ -9,8 +9,8 @@ import ( | @@ -9,8 +9,8 @@ import ( | ||
| 9 | 9 | ||
| 10 | func init() { | 10 | func init() { |
| 11 | ns := web.NewNamespace("/v1/evaluation-template", | 11 | ns := web.NewNamespace("/v1/evaluation-template", |
| 12 | - web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | ||
| 13 | - // web.NSRouter("/", &controllers.TemplateController{}, "Post:CreateTemplate"), | 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
| 13 | + web.NSRouter("/", &controllers.TemplateController{}, "Post:CreateTemplate"), | ||
| 14 | web.NSRouter("/", &controllers.TemplateController{}, "Put:UpdateTemplate"), | 14 | web.NSRouter("/", &controllers.TemplateController{}, "Put:UpdateTemplate"), |
| 15 | web.NSRouter("/", &controllers.TemplateController{}, "Delete:RemoveTemplate"), | 15 | web.NSRouter("/", &controllers.TemplateController{}, "Delete:RemoveTemplate"), |
| 16 | web.NSRouter("/:Id", &controllers.TemplateController{}, "Get:GetTemplate"), | 16 | web.NSRouter("/:Id", &controllers.TemplateController{}, "Get:GetTemplate"), |
| @@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
| 9 | 9 | ||
| 10 | func init() { | 10 | func init() { |
| 11 | ns := web.NewNamespace("/v1/role", | 11 | ns := web.NewNamespace("/v1/role", |
| 12 | - web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | 12 | + web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), |
| 13 | //web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"), | 13 | //web.NSRouter("/", &controllers.RoleController{}, "Post:CreateRole"), |
| 14 | //web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"), | 14 | //web.NSRouter("/", &controllers.RoleController{}, "Put:UpdateRole"), |
| 15 | //web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"), | 15 | //web.NSRouter("/", &controllers.RoleController{}, "Delete:RemoveRole"), |
| @@ -3,15 +3,16 @@ package routers | @@ -3,15 +3,16 @@ package routers | ||
| 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 | "github.com/linmadan/egglib-go/web/beego/filters" |
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/controllers" | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares" |
| 7 | ) | 8 | ) |
| 8 | 9 | ||
| 9 | func init() { | 10 | func init() { |
| 10 | ns := web.NewNamespace("/v1/role-user", | 11 | ns := web.NewNamespace("/v1/role-user", |
| 11 | - web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), | ||
| 12 | - // web.NSRouter("/", &controllers.RoleUserController{}, "Post:CreateRole"), | ||
| 13 | - // web.NSRouter("/", &controllers.RoleUserController{}, "Delete:RemoveRole"), | ||
| 14 | - // web.NSRouter("/all", &controllers.RoleUserController{}, "Post:ListRoleUser"), | 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"), | ||
| 15 | ) | 16 | ) |
| 16 | web.AddNamespace(ns) | 17 | web.AddNamespace(ns) |
| 17 | } | 18 | } |
-
请 注册 或 登录 后发表评论