作者 庄敏学

用户增加字段entryTime

正在显示 52 个修改的文件 包含 1025 行增加254 行删除
1 package main 1 package main
2 2
3 import ( 3 import (
4 - "fmt"  
5 -  
6 "github.com/beego/beego/v2/server/web" 4 "github.com/beego/beego/v2/server/web"
7 _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego" 5 _ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego"
8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer" 6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer"
9 ) 7 )
10 8
11 func main() { 9 func main() {
12 - tree := web.PrintTree()  
13 - methods := tree["Data"].(web.M)  
14 - for k, v := range methods {  
15 - fmt.Printf("%s => %v \n", k, v)  
16 - } 10 + // tree := web.PrintTree()
  11 + // methods := tree["Data"].(web.M)
  12 + // for k, v := range methods {
  13 + // fmt.Printf("%s => %v \n", k, v)
  14 + // }
17 go consumer.Run() 15 go consumer.Run()
18 web.Run() 16 web.Run()
19 } 17 }
@@ -5,8 +5,22 @@ import "github.com/beego/beego/v2/core/validation" @@ -5,8 +5,22 @@ import "github.com/beego/beego/v2/core/validation"
5 type QueryCycleCommand struct { 5 type QueryCycleCommand struct {
6 CompanyId int64 `cname:"公司ID" json:"companyId"` 6 CompanyId int64 `cname:"公司ID" json:"companyId"`
7 Name string `cname:"周期名称" json:"name"` 7 Name string `cname:"周期名称" json:"name"`
8 - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`  
9 - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` 8 + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
  9 + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
  10 +}
  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"`
10 } 24 }
11 25
12 func (in *QueryCycleCommand) Valid(validation *validation.Validation) { 26 func (in *QueryCycleCommand) Valid(validation *validation.Validation) {
@@ -16,11 +30,14 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) { @@ -16,11 +30,14 @@ func (in *QueryCycleCommand) Valid(validation *validation.Validation) {
16 } 30 }
17 } 31 }
18 32
19 -type StatisticCycleProjectUserCommand struct {  
20 - CompanyId int64 `cname:"公司ID" json:"companyId"`  
21 - CycleId int64 `cname:"周期ID" json:"cycleId,string"` 33 +func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) {
  34 +
22 } 35 }
23 36
24 -func (in *StatisticCycleProjectUserCommand) Valid(*validation.Validation) { 37 +func (in *CycleTemplateListCommand) Valid(*validation.Validation) {
  38 +
  39 +}
  40 +
  41 +func (in *CycleTemplateCommand) Valid(*validation.Validation) {
25 42
26 } 43 }
@@ -98,10 +98,11 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf @@ -98,10 +98,11 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
98 } 98 }
99 } 99 }
100 100
101 - // 插入周期中的模板数据 101 + // 周期模板数据表中插入数据
102 cycleTemplate := &domain.EvaluationCycleTemplate{ 102 cycleTemplate := &domain.EvaluationCycleTemplate{
103 Id: 0, 103 Id: 0,
104 Name: v.Name, 104 Name: v.Name,
  105 + TemplateCreatedAt: v.CreatedAt,
105 Template: v, 106 Template: v,
106 CycleId: cycle.Id, 107 CycleId: cycle.Id,
107 } 108 }
@@ -114,7 +115,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf @@ -114,7 +115,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
114 ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ 115 ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
115 Id: cycleTemplate.Id, 116 Id: cycleTemplate.Id,
116 Name: cycleTemplate.Name, 117 Name: cycleTemplate.Name,
117 - CreatedAt: cycleTemplate.CreatedAt, 118 + CreatedAt: cycleTemplate.TemplateCreatedAt, // 模板创建时间
118 }) 119 })
119 } 120 }
120 121
@@ -190,6 +191,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf @@ -190,6 +191,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf
190 cycleTemplate := &domain.EvaluationCycleTemplate{ 191 cycleTemplate := &domain.EvaluationCycleTemplate{
191 Id: 0, 192 Id: 0,
192 Name: v.Name, 193 Name: v.Name,
  194 + TemplateCreatedAt: v.CreatedAt,
193 Template: v, 195 Template: v,
194 CycleId: cycle.Id, 196 CycleId: cycle.Id,
195 } 197 }
@@ -220,7 +222,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf @@ -220,7 +222,7 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf
220 ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ 222 ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
221 Id: cycleTemplates[i].Id, 223 Id: cycleTemplates[i].Id,
222 Name: cycleTemplates[i].Name, 224 Name: cycleTemplates[i].Name,
223 - CreatedAt: cycleTemplates[i].CreatedAt, 225 + CreatedAt: cycleTemplates[i].TemplateCreatedAt,
224 }) 226 })
225 } 227 }
226 228
@@ -257,7 +259,7 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{}, @@ -257,7 +259,7 @@ func (rs *EvaluationCycleService) Get(in *command.GetCycleCommand) (interface{},
257 ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{ 259 ctAdapter.TemplateSimples = append(ctAdapter.TemplateSimples, &domain.TemplateSimple{
258 Id: cycleTemplates[i].Id, 260 Id: cycleTemplates[i].Id,
259 Name: cycleTemplates[i].Name, 261 Name: cycleTemplates[i].Name,
260 - CreatedAt: cycleTemplates[i].CreatedAt, 262 + CreatedAt: cycleTemplates[i].TemplateCreatedAt,
261 }) 263 })
262 } 264 }
263 265
@@ -361,3 +363,53 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP @@ -361,3 +363,53 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP
361 } 363 }
362 return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil 364 return map[string]interface{}{"userTotal": userTotal, "departmentTotal": departmentTotal}, nil
363 } 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 +}
@@ -8,8 +8,8 @@ type QueryProjectCommand struct { @@ -8,8 +8,8 @@ type QueryProjectCommand struct {
8 Name string `cname:"项目名称" json:"name"` 8 Name string `cname:"项目名称" json:"name"`
9 State int `cname:"项目状态" json:"state"` 9 State int `cname:"项目状态" json:"state"`
10 PmpIds []string `cname:"项目管理员ID" json:"pmpIds"` 10 PmpIds []string `cname:"项目管理员ID" json:"pmpIds"`
11 - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`  
12 - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` 11 + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
  12 + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
13 } 13 }
14 14
15 func (in *QueryProjectCommand) Valid(validation *validation.Validation) { 15 func (in *QueryProjectCommand) Valid(validation *validation.Validation) {
@@ -7,8 +7,8 @@ type QueryRuleCommand struct { @@ -7,8 +7,8 @@ type QueryRuleCommand struct {
7 NameOrRemark string `cname:"规则名称或备注" json:"nameOrRemark"` 7 NameOrRemark string `cname:"规则名称或备注" json:"nameOrRemark"`
8 Type int `cname:"评估方式(0评级、1评分)" json:"type"` 8 Type int `cname:"评估方式(0评级、1评分)" json:"type"`
9 CreatorId int64 `cname:"创建人ID" json:"creatorId,string"` 9 CreatorId int64 `cname:"创建人ID" json:"creatorId,string"`
10 - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`  
11 - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` 10 + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
  11 + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
12 } 12 }
13 13
14 func (in *QueryRuleCommand) Valid(validation *validation.Validation) { 14 func (in *QueryRuleCommand) Valid(validation *validation.Validation) {
@@ -8,7 +8,6 @@ import ( @@ -8,7 +8,6 @@ import (
8 type UpdateRuleCommand struct { 8 type UpdateRuleCommand struct {
9 Id int64 `cname:"规则ID" json:"id,string" valid:"Required"` 9 Id int64 `cname:"规则ID" json:"id,string" valid:"Required"`
10 CompanyId int64 `cname:"公司ID" json:"companyId"` 10 CompanyId int64 `cname:"公司ID" json:"companyId"`
11 - CreatorId int64 `cname:"创建人ID" json:"creatorId"`  
12 Name string `cname:"规则名称" json:"name" valid:"Required"` 11 Name string `cname:"规则名称" json:"name" valid:"Required"`
13 Remark string `cname:"规则备注" json:"remark"` 12 Remark string `cname:"规则备注" json:"remark"`
14 Type int `cname:"评估方式" json:"type"` 13 Type int `cname:"评估方式" json:"type"`
@@ -21,10 +20,6 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) { @@ -21,10 +20,6 @@ func (in *UpdateRuleCommand) Valid(validation *validation.Validation) {
21 validation.SetError("companyId", "公司ID无效") 20 validation.SetError("companyId", "公司ID无效")
22 return 21 return
23 } 22 }
24 - if in.CreatorId == 0 {  
25 - validation.SetError("creatorId", "创建人ID无效")  
26 - return  
27 - }  
28 23
29 if len(in.Name) > 40 { 24 if len(in.Name) > 40 {
30 validation.SetError("name", "名称最大长度40个字符") 25 validation.SetError("name", "名称最大长度40个字符")
@@ -35,7 +35,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac @@ -35,7 +35,7 @@ func (rs *EvaluationRuleService) Create(in *command.CreateRuleCommand) (interfac
35 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 35 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
36 } 36 }
37 if count > 0 { 37 if count > 0 {
38 - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") 38 + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估规则")
39 } 39 }
40 40
41 if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序 41 if in.Type == domain.EvaluationTypeRating { // 按等级量化值排序
@@ -82,7 +82,7 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac @@ -82,7 +82,7 @@ func (rs *EvaluationRuleService) Update(in *command.UpdateRuleCommand) (interfac
82 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 82 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
83 } 83 }
84 if count > 0 { 84 if count > 0 {
85 - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") 85 + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估规则")
86 } 86 }
87 87
88 rule, err := ruleRepository.FindOne(map[string]interface{}{"id": in.Id}) 88 rule, err := ruleRepository.FindOne(map[string]interface{}{"id": in.Id})
@@ -10,8 +10,8 @@ type QueryTemplateCommand struct { @@ -10,8 +10,8 @@ type QueryTemplateCommand struct {
10 Name string `cname:"模板名称" json:"name"` 10 Name string `cname:"模板名称" json:"name"`
11 State int `cname:"模板状态" json:"state"` 11 State int `cname:"模板状态" json:"state"`
12 CreatedAt *time.Time `cname:"创建时间" json:"createdAt"` 12 CreatedAt *time.Time `cname:"创建时间" json:"createdAt"`
13 - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`  
14 - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` 13 + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
  14 + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
15 } 15 }
16 16
17 func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { 17 func (in *QueryTemplateCommand) Valid(validation *validation.Validation) {
@@ -20,15 +20,3 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) { @@ -20,15 +20,3 @@ func (in *QueryTemplateCommand) Valid(validation *validation.Validation) {
20 return 20 return
21 } 21 }
22 } 22 }
23 -  
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 -//}  
@@ -34,7 +34,7 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( @@ -34,7 +34,7 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) (
34 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 34 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
35 } 35 }
36 if count > 0 { 36 if count > 0 {
37 - return nil, application.ThrowError(application.BUSINESS_ERROR, "名称已存在") 37 + return nil, application.ThrowError(application.BUSINESS_ERROR, "已存在相同名称的评估模板")
38 } 38 }
39 39
40 linkNodes := make([]*domain.LinkNode, 0) 40 linkNodes := make([]*domain.LinkNode, 0)
@@ -44,30 +44,35 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) ( @@ -44,30 +44,35 @@ func (rs *EvaluationTemplateService) Create(in *command.CreateTemplateCommand) (
44 Id: sid + 1, 44 Id: sid + 1,
45 Type: domain.LinkNodeSelfAssessment, 45 Type: domain.LinkNodeSelfAssessment,
46 Name: "填写自评反馈", 46 Name: "填写自评反馈",
  47 + NodeContents: make([]*domain.NodeContent, 0),
47 KpiCycle: domain.KpiCycleDay, 48 KpiCycle: domain.KpiCycleDay,
48 }) 49 })
49 linkNodes = append(linkNodes, &domain.LinkNode{ 50 linkNodes = append(linkNodes, &domain.LinkNode{
50 Id: sid + 2, 51 Id: sid + 2,
51 Type: domain.LinkNodeAllInvite, 52 Type: domain.LinkNodeAllInvite,
52 Name: "360°邀请", 53 Name: "360°邀请",
  54 + NodeContents: make([]*domain.NodeContent, 0),
53 KpiCycle: domain.KpiCycleDay, 55 KpiCycle: domain.KpiCycleDay,
54 }) 56 })
55 linkNodes = append(linkNodes, &domain.LinkNode{ 57 linkNodes = append(linkNodes, &domain.LinkNode{
56 Id: sid + 3, 58 Id: sid + 3,
57 Type: domain.LinkNodeAllAssessment, 59 Type: domain.LinkNodeAllAssessment,
58 Name: "360°评估", 60 Name: "360°评估",
  61 + NodeContents: make([]*domain.NodeContent, 0),
59 KpiCycle: domain.KpiCycleDay, 62 KpiCycle: domain.KpiCycleDay,
60 }) 63 })
61 linkNodes = append(linkNodes, &domain.LinkNode{ 64 linkNodes = append(linkNodes, &domain.LinkNode{
62 Id: sid + 4, 65 Id: sid + 4,
63 Type: domain.LinkNodeSuperiorAssessment, 66 Type: domain.LinkNodeSuperiorAssessment,
64 Name: "上级评估", 67 Name: "上级评估",
  68 + NodeContents: make([]*domain.NodeContent, 0),
65 KpiCycle: domain.KpiCycleDay, 69 KpiCycle: domain.KpiCycleDay,
66 }) 70 })
67 linkNodes = append(linkNodes, &domain.LinkNode{ 71 linkNodes = append(linkNodes, &domain.LinkNode{
68 Id: sid + 5, 72 Id: sid + 5,
69 Type: domain.LinkNodeViewResult, 73 Type: domain.LinkNodeViewResult,
70 Name: "绩效结果查看", 74 Name: "绩效结果查看",
  75 + NodeContents: make([]*domain.NodeContent, 0),
71 KpiCycle: domain.KpiCycleDay, 76 KpiCycle: domain.KpiCycleDay,
72 }) 77 })
73 78
@@ -183,8 +188,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int @@ -183,8 +188,14 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int
183 defer func() { 188 defer func() {
184 transactionContext.RollbackTransaction() 189 transactionContext.RollbackTransaction()
185 }() 190 }()
  191 +
  192 + queryOptions := tool_funs.SimpleStructToMap(in)
  193 + if in.CreatedAt == nil {
  194 + delete(queryOptions, "createdAt") // 删除创建时间
  195 + }
  196 +
186 templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext}) 197 templateRepository := factory.CreateEvaluationTemplateRepository(map[string]interface{}{"transactionContext": transactionContext})
187 - total, templates, err := templateRepository.Find(tool_funs.SimpleStructToMap(in), "linkNodes") 198 + total, templates, err := templateRepository.Find(queryOptions, "link_nodes")
188 if err != nil { 199 if err != nil {
189 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 200 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
190 } 201 }
@@ -5,6 +5,6 @@ import ( @@ -5,6 +5,6 @@ import (
5 ) 5 )
6 6
7 type RoleUserAdapter struct { 7 type RoleUserAdapter struct {
8 - domain.Role 8 + *domain.Role
9 Users []*domain.RoleContainUser `json:"users"` 9 Users []*domain.RoleContainUser `json:"users"`
10 } 10 }
@@ -5,8 +5,8 @@ import "github.com/beego/beego/v2/core/validation" @@ -5,8 +5,8 @@ import "github.com/beego/beego/v2/core/validation"
5 // QueryRoleUserCommand 查询角色列表(关联用户) 5 // QueryRoleUserCommand 查询角色列表(关联用户)
6 type QueryRoleUserCommand struct { 6 type QueryRoleUserCommand struct {
7 CompanyId int64 `cname:"公司ID" json:"companyId"` 7 CompanyId int64 `cname:"公司ID" json:"companyId"`
8 - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`  
9 - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` 8 + PageNumber int64 `cname:"分页页码" json:"pageNumber" valid:"Required"`
  9 + PageSize int64 `cname:"分页数量" json:"pageSize" valid:"Required"`
10 } 10 }
11 11
12 func (in *QueryRoleUserCommand) Valid(validation *validation.Validation) { 12 func (in *QueryRoleUserCommand) Valid(validation *validation.Validation) {
@@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ 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"
9 ) 10 )
10 11
11 type RoleService struct { 12 type RoleService struct {
@@ -91,47 +92,53 @@ func NewRoleService() *RoleService { @@ -91,47 +92,53 @@ func NewRoleService() *RoleService {
91 // return role, nil 92 // return role, nil
92 //} 93 //}
93 // 94 //
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 -//} 95 +
  96 +func (rs *RoleService) Remove(in *command.DeleteRoleCommand) (interface{}, error) {
  97 + transactionContext, err := factory.ValidateStartTransaction(in)
  98 + if err != nil {
  99 + return nil, err
  100 + }
  101 + defer func() {
  102 + transactionContext.RollbackTransaction()
  103 + }()
  104 +
  105 + roleRepository := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
  106 + roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
  107 +
  108 + role, err := roleRepository.FindOne(map[string]interface{}{"id": in.Id})
  109 + if err != nil {
  110 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  111 + }
  112 +
  113 + if role.Type == domain.RoleTypeSystem {
  114 + return nil, application.ThrowError(application.BUSINESS_ERROR, "系统预制角色不可删除")
  115 + }
  116 +
  117 + if _, err := roleRepository.Remove(role); err != nil {
  118 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  119 + }
  120 +
  121 + // 获取角色所有关联的用户,并删除
  122 + _, roleUsers, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.Id, "companyId": in.CompanyId})
  123 + if err != nil {
  124 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  125 + }
  126 + ids := make([]int64, 0)
  127 + for i := range roleUsers {
  128 + ids = append(ids, roleUsers[i].Id)
  129 + }
  130 + if len(ids) > 0 {
  131 + err := roleUserRepository.BatchDeleteById(ids)
  132 + if err != nil {
  133 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  134 + }
  135 + }
  136 +
  137 + if err := transactionContext.CommitTransaction(); err != nil {
  138 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  139 + }
  140 + return role, nil
  141 +}
135 142
136 func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) { 143 func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{}, error) {
137 transactionContext, err := factory.StartTransaction() 144 transactionContext, err := factory.StartTransaction()
@@ -150,11 +157,37 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ @@ -150,11 +157,37 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{
150 if err != nil { 157 if err != nil {
151 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 158 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
152 } 159 }
153 - if len(roles) == 0 {  
154 - return nil, application.ThrowError(application.BUSINESS_ERROR, "未找到角色数据")  
155 - }  
156 160
157 adapterList := make([]*adapter.RoleUserAdapter, 0) 161 adapterList := make([]*adapter.RoleUserAdapter, 0)
  162 +
  163 + // 如果不存在系统预支hrbp角色时,插入一条数据
  164 + var havaSystemType = false
  165 + for i := range roles {
  166 + if roles[i].Type == domain.RoleTypeSystem {
  167 + havaSystemType = true
  168 + break
  169 + }
  170 + }
  171 + if !havaSystemType {
  172 + role := &domain.Role{
  173 + Id: 0,
  174 + Name: "HRBP",
  175 + Type: domain.RoleTypeSystem,
  176 + Description: "拥有全部权限,预置角色不可删除",
  177 + CompanyId: in.CompanyId,
  178 + }
  179 + role, err = roleRepository.Insert(role)
  180 + if err != nil {
  181 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  182 + }
  183 +
  184 + // 创建HRBP角色
  185 + roleUser := &adapter.RoleUserAdapter{}
  186 + roleUser.Role = role
  187 + roleUser.Users = make([]*domain.RoleContainUser, 0)
  188 + adapterList = append(adapterList, roleUser)
  189 + }
  190 +
158 for i := range roles { 191 for i := range roles {
159 v := roles[i] 192 v := roles[i]
160 tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id) 193 tempList, err := ruRepository.FindAllContainUser(1, 10, in.CompanyId, v.Id)
@@ -162,13 +195,14 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{ @@ -162,13 +195,14 @@ func (rs *RoleService) ListForUser(in *command.QueryRoleUserCommand) (interface{
162 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 195 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
163 } 196 }
164 roleUser := &adapter.RoleUserAdapter{} 197 roleUser := &adapter.RoleUserAdapter{}
165 - roleUser.Id = v.Id  
166 - roleUser.Name = v.Name  
167 - roleUser.Type = v.Type  
168 - roleUser.Description = v.Description  
169 - roleUser.CompanyId = v.CompanyId 198 + roleUser.Role = v
170 roleUser.Users = tempList 199 roleUser.Users = tempList
171 adapterList = append(adapterList, roleUser) 200 adapterList = append(adapterList, roleUser)
172 } 201 }
  202 +
  203 + if err := transactionContext.CommitTransaction(); err != nil {
  204 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  205 + }
  206 +
173 return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil 207 return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil
174 } 208 }
@@ -28,6 +28,11 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{ @@ -28,6 +28,11 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{
28 }() 28 }()
29 roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext}) 29 roleUserRepository := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
30 30
  31 + //int64Array := make([]int64, 0)
  32 + //for i := range in.UserIds {
  33 + // int64Num, _ := strconv.ParseInt(in.UserIds[i], 10, 64)
  34 + // int64Array = append(int64Array, int64Num)
  35 + //}
31 // 检测已存在的关联用户 36 // 检测已存在的关联用户
32 _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999}) 37 _, rus, err := roleUserRepository.Find(map[string]interface{}{"roleId": in.RoleId, "companyId": in.CompanyId, "userIds": in.UserIds, "limit": 9999999})
33 if err != nil { 38 if err != nil {
@@ -4,6 +4,7 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" @@ -4,6 +4,7 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
4 4
5 //评估内容详情 5 //评估内容详情
6 type AssessInfoResp struct { 6 type AssessInfoResp struct {
  7 + AssessId int `json:"assessId"`
7 CycleId int64 `json:"cycleId"` //周期id 8 CycleId int64 `json:"cycleId"` //周期id
8 CycleName string `json:"cycleName"` //周期名称 9 CycleName string `json:"cycleName"` //周期名称
9 EvaluationProjectId int `json:"evaluationProjectId"` //项目id 10 EvaluationProjectId int `json:"evaluationProjectId"` //项目id
@@ -11,15 +12,27 @@ type AssessInfoResp struct { @@ -11,15 +12,27 @@ type AssessInfoResp struct {
11 BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05 12 BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
12 EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05 13 EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
13 Status string `json:"status"` //完成状态 14 Status string `json:"status"` //完成状态
14 - TargetUserId int `json:"targetUser"` //  
15 - TargetUserName string `json:"targetUserName"` //  
16 - AssessContent []AssessContent `json:"assessContent"` //评估内容 15 + TargetUserId int `json:"targetUser"` //目标用户
  16 + TargetUserName string `json:"targetUserName"` //目标用户名称
  17 + CompanyId int `json:"companyId,string"` //
  18 + CompanyName string `json:"companyName"` //公司名称
  19 + SupperUser string `json:"superUser"` //目标用户的上级
  20 + DutyTime string `json:"dutyTime"` //入职时间 //
  21 + AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
17 } 22 }
18 23
19 type AssessContent struct { 24 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 + Category string `json:"category"` //comment:"类别"
  26 + Name string `json:"name"` // comment:"名称"
  27 + PromptTitle string `json:"promptTitle"` //comment:"提示项标题"
  28 + PromptText string `json:"promptText"` // comment:"提示项正文"
  29 + Rule AssessContentRule `json:"rules"` //评定规则
  30 + Value string `json:"value"` // 实际填写评定值
  31 + Remark []domain.AssessContemtRemark `json:"entryItems"` // comment:"填写反馈"
  32 +}
  33 +
  34 +type AssessContentRule struct {
  35 + Types int `json:"types"` //评估方式(0评级、1评分)
  36 + Rating domain.Rating `json:"rating"` //评级
  37 + Score domain.Score `json:"score"` //评分
25 } 38 }
@@ -2,6 +2,7 @@ package adapter @@ -2,6 +2,7 @@ package adapter
2 2
3 import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 3 import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
4 4
  5 +//获取评估的邀请人
5 type AssessInviteUserResp struct { 6 type AssessInviteUserResp struct {
6 LinkNodeId int `json:"linkNodeId"` 7 LinkNodeId int `json:"linkNodeId"`
7 LinkNodeName string `json:"linkNodeName"` 8 LinkNodeName string `json:"linkNodeName"`
  1 +package adapter
  2 +
  3 +type ListInviteUserAssessResp struct {
  4 + TableHeader []ListTableHeader
  5 + List []map[string]string
  6 + Total int
  7 +}
  8 +type ListTableHeader struct {
  9 + Key string
  10 + Name string
  11 +}
  1 +package adapter
  2 +
  3 +type ListSupperAssessResp struct {
  4 + AssessId int `json:"assessId"` //
  5 + UserName string `json:"userName"` //用户名称
  6 + EndTime string `json:"endTime"` //截止时间
  7 + InviteTotal int `json:"inviteCompleted"` //邀请总数
  8 + InviteUncompleted int `json:"inviteUncompleted"` //邀请未完成
  9 + Department string `json:"department"` //部门
  10 + Position string `json:"position"` //职位
  11 + DutyTime string `json:"dutyTime"` //入职时间
  12 +}
  1 +package adapter
  2 +
  3 +type SelectInviteUser struct {
  4 + UserId int `json:"userId,string"`
  5 + UserName string `json:"userName"` //
  6 + IsSupper bool `json:"isSupper"` // 是否,是直属上级
  7 + Types int `json:"types"` // 1:相同上级的同事 2:不相同上级的同事
  8 +}
1 package query 1 package query
2 2
  3 +//获取评估任务详情
3 type AssessInfoQuery struct { 4 type AssessInfoQuery struct {
4 - AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id  
5 - TargetUserId int `json:"targetUserId"` //被评估的人id  
6 - CompanyId int `json:"companyId"` //公司id  
7 - 5 + AssessId int `json:"assessId"` //
  6 + CompanyId int `json:"companyId"` //
8 } 7 }
  1 +package query
  2 +
  3 +//获取员工自评填写详情
  4 +type AssessSelfInfoQuery struct {
  5 + AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id
  6 + TargetUserId int `json:"targetUserId"` //被评估的人id
  7 + CompanyId int `json:"companyId"` //公司id
  8 +
  9 +}
@@ -2,6 +2,6 @@ package query @@ -2,6 +2,6 @@ package query
2 2
3 type GetAssessInviteUserQuery struct { 3 type GetAssessInviteUserQuery struct {
4 CompanyId int `json:"companyId"` //对公司 4 CompanyId int `json:"companyId"` //对公司
5 - UsrId int `json:"usrId"` //被评估的员工id 5 + UserId int `json:"userId"` //被评估的员工id
6 AssessTaskId int `json:"assessTaskId"` //评估任务的id 6 AssessTaskId int `json:"assessTaskId"` //评估任务的id
7 } 7 }
  1 +package query
  2 +
  3 +type ListSupperAssessQuery struct {
  4 + PageNumber int `json:"pageNumber"`
  5 + PageSize int `json:"pageSize"`
  6 + UserName string `json:"userName"` //查询条件 员工的名称
  7 + CompanyId int `json:"companyId"` //
  8 + ExecutorId int `json:"executorId"` //评估的执行人
  9 + AssessTaskkId int `json:"assessTaskId"` //评估任务id
  10 +}
  1 +package query
  2 +
  3 +type ListInviteUserAssessQuery struct {
  4 + PageNumber int `json:"pageNumber"`
  5 + PageSize int `json:"pageSize"`
  6 + UserName string `json:"userName"` //查询条件 员工的名称
  7 + CompanyId int `json:"companyId"` //
  8 + ExecutorId int `json:"executorId"` //评估的执行人
  9 + AssessTaskkId int `json:"assessTaskId"` //评估任务id
  10 +}
  1 +package query
  2 +
  3 +type SelectAssessInviteUser struct {
  4 + TargetUserId int `json:"targetUserId"` //被评估的员工userId
  5 + CompanyId int `json:"companyId"`
  6 + InviteUserName string `json:"inviteUserName"`
  7 + PageSize int `json:"pageSize"`
  8 + PageNumber int `json:"pageNumber"`
  9 +}
@@ -575,7 +575,7 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU @@ -575,7 +575,7 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU
575 _, assessList, err := assessReps.Find(map[string]interface{}{ 575 _, assessList, err := assessReps.Find(map[string]interface{}{
576 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 576 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
577 "staffAssessTaskId": param.AssessTaskId, 577 "staffAssessTaskId": param.AssessTaskId,
578 - "targetUserId": param.UsrId, 578 + "targetUserId": param.UserId,
579 }) 579 })
580 if err != nil { 580 if err != nil {
581 return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error()) 581 return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
@@ -586,6 +586,8 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU @@ -586,6 +586,8 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU
586 586
587 result := adapter.AssessInviteUserResp{ 587 result := adapter.AssessInviteUserResp{
588 AssessTaskId: assessTaskData.Id, 588 AssessTaskId: assessTaskData.Id,
  589 + InviteDiffSuper: []domain.StaffDesc{},
  590 + InviteSameSuper: []domain.StaffDesc{},
589 } 591 }
590 for _, v := range assessTaskData.StepList { 592 for _, v := range assessTaskData.StepList {
591 if v.LinkNodeType != domain.LinkNodeAllInvite { 593 if v.LinkNodeType != domain.LinkNodeAllInvite {
@@ -608,8 +610,8 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU @@ -608,8 +610,8 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU
608 return &result, nil 610 return &result, nil
609 } 611 }
610 612
611 -// 获取某个员工360邀请的人员  
612 -func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) { 613 +// 保存某个员工360邀请的人员
  614 +func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (map[string]interface{}, error) {
613 inviteSameSuperId := []int{} 615 inviteSameSuperId := []int{}
614 InviteDiffSuperId := []int{} 616 InviteDiffSuperId := []int{}
615 for _, v := range param.InviteDiffSuper { 617 for _, v := range param.InviteDiffSuper {
@@ -657,6 +659,19 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -657,6 +659,19 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
657 return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error()) 659 return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
658 } 660 }
659 661
  662 + //获取邀请评估的节点
  663 + var inviteNode *domain.AssessTaskStep
  664 + for _, v := range assessTaskData.StepList {
  665 + if v.LinkNodeType == domain.LinkNodeAllAssessment {
  666 + cp := v
  667 + inviteNode = &cp
  668 + break
  669 + }
  670 + }
  671 + if inviteNode == nil {
  672 + return nil, application.ThrowError(application.ARG_ERROR, "评估任务没有邀请评估的环节")
  673 + }
  674 +
660 targetUser, err := userRepo.FindOne(map[string]interface{}{ 675 targetUser, err := userRepo.FindOne(map[string]interface{}{
661 "id": param.TargetUserId, 676 "id": param.TargetUserId,
662 }) 677 })
@@ -713,50 +728,108 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -713,50 +728,108 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
713 }) 728 })
714 } 729 }
715 } 730 }
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 - 731 + //获取员工邀请的人
  732 + _, assessList, err := assessReps.Find(map[string]interface{}{
  733 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  734 + "staffAssessTaskId": param.AssessTaskId,
  735 + "targetUserId": param.TargetUserId,
  736 + })
  737 + if err != nil {
  738 + return nil, application.ThrowError(application.ARG_ERROR, "获取员工邀请的人"+err.Error())
  739 + }
  740 + //比对新旧数据
  741 + nowTime := time.Now()
  742 + assessMap := map[string]*domain.StaffAssess{}
  743 + for _, v := range assessList {
  744 + //假设为删除
  745 + v.DeletedAt = &nowTime
  746 + key := fmt.Sprintf("%s%d", string(v.Types), v.Executor.UserId)
  747 + assessMap[key] = v
  748 + }
  749 + newAssessList := []*domain.StaffAssess{}
  750 + //邀请同上级的员工
  751 + for _, v := range inviteSameSuper {
  752 + key := fmt.Sprintf("%s%d", string(domain.AssessInviteSameSuper), v.UserId)
  753 + if _, ok := assessMap[key]; ok {
  754 + assessMap[key].DeletedAt = nil
  755 + } else {
  756 + newAssessList = append(newAssessList, &domain.StaffAssess{
  757 + Id: 0,
  758 + CompanyId: assessTaskData.CompanyId,
  759 + EvaluationProjectId: assessTaskData.EvaluationProjectId,
  760 + EvaluationProjectName: assessTaskData.EvaluationProjectName,
  761 + CycleId: assessTaskData.CycleId,
  762 + CycleName: assessTaskData.CycleName,
  763 + StaffAssessTaskId: assessTaskData.Id,
  764 + TargetUser: domain.StaffDesc{
  765 + UserId: int(targetUser.Id),
  766 + Account: targetUser.Account,
  767 + UserName: targetUser.Name,
  768 + },
  769 + TargetDepartment: targetUserDepartment,
  770 + Executor: v,
  771 + Types: domain.AssessInviteSameSuper,
  772 + LinkNodeId: inviteNode.LinkNodeId,
  773 + LinkNodeName: inviteNode.LinkNodeName,
  774 + Status: domain.StaffAssessUncompleted,
  775 + BeginTime: inviteNode.BeginTime,
  776 + EndTime: inviteNode.EndTime,
  777 + CreatedAt: nowTime,
  778 + UpdatedAt: nowTime,
  779 + DeletedAt: nil,
  780 + })
  781 + }
  782 + }
  783 + for _, v := range inviteDiffSuper {
  784 + key := fmt.Sprintf("%s%d", string(domain.AssessInviteDiffSuper), v.UserId)
  785 + if _, ok := assessMap[key]; ok {
  786 + assessMap[key].DeletedAt = nil
  787 + } else {
  788 + newAssessList = append(newAssessList, &domain.StaffAssess{
  789 + Id: 0,
  790 + CompanyId: assessTaskData.CompanyId,
  791 + EvaluationProjectId: assessTaskData.EvaluationProjectId,
  792 + EvaluationProjectName: assessTaskData.EvaluationProjectName,
  793 + CycleId: assessTaskData.CycleId,
  794 + CycleName: assessTaskData.CycleName,
  795 + StaffAssessTaskId: assessTaskData.Id,
  796 + TargetUser: domain.StaffDesc{
  797 + UserId: int(targetUser.Id),
  798 + Account: targetUser.Account,
  799 + UserName: targetUser.Name,
  800 + },
  801 + TargetDepartment: targetUserDepartment,
  802 + Executor: v,
  803 + Types: domain.AssessInviteDiffSuper,
  804 + LinkNodeId: inviteNode.LinkNodeId,
  805 + LinkNodeName: inviteNode.LinkNodeName,
  806 + Status: domain.StaffAssessUncompleted,
  807 + BeginTime: inviteNode.BeginTime,
  808 + EndTime: inviteNode.EndTime,
  809 + CreatedAt: nowTime,
  810 + UpdatedAt: nowTime,
  811 + DeletedAt: nil,
  812 + })
  813 + }
  814 + }
  815 + assessList = append(assessList, newAssessList...)
  816 + for i := range assessList {
  817 + _, err = assessReps.Save(assessList[i])
  818 + if err != nil {
  819 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存员工邀请评估"+err.Error())
  820 + }
  821 + }
730 if err := transactionContext.CommitTransaction(); err != nil { 822 if err := transactionContext.CommitTransaction(); err != nil {
731 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 823 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
732 } 824 }
733 -  
734 - result := adapter.AssessInviteUserResp{  
735 - AssessTaskId: assessTaskData.Id, 825 + result := map[string]interface{}{
  826 + "assessTaskId": assessTaskData.Id,
736 } 827 }
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 828 + return result, nil
756 } 829 }
757 830
758 // 获取员工自评的评估内容详情 831 // 获取员工自评的评估内容详情
759 -func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) { 832 +func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuery) (*adapter.AssessInfoResp, error) {
760 transactionContext, err := factory.CreateTransactionContext(nil) 833 transactionContext, err := factory.CreateTransactionContext(nil)
761 if err != nil { 834 if err != nil {
762 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 835 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -770,7 +843,6 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( @@ -770,7 +843,6 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (
770 assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{ 843 assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
771 "transactionContext": transactionContext, 844 "transactionContext": transactionContext,
772 }) 845 })
773 -  
774 //获取员工的评估 846 //获取员工的评估
775 _, assessList, err := assessReps.Find(map[string]interface{}{ 847 _, assessList, err := assessReps.Find(map[string]interface{}{
776 "companyId": param.CompanyId, 848 "companyId": param.CompanyId,
@@ -785,43 +857,32 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( @@ -785,43 +857,32 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (
785 return &adapter.AssessInfoResp{}, nil 857 return &adapter.AssessInfoResp{}, nil
786 } 858 }
787 assessData := assessList[0] 859 assessData := assessList[0]
788 - projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ 860 +
  861 + assessContentList := []*domain.StaffAssessContent{}
  862 + if assessData.Status == domain.StaffAssessCompleted {
  863 + //已完成
  864 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
789 "transactionContext": transactionContext, 865 "transactionContext": transactionContext,
790 }) 866 })
791 - projectData, err := projectRepo.FindOne(map[string]interface{}{  
792 - "id": assessData.EvaluationProjectId, 867 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
  868 + "staffAssessId": assessData.Id,
793 }) 869 })
794 if err != nil { 870 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 871 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
805 } 872 }
  873 + } else if assessData.Status == domain.StaffAssessUncompleted {
  874 + //未完成
  875 + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
  876 + if err != nil {
  877 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
806 } 878 }
807 - if selfLinkNode == nil {  
808 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估自评配置")  
809 } 879 }
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 { 880 if err := transactionContext.CommitTransaction(); err != nil {
821 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 881 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
822 } 882 }
823 883
824 result := adapter.AssessInfoResp{ 884 result := adapter.AssessInfoResp{
  885 + AssessId: assessData.Id,
825 CycleId: assessData.CycleId, 886 CycleId: assessData.CycleId,
826 CycleName: assessData.CycleName, 887 CycleName: assessData.CycleName,
827 EvaluationProjectId: assessData.EvaluationProjectId, 888 EvaluationProjectId: assessData.EvaluationProjectId,
@@ -831,18 +892,350 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) ( @@ -831,18 +892,350 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (
831 Status: string(assessData.Status), 892 Status: string(assessData.Status),
832 TargetUserId: assessData.TargetUser.UserId, 893 TargetUserId: assessData.TargetUser.UserId,
833 TargetUserName: assessData.TargetUser.UserName, 894 TargetUserName: assessData.TargetUser.UserName,
834 - AssessContent: nil, 895 + AssessContent: assessContentList,
  896 + }
  897 + return &result, nil
  898 +}
  899 +
  900 +// 获取未完成的员工评估内容
  901 +func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext application.TransactionContext,
  902 + assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) {
  903 + projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
  904 + "transactionContext": transactionContext,
  905 + })
  906 + projectData, err := projectRepo.FindOne(map[string]interface{}{
  907 + "id": assess.EvaluationProjectId,
  908 + })
  909 + if err != nil {
  910 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  911 + }
  912 + var linkNode *domain.LinkNode
  913 + for _, v := range projectData.Template.LinkNodes {
  914 + if v.Id == int64(assess.LinkNodeId) {
  915 + linkNode = v
  916 + break
  917 + }
  918 + }
  919 + if linkNode == nil {
  920 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获得评估环节配置"+err.Error())
  921 + }
  922 + ruleRepo := factory.CreateEvaluationRuleRepository(map[string]interface{}{
  923 + "transactionContext": transactionContext,
  924 + })
  925 + ruleMap := map[int64]*domain.EvaluationRule{}
  926 + for _, v := range linkNode.NodeContents {
  927 + if _, ok := ruleMap[v.RuleId]; ok {
  928 + continue
  929 + }
  930 + ruleData, err := ruleRepo.FindOne(map[string]interface{}{
  931 + "id": v.RuleId,
  932 + })
  933 + if err == nil {
  934 + ruleMap[v.RuleId] = ruleData
835 } 935 }
836 - assessContent := make([]adapter.AssessContent, 0)  
837 - for _, v := range selfLinkNode.NodeContents {  
838 - assessContent = append(assessContent, adapter.AssessContent{ 936 + }
  937 +
  938 + var contentList []*domain.StaffAssessContent
  939 + nowTime := time.Now()
  940 + for i, v := range linkNode.NodeContents {
  941 + item := &domain.StaffAssessContent{
  942 + Id: 0,
  943 + StaffAssessId: assess.Id,
  944 + SortBy: i + 1,
839 Category: v.Category, 945 Category: v.Category,
840 Name: v.Name, 946 Name: v.Name,
841 PromptTitle: v.PromptTitle, 947 PromptTitle: v.PromptTitle,
842 PromptText: v.PromptText, 948 PromptText: v.PromptText,
843 - EntryItems: v.EntryItems, 949 + Remark: nil,
  950 + Value: "",
  951 + ReteResult: "",
  952 + CreatedAt: nowTime,
  953 + UpdatedAt: nowTime,
  954 + DeletedAt: nil,
  955 + // Rule: ,
  956 + }
  957 + if ruleVal, ok := ruleMap[v.RuleId]; ok {
  958 + item.Rule = *ruleVal
  959 + }
  960 + var remarks []domain.AssessContemtRemark
  961 + for _, vv := range v.EntryItems {
  962 + ritem := domain.AssessContemtRemark{
  963 + Title: vv.Title,
  964 + HintText: vv.HintText,
  965 + RemarkText: "",
  966 + }
  967 + remarks = append(remarks, ritem)
  968 + }
  969 + item.Remark = remarks
  970 + contentList = append(contentList, item)
  971 + }
  972 + return contentList, nil
  973 +}
  974 +
  975 +// 选择员工评估可邀请的用户
  976 +func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {
  977 + transactionContext, err := factory.CreateTransactionContext(nil)
  978 + if err != nil {
  979 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  980 + }
  981 + if err := transactionContext.StartTransaction(); err != nil {
  982 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  983 + }
  984 + defer func() {
  985 + _ = transactionContext.RollbackTransaction()
  986 + }()
  987 + //获取被评估的目标用户
  988 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  989 + "transactionContext": transactionContext,
  990 + })
  991 + targetUser, err := userRepo.FindOne(map[string]interface{}{
  992 + "id": param.TargetUserId,
  993 + })
  994 + if err != nil {
  995 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
  996 + }
  997 + //获取被评估的目标用户的部门
  998 + departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
  999 + "transactionContext": transactionContext,
  1000 + })
  1001 +
  1002 + _, targetUserDepartment, err := departmentRepo.Find(map[string]interface{}{
  1003 + "ids": targetUser.DepartmentId,
844 }) 1004 })
  1005 +
  1006 + if err != nil {
  1007 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
  1008 + }
  1009 + //获取部门主管的id
  1010 + targetUserCharge := map[int64]struct{}{}
  1011 + for _, v := range targetUserDepartment {
  1012 + for _, vv := range v.ChargeUserIds {
  1013 + targetUserCharge[vv] = struct{}{}
  1014 + }
  1015 + }
  1016 + //
  1017 + targetUserDepartmentMap := map[int64]struct{}{}
  1018 + for _, v := range targetUserDepartment {
  1019 + targetUserDepartmentMap[v.Id] = struct{}{}
  1020 + }
  1021 + //查询员工数据
  1022 + condition := map[string]interface{}{
  1023 + "companyId": param.CompanyId,
  1024 + "name": param.InviteUserName,
  1025 + "limit": 20,
  1026 + }
  1027 + if param.PageSize > 0 {
  1028 + condition["limit"] = param.PageSize
  1029 + }
  1030 + offset := (param.PageNumber - 1) * param.PageSize
  1031 + if offset > 0 {
  1032 + condition["offset"] = offset
  1033 + }
  1034 + cnt, userList, err := userRepo.Find(condition)
  1035 + if err != nil {
  1036 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())
  1037 + }
  1038 + if err := transactionContext.CommitTransaction(); err != nil {
  1039 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1040 + }
  1041 + listData := []adapter.SelectInviteUser{}
  1042 + for _, v := range userList {
  1043 + item := adapter.SelectInviteUser{
  1044 + UserId: int(v.Id),
  1045 + UserName: v.Name,
  1046 + IsSupper: false,
  1047 + Types: 2, //默认是不同上级
  1048 + }
  1049 + if _, ok := targetUserCharge[v.Id]; ok {
  1050 + item.IsSupper = true
  1051 + }
  1052 + for _, vv := range v.DepartmentId {
  1053 + if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
  1054 + item.Types = 1 //设为相同上级
  1055 + break
  1056 + }
  1057 + }
  1058 + listData = append(listData, item)
  1059 + }
  1060 + return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
  1061 +}
  1062 +
  1063 +// 获取我的360评估,用户列表和评估填写的值
  1064 +func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserAssessQuery) (
  1065 + *adapter.ListInviteUserAssessResp, error) {
  1066 + transactionContext, err := factory.CreateTransactionContext(nil)
  1067 + if err != nil {
  1068 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1069 + }
  1070 + if err := transactionContext.StartTransaction(); err != nil {
  1071 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1072 + }
  1073 + defer func() {
  1074 + _ = transactionContext.RollbackTransaction()
  1075 + }()
  1076 + //获取对应的评估任务
  1077 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  1078 + "transactionContext": transactionContext,
  1079 + })
  1080 + //获取 executorId 对应的360评估任务 用户
  1081 + cnt, assessList, err := assessRepo.Find(map[string]interface{}{
  1082 + "staffAssessTaskId": param.AssessTaskkId,
  1083 + "executorId": param.ExecutorId,
  1084 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  1085 + })
  1086 + if err != nil {
  1087 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1088 + }
  1089 + // 获取已经填报的内容
  1090 + if err := transactionContext.CommitTransaction(); err != nil {
  1091 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1092 + }
  1093 +
  1094 + //TODO 评估填写数据行转列
  1095 + tableHeader := []adapter.ListTableHeader{
  1096 + {Key: "userName", Name: "姓名"},
  1097 + {Key: "status", Name: "状态"},
  1098 + {Key: "types", Name: "360°评估关系"},
  1099 + {Key: "endTime", Name: "360°评估截止日期"},
  1100 + }
  1101 + listData := []map[string]string{}
  1102 + for _, v := range assessList {
  1103 + m := map[string]string{
  1104 + "userName": v.TargetUser.UserName,
  1105 + "status": string(v.Status),
  1106 + "types": string(v.Types),
  1107 + "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
  1108 + }
  1109 + listData = append(listData, m)
  1110 + }
  1111 + _ = tableHeader
  1112 +
  1113 + result := adapter.ListInviteUserAssessResp{
  1114 + TableHeader: tableHeader,
  1115 + List: listData,
  1116 + Total: cnt,
845 } 1117 }
846 - result.AssessContent = assessContent  
847 return &result, nil 1118 return &result, nil
848 } 1119 }
  1120 +
  1121 +// 获取上级评估成员列表
  1122 +func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQuery) (map[string]interface{}, error) {
  1123 + transactionContext, err := factory.CreateTransactionContext(nil)
  1124 + if err != nil {
  1125 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1126 + }
  1127 + if err := transactionContext.StartTransaction(); err != nil {
  1128 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1129 + }
  1130 + defer func() {
  1131 + _ = transactionContext.RollbackTransaction()
  1132 + }()
  1133 + //获取对应的评估任务
  1134 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  1135 + "transactionContext": transactionContext,
  1136 + })
  1137 + //获取 executorId 对应的上级评估列表
  1138 + cnt, assessList, err := assessRepo.Find(map[string]interface{}{
  1139 + "staffAssessTaskId": param.AssessTaskkId,
  1140 + "executorId": param.ExecutorId,
  1141 + "typesList": []string{string(domain.AssessSuper)},
  1142 + })
  1143 + if err != nil {
  1144 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1145 + }
  1146 + if err := transactionContext.CommitTransaction(); err != nil {
  1147 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1148 + }
  1149 +
  1150 + resultList := []adapter.ListSupperAssessResp{}
  1151 + for _, v := range assessList {
  1152 + item := adapter.ListSupperAssessResp{
  1153 + AssessId: v.Id,
  1154 + UserName: v.TargetUser.UserName,
  1155 + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
  1156 + InviteUncompleted: 0,
  1157 + InviteTotal: 5,
  1158 + Department: "",
  1159 + Position: "",
  1160 + DutyTime: "",
  1161 + }
  1162 +
  1163 + for _, vv := range v.TargetDepartment {
  1164 + item.Department += vv.DepartmentName + " "
  1165 + }
  1166 + resultList = append(resultList, item)
  1167 + }
  1168 + return tool_funs.SimpleWrapGridMap(int64(cnt), resultList), nil
  1169 +}
  1170 +
  1171 +// 根据staffAssessId 获取评估的填写信息
  1172 +func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  1173 + transactionContext, err := factory.CreateTransactionContext(nil)
  1174 + if err != nil {
  1175 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1176 + }
  1177 + if err := transactionContext.StartTransaction(); err != nil {
  1178 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1179 + }
  1180 + defer func() {
  1181 + _ = transactionContext.RollbackTransaction()
  1182 + }()
  1183 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  1184 + "transactionContext": transactionContext,
  1185 + })
  1186 + //获取员工的评估
  1187 + _, assessList, err := assessReps.Find(map[string]interface{}{
  1188 + "companyId": param.CompanyId,
  1189 + "id": param.AssessId,
  1190 + })
  1191 + if err != nil {
  1192 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
  1193 + }
  1194 + if len(assessList) == 0 {
  1195 + return &adapter.AssessInfoResp{}, nil
  1196 + }
  1197 + assessData := assessList[0]
  1198 + assessContentList := []*domain.StaffAssessContent{}
  1199 + if assessData.Status == domain.StaffAssessCompleted {
  1200 + //已完成
  1201 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  1202 + "transactionContext": transactionContext,
  1203 + })
  1204 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
  1205 + "staffAssessId": assessData.Id,
  1206 + })
  1207 + if err != nil {
  1208 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  1209 + }
  1210 + } else if assessData.Status == domain.StaffAssessUncompleted {
  1211 + //未完成
  1212 + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
  1213 + if err != nil {
  1214 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  1215 + }
  1216 + }
  1217 + if err := transactionContext.CommitTransaction(); err != nil {
  1218 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1219 + }
  1220 +
  1221 + result := adapter.AssessInfoResp{
  1222 + AssessId: assessData.Id,
  1223 + CycleId: assessData.CycleId,
  1224 + CycleName: assessData.CycleName,
  1225 + EvaluationProjectId: assessData.EvaluationProjectId,
  1226 + EvaluationProjectName: assessData.EvaluationProjectName,
  1227 + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
  1228 + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
  1229 + Status: string(assessData.Status),
  1230 + TargetUserId: assessData.TargetUser.UserId,
  1231 + TargetUserName: assessData.TargetUser.UserName,
  1232 + AssessContent: assessContentList,
  1233 + }
  1234 + return &result, nil
  1235 +}
  1236 +
  1237 +// 获取员工的某次评估任务的360评估记录录
  1238 +// assessTaskId targetUserId
  1239 +func (srv StaffAssessServeice) AssessInviteList() error {
  1240 + return nil
  1241 +}
@@ -17,7 +17,7 @@ const ( @@ -17,7 +17,7 @@ const (
17 type TemplateSimple struct { 17 type TemplateSimple struct {
18 Id int64 `json:"id,string" comment:"模板ID"` 18 Id int64 `json:"id,string" comment:"模板ID"`
19 Name string `json:"name" comment:"模板名称"` 19 Name string `json:"name" comment:"模板名称"`
20 - CreatedAt time.Time `json:"createdAt" comment:"创建时间"` 20 + CreatedAt time.Time `json:"createdAt" comment:"模板创建时间"`
21 } 21 }
22 22
23 type EvaluationCycle struct { 23 type EvaluationCycle struct {
@@ -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:"创建时间"`
@@ -33,7 +33,7 @@ type EntryItem struct { @@ -33,7 +33,7 @@ type EntryItem struct {
33 type NodeContent struct { 33 type NodeContent struct {
34 Category string `json:"category" comment:"类别"` 34 Category string `json:"category" comment:"类别"`
35 Name string `json:"name" comment:"名称"` 35 Name string `json:"name" comment:"名称"`
36 - RuleId int64 `json:"ruleId" comment:"评估规则ID"` 36 + RuleId int64 `json:"ruleId,string" comment:"评估规则ID"`
37 Rule *EvaluationRule `json:"rule" comment:"评估规则对象"` 37 Rule *EvaluationRule `json:"rule" comment:"评估规则对象"`
38 PromptTitle string `json:"promptTitle" comment:"提示项标题"` 38 PromptTitle string `json:"promptTitle" comment:"提示项标题"`
39 PromptText string `json:"promptText" comment:"提示项正文"` 39 PromptText string `json:"promptText" comment:"提示项正文"`
@@ -59,7 +59,7 @@ type LinkNode struct { @@ -59,7 +59,7 @@ type LinkNode struct {
59 NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"` 59 NodeContents []*NodeContent `json:"nodeContents" comment:"环节-评估内容"`
60 TimeStart *time.Time `json:"timeStart" comment:"起始时间"` 60 TimeStart *time.Time `json:"timeStart" comment:"起始时间"`
61 TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"` 61 TimeEnd *time.Time `json:"timeEnd" comment:"截至时间"`
62 - KpiCycle int `json:"state" comment:"考核周期(1日、2周、3月)"` 62 + KpiCycle int `json:"kpiCycle" comment:"考核周期(1日、2周、3月)"`
63 //NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"` 63 //NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"`
64 64
65 } 65 }
@@ -10,7 +10,7 @@ const ( @@ -10,7 +10,7 @@ const (
10 type Role struct { 10 type Role struct {
11 Id int64 `json:"id,string"` 11 Id int64 `json:"id,string"`
12 Name string `json:"name"` 12 Name string `json:"name"`
13 - Type int `json:"type"` 13 + Type int `json:"type" pg:",use_zero"`
14 Description string `json:"description"` 14 Description string `json:"description"`
15 CompanyId int64 `json:"companyId,string"` 15 CompanyId int64 `json:"companyId,string"`
16 CreatedAt time.Time `json:"createdAt"` 16 CreatedAt time.Time `json:"createdAt"`
@@ -8,18 +8,22 @@ type StaffAssessContent struct { @@ -8,18 +8,22 @@ type StaffAssessContent struct {
8 StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id 8 StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id
9 SortBy int `json:"sortBy"` //排序 9 SortBy int `json:"sortBy"` //排序
10 Category string `json:"category"` //类别 10 Category string `json:"category"` //类别
11 - Title string `json:"title"` //问题标题  
12 - Remark string `json:"remark"` //填写的反馈  
13 - Rate string `json:"rate"` //评估填写的值 11 + Name string `json:"name"` //名称
  12 + PromptTitle string `json:"promptTitle"` //提示项标题
  13 + PromptText string `json:"promptText"` //提示项正文
  14 + Remark []AssessContemtRemark `json:"remark"` //填写的反馈
  15 + Value string `json:"value"` //评估填写的值
14 ReteResult string `json:"reteResult"` //评估的结果 16 ReteResult string `json:"reteResult"` //评估的结果
  17 + Rule EvaluationRule `json:"rule"` //评估的选项规则
15 CreatedAt time.Time `json:"createdAt"` //数据创建时间 18 CreatedAt time.Time `json:"createdAt"` //数据创建时间
16 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 19 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
17 - //TODO 20 + DeletedAt *time.Time `json:"deletedAt"`
18 } 21 }
19 22
20 type AssessContemtRemark struct { 23 type AssessContemtRemark struct {
21 Title string `json:"title"` //comment:"填写标题" 24 Title string `json:"title"` //comment:"填写标题"
22 - RemarkText string `json:"hintText"` // comment:"填写文本内容" 25 + HintText string `json:"hintText"` // comment:"文本内容提示"
  26 + RemarkText string `json:"remarkText"` // comment:"填写文本内容"
23 } 27 }
24 28
25 type StaffAssessContentRepository interface { 29 type StaffAssessContentRepository interface {
@@ -3,19 +3,20 @@ package domain @@ -3,19 +3,20 @@ package domain
3 import "time" 3 import "time"
4 4
5 type User struct { 5 type User struct {
6 - Id int64 // 用户Id  
7 - Account string // 用户账号  
8 - AvatarUrl string // 用户头像URL  
9 - CompanyId int64 // 公司编号  
10 - AdminType int // 1普通员工 2 主管理员  
11 - Name string // 用户姓名  
12 - Email string // 邮箱  
13 - Status int // 用户状态(1正常 2禁用)  
14 - DepartmentId []int // 用户归属的部门  
15 - PositionId []int //用户职位  
16 - UpdatedAt time.Time // 更新时间  
17 - DeletedAt *time.Time  
18 - CreatedAt time.Time 6 + Id int64 `json:"id"` // 用户Id
  7 + Account string `json:"account"` // 用户账号
  8 + AvatarUrl string `json:"avatarUrl"` // 用户头像URL
  9 + CompanyId int64 `json:"companyId"` // 公司编号
  10 + AdminType int `json:"adminType"` // 1普通员工 2 主管理员
  11 + Name string `json:"name"` // 用户姓名
  12 + Email string `json:"email"` // 邮箱
  13 + Status int `json:"status"` // 用户状态(1正常 2禁用)
  14 + DepartmentId []int `json:"departmentId"` // 用户归属的部门
  15 + PositionId []int `json:"PositionId"` //用户职位
  16 + EntryTime string `json:"entryTime"` //入职日期
  17 + UpdatedAt time.Time `json:"updatedAt"` // 更新时间
  18 + DeletedAt *time.Time `json:"deletedAt"`
  19 + CreatedAt time.Time `json:"createdAt"`
19 } 20 }
20 21
21 // 1普通员工 2 主管理员 22 // 1普通员工 2 主管理员
@@ -42,6 +42,7 @@ func init() { @@ -42,6 +42,7 @@ func init() {
42 &models.EvaluationProject{}, 42 &models.EvaluationProject{},
43 &models.StaffAssess{}, 43 &models.StaffAssess{},
44 &models.StaffAssessTask{}, 44 &models.StaffAssessTask{},
  45 + &models.StaffAssessContent{},
45 } 46 }
46 for _, model := range tables { 47 for _, model := range tables {
47 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ 48 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
@@ -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:"创建时间"`
@@ -17,5 +17,5 @@ type EvaluationRule struct { @@ -17,5 +17,5 @@ type EvaluationRule struct {
17 Score domain.Score `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:"删除时间" pg:",soft_delete"` 20 + DeletedAt *time.Time `comment:"删除时间"`
21 } 21 }
@@ -3,13 +3,13 @@ package models @@ -3,13 +3,13 @@ package models
3 import "time" 3 import "time"
4 4
5 type Role struct { 5 type Role struct {
6 - tableName struct{} `pg:"role" comment:"角色"`  
7 - Id int64 `pg:"pk:id" comment:"ID"` 6 + tableName struct{} `comment:"角色" pg:"role"`
  7 + Id int64 `comment:"ID" pg:"pk:id"`
8 Name string `comment:"角色名称"` 8 Name string `comment:"角色名称"`
9 Type int `comment:"角色类型(0角色可删、1系统预置角色不可删)" pg:",use_zero"` 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:"创建时间"`
13 UpdatedAt time.Time `comment:"更新时间"` 13 UpdatedAt time.Time `comment:"更新时间"`
14 - DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` 14 + DeletedAt *time.Time `comment:"删除时间"`
15 } 15 }
@@ -10,5 +10,5 @@ type RoleUser struct { @@ -10,5 +10,5 @@ type RoleUser struct {
10 CompanyId int64 `comment:"公司ID"` 10 CompanyId int64 `comment:"公司ID"`
11 CreatedAt time.Time `comment:"创建时间"` 11 CreatedAt time.Time `comment:"创建时间"`
12 UpdatedAt time.Time `comment:"更新时间"` 12 UpdatedAt time.Time `comment:"更新时间"`
13 - DeletedAt *time.Time `comment:"删除时间" pg:",soft_delete"` 13 + DeletedAt *time.Time `comment:"删除时间"`
14 } 14 }
1 package models 1 package models
2 2
3 -import "time" 3 +import (
  4 + "time"
4 5
5 -//填写的评估内容 6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  7 +)
  8 +
  9 +// 填写的评估内容
6 type StaffAssessContent struct { 10 type StaffAssessContent struct {
7 tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"` 11 tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"`
8 Id int `pg:",pk"` //id 12 Id int `pg:",pk"` //id
9 StaffAssessId int //用户需要的评估项id 13 StaffAssessId int //用户需要的评估项id
10 SortBy int //排序 14 SortBy int //排序
11 Category string //类别 15 Category string //类别
12 - Title string //问题标题  
13 - Remark string //填写的反馈  
14 - Rate string //评估填写的值 16 + Name string //名称
  17 + PromptTitle string //问题标题
  18 + PromptText string //提示项正文
  19 + Value string //评估填写的值
15 ReteResult string //评估的结果 20 ReteResult string //评估的结果
  21 + Rule domain.EvaluationRule
  22 + Remark []domain.AssessContemtRemark
16 CreatedAt time.Time //数据创建时间 23 CreatedAt time.Time //数据创建时间
17 UpdatedAt time.Time //数据更新时间 24 UpdatedAt time.Time //数据更新时间
  25 + DeletedAt *time.Time
18 } 26 }
19 27
20 type StaffAssessContentRepository interface { 28 type StaffAssessContentRepository interface {
@@ -14,6 +14,7 @@ type User struct { @@ -14,6 +14,7 @@ type User struct {
14 Status int // 用户状态(1正常 2禁用) 14 Status int // 用户状态(1正常 2禁用)
15 DepartmentId []int // 用户归属的部门 15 DepartmentId []int // 用户归属的部门
16 PositionId []int // 用户职位 16 PositionId []int // 用户职位
  17 + EntryTime string //入职日期
17 CreatedAt time.Time // 创建时间 18 CreatedAt time.Time // 创建时间
18 UpdatedAt time.Time // 更新时间 19 UpdatedAt time.Time // 更新时间
19 DeletedAt *time.Time `pg:",soft_delete"` // 删除时间 20 DeletedAt *time.Time `pg:",soft_delete"` // 删除时间
@@ -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,
@@ -142,7 +142,12 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface @@ -142,7 +142,12 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
142 } 142 }
143 143
144 if v, ok := queryOptions["createdAt"]; ok { 144 if v, ok := queryOptions["createdAt"]; ok {
145 - query.Where("created_at = ?", v) 145 + t := v.(*time.Time)
  146 + year, month, day := t.Date()
  147 + begin := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
  148 + end := time.Date(year, month, day, 23, 59, 59, 0, time.Local)
  149 + query.Where("created_at >= ?", begin)
  150 + query.Where("created_at <= ?", end)
146 } 151 }
147 152
148 if v, ok := queryOptions["limit"].(int); ok { 153 if v, ok := queryOptions["limit"].(int); ok {
@@ -125,7 +125,7 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64 @@ -125,7 +125,7 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64
125 } 125 }
126 126
127 if userIds, ok := queryOptions["userIds"]; ok { 127 if userIds, ok := queryOptions["userIds"]; ok {
128 - query.Where("user_id in (?)", userIds) 128 + query.Where("user_id in (?)", pg.In(userIds))
129 } 129 }
130 130
131 if v, ok := queryOptions["limit"].(int); ok { 131 if v, ok := queryOptions["limit"].(int); ok {
@@ -182,7 +182,7 @@ func (repo *RoleUserRepository) BatchDeleteById(ids []int64) error { @@ -182,7 +182,7 @@ func (repo *RoleUserRepository) BatchDeleteById(ids []int64) error {
182 return err 182 return err
183 } 183 }
184 184
185 -func (repo *RoleUserRepository) FindAllContainUser(pageSize int, pageNumber int, companyId int64, roleId int64) ([]*domain.RoleContainUser, error) { 185 +func (repo *RoleUserRepository) FindAllContainUser(pageNumber int, pageSize int, companyId int64, roleId int64) ([]*domain.RoleContainUser, error) {
186 limit := pageSize 186 limit := pageSize
187 offset := limit * (pageNumber - 1) 187 offset := limit * (pageNumber - 1)
188 if offset < 0 { 188 if offset < 0 {
@@ -192,7 +192,7 @@ func (repo *RoleUserRepository) FindAllContainUser(pageSize int, pageNumber int, @@ -192,7 +192,7 @@ func (repo *RoleUserRepository) FindAllContainUser(pageSize int, pageNumber int,
192 "role_user".role_id, 192 "role_user".role_id,
193 "role_user".user_id, 193 "role_user".user_id,
194 "user".name as user_name, 194 "user".name as user_name,
195 - "user".email as user_email, 195 + "user".email as user_email
196 ` 196 `
197 whereFrom := ` 197 whereFrom := `
198 FROM "role_user" 198 FROM "role_user"
@@ -22,12 +22,40 @@ func NewStaffAssessContentRepository(transactionContext *pgTransaction.Transacti @@ -22,12 +22,40 @@ func NewStaffAssessContentRepository(transactionContext *pgTransaction.Transacti
22 } 22 }
23 23
24 func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAssessContent) *domain.StaffAssessContent { 24 func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAssessContent) *domain.StaffAssessContent {
25 - return &domain.StaffAssessContent{} 25 + return &domain.StaffAssessContent{
  26 + Id: d.Id,
  27 + StaffAssessId: d.StaffAssessId,
  28 + SortBy: d.SortBy,
  29 + Category: d.Category,
  30 + Name: d.Name,
  31 + PromptTitle: d.PromptTitle,
  32 + PromptText: d.PromptText,
  33 + Remark: d.Remark,
  34 + Value: d.Value,
  35 + ReteResult: d.ReteResult,
  36 + Rule: d.Rule,
  37 + CreatedAt: d.CreatedAt,
  38 + UpdatedAt: d.UpdatedAt,
  39 + DeletedAt: nil,
  40 + }
26 } 41 }
27 42
28 func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*domain.StaffAssessContent, error) { 43 func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*domain.StaffAssessContent, error) {
29 - saveModel := models.StaffAssess{ 44 + saveModel := models.StaffAssessContent{
30 Id: d.Id, 45 Id: d.Id,
  46 + StaffAssessId: d.StaffAssessId,
  47 + SortBy: d.SortBy,
  48 + Category: d.Category,
  49 + Name: d.Name,
  50 + PromptTitle: d.PromptTitle,
  51 + PromptText: d.PromptText,
  52 + Remark: d.Remark,
  53 + Value: d.Value,
  54 + ReteResult: d.ReteResult,
  55 + Rule: d.Rule,
  56 + CreatedAt: d.CreatedAt,
  57 + UpdatedAt: d.UpdatedAt,
  58 + DeletedAt: nil,
31 } 59 }
32 tx := repo.transactionContext.PgTx 60 tx := repo.transactionContext.PgTx
33 var err error 61 var err error
@@ -79,7 +107,7 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface @@ -79,7 +107,7 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface
79 tx := repo.transactionContext.PgTx 107 tx := repo.transactionContext.PgTx
80 var m []*models.StaffAssessContent 108 var m []*models.StaffAssessContent
81 query := tx.Model(&m). 109 query := tx.Model(&m).
82 - Where("deleted_at isnull").Limit(20) 110 + Where("deleted_at isnull")
83 if companyId, ok := queryOptions["companyId"]; ok { 111 if companyId, ok := queryOptions["companyId"]; ok {
84 query.Where("company_id = ?", companyId) 112 query.Where("company_id = ?", companyId)
85 } 113 }
@@ -140,7 +140,9 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -140,7 +140,9 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
140 if v, ok := queryOptions["staffAssessTaskId"]; ok { 140 if v, ok := queryOptions["staffAssessTaskId"]; ok {
141 query.Where(`staff_assess_task_id=?`, v) 141 query.Where(`staff_assess_task_id=?`, v)
142 } 142 }
143 - 143 + if v, ok := queryOptions["id"]; ok {
  144 + query.Where("id=?", v)
  145 + }
144 if v, ok := queryOptions["typesList"].([]string); ok && len(v) > 0 { 146 if v, ok := queryOptions["typesList"].([]string); ok && len(v) > 0 {
145 query.Where("types in(?)", pg.In(v)) 147 query.Where("types in(?)", pg.In(v))
146 } 148 }
1 package repository 1 package repository
2 2
3 import ( 3 import (
  4 + "fmt"
  5 +
4 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
@@ -114,8 +116,8 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d @@ -114,8 +116,8 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
114 if v, ok := queryOptions["account"]; ok { 116 if v, ok := queryOptions["account"]; ok {
115 query.Where("account like ?", v) 117 query.Where("account like ?", v)
116 } 118 }
117 - if v, ok := queryOptions["name"]; ok && v.(string) != "" {  
118 - query.Where("name like ?", "%"+v.(string)+"%") 119 + if v, ok := queryOptions["name"]; ok {
  120 + query.Where("name like ?", fmt.Sprintf("%%%v%%", v))
119 } 121 }
120 if v, ok := queryOptions["offset"]; ok { 122 if v, ok := queryOptions["offset"]; ok {
121 query.Offset(v.(int)) 123 query.Offset(v.(int))
@@ -87,3 +87,23 @@ func (controller *CycleController) StatisticCycleUser() { @@ -87,3 +87,23 @@ func (controller *CycleController) StatisticCycleUser() {
87 controller.Response(ruService.StatisticCycleUser(in)) 87 controller.Response(ruService.StatisticCycleUser(in))
88 } 88 }
89 } 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 +}
@@ -21,8 +21,6 @@ func (controller *RuleController) CreateRule() { @@ -21,8 +21,6 @@ func (controller *RuleController) CreateRule() {
21 ua := middlewares.GetUser(controller.Ctx) 21 ua := middlewares.GetUser(controller.Ctx)
22 in.CompanyId = ua.CompanyId 22 in.CompanyId = ua.CompanyId
23 in.CreatorId = ua.UserId 23 in.CreatorId = ua.UserId
24 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
25 - //in.CreatorId = middlewares.GetUserId(controller.Ctx)  
26 controller.Response(ruService.Create(in)) 24 controller.Response(ruService.Create(in))
27 } 25 }
28 } 26 }
@@ -35,9 +33,6 @@ func (controller *RuleController) UpdateRule() { @@ -35,9 +33,6 @@ func (controller *RuleController) UpdateRule() {
35 } else { 33 } else {
36 ua := middlewares.GetUser(controller.Ctx) 34 ua := middlewares.GetUser(controller.Ctx)
37 in.CompanyId = ua.CompanyId 35 in.CompanyId = ua.CompanyId
38 - in.CreatorId = ua.UserId  
39 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
40 - //in.CreatorId = middlewares.GetUserId(controller.Ctx)  
41 controller.Response(ruService.Update(in)) 36 controller.Response(ruService.Update(in))
42 } 37 }
43 } 38 }
@@ -22,8 +22,6 @@ func (controller *TemplateController) CreateTemplate() { @@ -22,8 +22,6 @@ func (controller *TemplateController) CreateTemplate() {
22 ua := middlewares.GetUser(controller.Ctx) 22 ua := middlewares.GetUser(controller.Ctx)
23 in.CompanyId = ua.CompanyId 23 in.CompanyId = ua.CompanyId
24 in.CreatorId = ua.UserId 24 in.CreatorId = ua.UserId
25 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
26 - //in.CreatorId = middlewares.GetUserId(controller.Ctx)  
27 controller.Response(ruService.Create(in)) 25 controller.Response(ruService.Create(in))
28 } 26 }
29 } 27 }
@@ -36,7 +34,6 @@ func (controller *TemplateController) UpdateTemplate() { @@ -36,7 +34,6 @@ func (controller *TemplateController) UpdateTemplate() {
36 } else { 34 } else {
37 ua := middlewares.GetUser(controller.Ctx) 35 ua := middlewares.GetUser(controller.Ctx)
38 in.CompanyId = ua.CompanyId 36 in.CompanyId = ua.CompanyId
39 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
40 controller.Response(ruService.Update(in)) 37 controller.Response(ruService.Update(in))
41 } 38 }
42 } 39 }
@@ -74,7 +71,6 @@ func (controller *TemplateController) ListTemplate() { @@ -74,7 +71,6 @@ func (controller *TemplateController) ListTemplate() {
74 } 71 }
75 ua := middlewares.GetUser(controller.Ctx) 72 ua := middlewares.GetUser(controller.Ctx)
76 in.CompanyId = ua.CompanyId 73 in.CompanyId = ua.CompanyId
77 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
78 controller.Response(ruService.List(in)) 74 controller.Response(ruService.List(in))
79 } 75 }
80 } 76 }
@@ -90,7 +86,6 @@ func (controller *TemplateController) ListEnableTemplate() { @@ -90,7 +86,6 @@ func (controller *TemplateController) ListEnableTemplate() {
90 } else { 86 } else {
91 ua := middlewares.GetUser(controller.Ctx) 87 ua := middlewares.GetUser(controller.Ctx)
92 in.CompanyId = ua.CompanyId 88 in.CompanyId = ua.CompanyId
93 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
94 controller.Response(ruService.List(in)) 89 controller.Response(ruService.List(in))
95 } 90 }
96 } 91 }
@@ -103,7 +98,6 @@ func (controller *TemplateController) StateTemplate() { @@ -103,7 +98,6 @@ func (controller *TemplateController) StateTemplate() {
103 } else { 98 } else {
104 ua := middlewares.GetUser(controller.Ctx) 99 ua := middlewares.GetUser(controller.Ctx)
105 in.CompanyId = ua.CompanyId 100 in.CompanyId = ua.CompanyId
106 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
107 controller.Response(ruService.State(in)) 101 controller.Response(ruService.State(in))
108 } 102 }
109 } 103 }
@@ -12,7 +12,7 @@ type RoleController struct { @@ -12,7 +12,7 @@ type RoleController struct {
12 beego.BaseController 12 beego.BaseController
13 } 13 }
14 14
15 -//func (controller *RoleController) CreateRole() { 15 +// func (controller *RoleController) CreateRole() {
16 // ruService := service.NewRoleService() 16 // ruService := service.NewRoleService()
17 // in := &command.CreateRoleCommand{} 17 // in := &command.CreateRoleCommand{}
18 // if err := controller.Unmarshal(in); err != nil { 18 // if err := controller.Unmarshal(in); err != nil {
@@ -21,9 +21,9 @@ type RoleController struct { @@ -21,9 +21,9 @@ type RoleController struct {
21 // in.CompanyId = middlewares.GetCompanyId(controller.Ctx) 21 // in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
22 // controller.Response(ruService.Create(in)) 22 // controller.Response(ruService.Create(in))
23 // } 23 // }
24 -//} 24 +// }
25 // 25 //
26 -//func (controller *RoleController) UpdateRole() { 26 +// func (controller *RoleController) UpdateRole() {
27 // ruService := service.NewRoleService() 27 // ruService := service.NewRoleService()
28 // in := &command.UpdateRoleCommand{} 28 // in := &command.UpdateRoleCommand{}
29 // if err := controller.Unmarshal(in); err != nil { 29 // if err := controller.Unmarshal(in); err != nil {
@@ -32,18 +32,18 @@ type RoleController struct { @@ -32,18 +32,18 @@ type RoleController struct {
32 // in.CompanyId = middlewares.GetCompanyId(controller.Ctx) 32 // in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
33 // controller.Response(ruService.Update(in)) 33 // controller.Response(ruService.Update(in))
34 // } 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 // } 35 // }
46 -//} 36 +func (controller *RoleController) RemoveRole() {
  37 + ruService := service.NewRoleService()
  38 + in := &command.DeleteRoleCommand{}
  39 + if err := controller.Unmarshal(in); err != nil {
  40 + controller.Response(nil, application.ThrowError(application.ARG_ERROR, err.Error()))
  41 + } else {
  42 + ua := middlewares.GetUser(controller.Ctx)
  43 + in.CompanyId = ua.CompanyId
  44 + controller.Response(ruService.Remove(in))
  45 + }
  46 +}
47 47
48 func (controller *RoleController) ListForUserRole() { 48 func (controller *RoleController) ListForUserRole() {
49 ruService := service.NewRoleService() 49 ruService := service.NewRoleService()
@@ -53,7 +53,6 @@ func (controller *RoleController) ListForUserRole() { @@ -53,7 +53,6 @@ func (controller *RoleController) ListForUserRole() {
53 } else { 53 } else {
54 ua := middlewares.GetUser(controller.Ctx) 54 ua := middlewares.GetUser(controller.Ctx)
55 in.CompanyId = ua.CompanyId 55 in.CompanyId = ua.CompanyId
56 - //in.CompanyId = middlewares.GetCompanyId(controller.Ctx)  
57 controller.Response(ruService.ListForUser(in)) 56 controller.Response(ruService.ListForUser(in))
58 } 57 }
59 } 58 }
@@ -78,10 +78,136 @@ func (c *StaffAssessController) CreateStaffAssessTask() { @@ -78,10 +78,136 @@ func (c *StaffAssessController) CreateStaffAssessTask() {
78 c.Response(data, err) 78 c.Response(data, err)
79 } 79 }
80 80
81 -//获取员工自评详情 81 +// 获取当前登录员工自评详情
  82 +func (c *StaffAssessController) GetAssessSelfMeInfo() {
  83 + srv := service.NewStaffAssessServeice()
  84 + paramReq := &query.AssessSelfInfoQuery{}
  85 + err := c.BindJSON(paramReq)
  86 + if err != nil {
  87 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  88 + c.Response(nil, e)
  89 + return
  90 + }
  91 + //TODO 获取当前用户信息
  92 + paramReq.CompanyId = 1
  93 + paramReq.TargetUserId = 1
  94 + data, err := srv.GetAssessSelfInfo(paramReq)
  95 + c.Response(data, err)
  96 +}
82 97
83 //保存员工自评填写内容 98 //保存员工自评填写内容
84 99
85 -//获取员工邀请的人 100 +// 获取员工邀请的人
  101 +func (c *StaffAssessController) GetAssessInviteUser() {
  102 + srv := service.NewStaffAssessServeice()
  103 + paramReq := &query.GetAssessInviteUserQuery{}
  104 + err := c.BindJSON(paramReq)
  105 + if err != nil {
  106 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  107 + c.Response(nil, e)
  108 + return
  109 + }
  110 + //TODO 获取当前用户信息
  111 + paramReq.CompanyId = 1
  112 + paramReq.UserId = 1
  113 + data, err := srv.GetAssessInviteUser(paramReq)
  114 + c.Response(data, err)
  115 +}
  116 +
  117 +// 保持员工邀请的人
  118 +func (c *StaffAssessController) SaveAssessInviteUser() {
  119 + srv := service.NewStaffAssessServeice()
  120 + paramReq := &command.SaveAssessInvite{}
  121 + err := c.BindJSON(paramReq)
  122 + if err != nil {
  123 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  124 + c.Response(nil, e)
  125 + return
  126 + }
  127 + //TODO 获取当前用户信息
  128 + // paramReq.CompanyId = 1
  129 + // paramReq.UserId = 1
  130 + data, err := srv.SaveAssessInviteUser(paramReq)
  131 + c.Response(data, err)
  132 +}
  133 +
  134 +// 员工邀请的人选择列表
  135 +func (c *StaffAssessController) SelectAssessInviteUser() {
  136 + srv := service.NewStaffAssessServeice()
  137 + paramReq := &query.SelectAssessInviteUser{}
  138 + err := c.BindJSON(paramReq)
  139 + if err != nil {
  140 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  141 + c.Response(nil, e)
  142 + return
  143 + }
  144 + //TODO 获取当前用户信息
  145 + paramReq.CompanyId = 1
  146 + paramReq.TargetUserId = 1
  147 + data, err := srv.SelectAssessInviteUser(paramReq)
  148 + c.Response(data, err)
  149 +}
86 150
87 -//保持员工邀请的人 151 +// 获取我要执行360评估,用户列表和评估填写的值
  152 +func (c *StaffAssessController) ListInviteUserAssess() {
  153 + srv := service.NewStaffAssessServeice()
  154 + paramReq := &query.ListInviteUserAssessQuery{}
  155 + err := c.BindJSON(paramReq)
  156 + if err != nil {
  157 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  158 + c.Response(nil, e)
  159 + return
  160 + }
  161 + //TODO 获取当前用户信息
  162 + paramReq.CompanyId = 1
  163 + paramReq.ExecutorId = 1
  164 + data, err := srv.ListInviteUserAssess(paramReq)
  165 + c.Response(data, err)
  166 +}
  167 +
  168 +// 获取上级评估成员列表
  169 +func (c *StaffAssessController) ListSupperAssess() {
  170 + srv := service.NewStaffAssessServeice()
  171 + paramReq := &query.ListSupperAssessQuery{}
  172 + err := c.BindJSON(paramReq)
  173 + if err != nil {
  174 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  175 + c.Response(nil, e)
  176 + return
  177 + }
  178 + //TODO 获取当前用户信息
  179 + paramReq.CompanyId = 1
  180 + paramReq.ExecutorId = 1
  181 + data, err := srv.ListSupperAssess(paramReq)
  182 + c.Response(data, err)
  183 +}
  184 +
  185 +// 获取员工自评详情
  186 +func (c *StaffAssessController) GetAssessSelfInfo() {
  187 + srv := service.NewStaffAssessServeice()
  188 + paramReq := &query.AssessSelfInfoQuery{}
  189 + err := c.BindJSON(paramReq)
  190 + if err != nil {
  191 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  192 + c.Response(nil, e)
  193 + return
  194 + }
  195 + paramReq.CompanyId = 1
  196 + data, err := srv.GetAssessSelfInfo(paramReq)
  197 + c.Response(data, err)
  198 +}
  199 +
  200 +// 获取评估内容详情
  201 +func (c *StaffAssessController) GetAssessInfo() {
  202 + srv := service.NewStaffAssessServeice()
  203 + paramReq := &query.AssessInfoQuery{}
  204 + err := c.BindJSON(paramReq)
  205 + if err != nil {
  206 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  207 + c.Response(nil, e)
  208 + return
  209 + }
  210 + paramReq.CompanyId = 1
  211 + data, err := srv.GetAssessInfo(paramReq)
  212 + c.Response(data, err)
  213 +}
@@ -16,6 +16,7 @@ func init() { @@ -16,6 +16,7 @@ func init() {
16 web.NSRouter("/:Id", &controllers.CycleController{}, "Get:GetCycle"), 16 web.NSRouter("/:Id", &controllers.CycleController{}, "Get:GetCycle"),
17 web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"), 17 web.NSRouter("/list", &controllers.CycleController{}, "Post:ListCycle"),
18 web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"), 18 web.NSRouter("/statistic", &controllers.CycleController{}, "Post:StatisticCycleUser"),
  19 + web.NSRouter("/templates", &controllers.CycleController{}, "Post:CycleTemplateList"),
19 ) 20 )
20 web.AddNamespace(ns) 21 web.AddNamespace(ns)
21 } 22 }
@@ -12,7 +12,7 @@ func init() { @@ -12,7 +12,7 @@ func init() {
12 web.NSBefore(filters.AllowCors(), middlewares.CheckAdminToken()), 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"),
16 //web.NSRouter("/:Id", &controllers.RoleController{}, "Get:GetRole"), 16 //web.NSRouter("/:Id", &controllers.RoleController{}, "Get:GetRole"),
17 web.NSRouter("/all", &controllers.RoleController{}, "Post:ListForUserRole"), 17 web.NSRouter("/all", &controllers.RoleController{}, "Post:ListForUserRole"),
18 ) 18 )
@@ -16,7 +16,12 @@ func init() { @@ -16,7 +16,12 @@ func init() {
16 assessNS := web.NewNamespace("/v1/staff-assess", 16 assessNS := web.NewNamespace("/v1/staff-assess",
17 // web.NSBefore(filters.AllowCors(), middlewares.CheckToken()), 17 // web.NSBefore(filters.AllowCors(), middlewares.CheckToken()),
18 web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表 18 web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
19 - // web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).AssessSelfMeList), 19 + web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情
  20 + web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessInviteUser), //获取邀请的员工
  21 + web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessInviteUser), //保存我邀请的员工
  22 + web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
  23 + web.NSCtrlPost("/self/info", (*controllers.StaffAssessController).GetAssessSelfInfo), //获取我的自评反馈详情
  24 + web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //获取我的自评反馈详情
20 ) 25 )
21 web.AddNamespace(assessTaskNS) 26 web.AddNamespace(assessTaskNS)
22 web.AddNamespace(assessNS) 27 web.AddNamespace(assessNS)