作者 郑周

Merge remote-tracking branch 'origin/test' into test

@@ -160,3 +160,11 @@ func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.Staf @@ -160,3 +160,11 @@ func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.Staf
160 } 160 }
161 return repository.NewStaffAssessTaskRepository(transactionContext) 161 return repository.NewStaffAssessTaskRepository(transactionContext)
162 } 162 }
  163 +
  164 +func CreateStaffAssessContentTempRepository(options map[string]interface{}) domain.StaffAssessContentTempRepository {
  165 + var transactionContext *pg.TransactionContext
  166 + if value, ok := options["transactionContext"]; ok {
  167 + transactionContext = value.(*pg.TransactionContext)
  168 + }
  169 + return repository.NewStaffAssessContentTempRepository(transactionContext)
  170 +}
@@ -480,6 +480,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application. @@ -480,6 +480,7 @@ func (srv StaffAssessServeice) createStaffAssess(transactionContext application.
480 //获取员工信息 480 //获取员工信息
481 _, userList, err := userRepo.Find(map[string]interface{}{ 481 _, userList, err := userRepo.Find(map[string]interface{}{
482 "ids": selfUserId, 482 "ids": selfUserId,
  483 + "status": 1,
483 }) 484 })
484 if err != nil { 485 if err != nil {
485 return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error()) 486 return nil, application.ThrowError(application.ARG_ERROR, "获取员工信息"+err.Error())
@@ -781,6 +782,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -781,6 +782,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
781 if len(inviteSameSuperId) > 0 { 782 if len(inviteSameSuperId) > 0 {
782 _, userList, err := userRepo.Find(map[string]interface{}{ 783 _, userList, err := userRepo.Find(map[string]interface{}{
783 "ids": inviteSameSuperId, 784 "ids": inviteSameSuperId,
  785 + "status": 1,
784 }) 786 })
785 if err != nil { 787 if err != nil {
786 return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error()) 788 return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
@@ -798,6 +800,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -798,6 +800,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
798 if len(InviteDiffSuperId) > 0 { 800 if len(InviteDiffSuperId) > 0 {
799 _, userList, err := userRepo.Find(map[string]interface{}{ 801 _, userList, err := userRepo.Find(map[string]interface{}{
800 "ids": InviteDiffSuperId, 802 "ids": InviteDiffSuperId,
  803 + "status": 1,
801 }) 804 })
802 if err != nil { 805 if err != nil {
803 return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error()) 806 return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
@@ -1136,6 +1139,7 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI @@ -1136,6 +1139,7 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI
1136 "companyId": param.CompanyId, 1139 "companyId": param.CompanyId,
1137 "name": param.InviteUserName, 1140 "name": param.InviteUserName,
1138 "limit": 20, 1141 "limit": 20,
  1142 + "status": 1,
1139 } 1143 }
1140 if param.PageSize > 0 { 1144 if param.PageSize > 0 {
1141 condition["limit"] = param.PageSize 1145 condition["limit"] = param.PageSize
@@ -1863,6 +1867,7 @@ loop: @@ -1863,6 +1867,7 @@ loop:
1863 if len(chargeUserIds) > 0 { 1867 if len(chargeUserIds) > 0 {
1864 _, chargeUserList, err = userRepo.Find(map[string]interface{}{ 1868 _, chargeUserList, err = userRepo.Find(map[string]interface{}{
1865 "ids": chargeUserIds, 1869 "ids": chargeUserIds,
  1870 + "status": 1, //正常的用户
1866 }) 1871 })
1867 if err != nil { 1872 if err != nil {
1868 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error()) 1873 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "time"
  5 +
4 "github.com/linmadan/egglib-go/core/application" 6 "github.com/linmadan/egglib-go/core/application"
5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command" 9 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
  10 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
8 ) 11 )
9 12
10 //调试用,手动调用CreateStaffAssessTask 13 //调试用,手动调用CreateStaffAssessTask
@@ -31,14 +34,77 @@ func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateS @@ -31,14 +34,77 @@ func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateS
31 } 34 }
32 35
33 //保存员工绩效评估填写过程中即写即存的内容 36 //保存员工绩效评估填写过程中即写即存的内容
34 -func (srv StaffAssessServeice) SaveAssessContentTemp(param *command.SaveAssessInfoCommand) error { 37 +func (srv StaffAssessServeice) SaveAssessContentTemp(param *command.SaveAssessInfoCommand) (map[string]interface{}, error) {
35 38
36 - return nil 39 + transactionContext, err := factory.CreateTransactionContext(nil)
  40 + if err != nil {
  41 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  42 + }
  43 + if err := transactionContext.StartTransaction(); err != nil {
  44 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  45 + }
  46 + defer func() {
  47 + _ = transactionContext.RollbackTransaction()
  48 + }()
  49 + //获取旧的临时数据内容
  50 + contentTempRepo := factory.CreateStaffAssessContentTempRepository(map[string]interface{}{
  51 + "transactionContext": transactionContext,
  52 + })
  53 + //获取评估填写的内容
  54 + // assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  55 + // "transactionContext": transactionContext,
  56 + // })
  57 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  58 + "transactionContext": transactionContext,
  59 + })
  60 + assessData, err := assessRepo.FindOne(map[string]interface{}{
  61 + "id": param.AssessId,
  62 + })
  63 + if err != nil {
  64 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
  65 + }
  66 +
  67 + // staffAssessId
  68 + _, contentTempList, err := contentTempRepo.Find(map[string]interface{}{
  69 + "staffAssessId": param.AssessId,
  70 + })
  71 + if err != nil {
  72 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取临时保存的内容"+err.Error())
  73 + }
  74 + nowTime := time.Now()
  75 + if len(contentTempList) == 0 {
  76 + //获取评估模板
  77 + assessContentList, err := srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
  78 + if err != nil {
  79 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估模板,"+err.Error())
  80 + }
  81 + //转填入临时的数据
  82 + for _, v := range assessContentList {
  83 + item := &domain.StaffAssessContentTemp{
  84 + Id: 0,
  85 + StaffAssessId: v.StaffAssessId,
  86 + SortBy: v.SortBy,
  87 + Category: v.Category,
  88 + Name: v.Name,
  89 + Remark: v.Remark,
  90 + Value: "",
  91 + CreatedAt: nowTime,
  92 + UpdatedAt: nowTime,
  93 + }
  94 + contentTempList = append(contentTempList, item)
  95 + }
  96 + }
  97 + //更新assessContentTemp
  98 + if err := transactionContext.CommitTransaction(); err != nil {
  99 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  100 + }
  101 + return nil, nil
37 } 102 }
38 103
39 //获取员工绩效评估填写内容 104 //获取员工绩效评估填写内容
40 //临时数据存在时就获取临时数据 105 //临时数据存在时就获取临时数据
41 //不存在就获取实际保存的数据 106 //不存在就获取实际保存的数据
42 func (srv StaffAssessServeice) GetAssessContentTemp(param *command.SaveAssessInfoCommand) (*adapter.AssessInfoResp, error) { 107 func (srv StaffAssessServeice) GetAssessContentTemp(param *command.SaveAssessInfoCommand) (*adapter.AssessInfoResp, error) {
  108 + //将临时保存的数据填入模板中
43 return nil, nil 109 return nil, nil
44 } 110 }
@@ -13,7 +13,6 @@ type StaffAssessContentTemp struct { @@ -13,7 +13,6 @@ type StaffAssessContentTemp struct {
13 Value string `json:"value"` //评估填写的值 13 Value string `json:"value"` //评估填写的值
14 CreatedAt time.Time `json:"createdAt"` //数据创建时间 14 CreatedAt time.Time `json:"createdAt"` //数据创建时间
15 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 15 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
16 - DeletedAt *time.Time `json:"deletedAt"`  
17 } 16 }
18 17
19 type StaffAssessContentTempRepository interface { 18 type StaffAssessContentTempRepository interface {
@@ -8,20 +8,14 @@ import ( @@ -8,20 +8,14 @@ import (
8 8
9 // 填写的评估内容 9 // 填写的评估内容
10 type StaffAssessContentTemp struct { 10 type StaffAssessContentTemp struct {
11 - tableName struct{} `pg:"staff_assess_content_temp" comment:"填写的评估项"` 11 + tableName struct{} `pg:"staff_assess_content_temp" comment:"临时填写的评估项"`
12 Id int `pg:",pk"` //id 12 Id int `pg:",pk"` //id
13 - StaffAssessId int //用户需要的评估项id  
14 - SortBy int //排序  
15 - Category string //类别  
16 - Name string //名称  
17 - PromptTitle string //问题标题  
18 - PromptText string //提示项正文  
19 - Value string //评估填写的值  
20 - ReteResult string //评估的结果  
21 - Rule domain.EvaluationRule  
22 - Remark []domain.AssessContemtRemark  
23 - Weight int //权重  
24 - CreatedAt time.Time //数据创建时间  
25 - UpdatedAt time.Time //数据更新时间  
26 - DeletedAt *time.Time 13 + StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id
  14 + SortBy int `json:"sortBy"` //排序
  15 + Category string `json:"category"` //类别
  16 + Name string `json:"name"` //名称
  17 + Remark []domain.AssessContemtRemark `json:"remark"` //填写的反馈
  18 + Value string `json:"value"` //评估填写的值
  19 + CreatedAt time.Time `json:"createdAt"` //数据创建时间
  20 + UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
27 } 21 }
@@ -3,7 +3,6 @@ package repository @@ -3,7 +3,6 @@ package repository
3 import ( 3 import (
4 "errors" 4 "errors"
5 "fmt" 5 "fmt"
6 - "time"  
7 6
8 "github.com/go-pg/pg/v10" 7 "github.com/go-pg/pg/v10"
9 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
@@ -15,49 +14,37 @@ type StaffAssessContentTempRepository struct { @@ -15,49 +14,37 @@ type StaffAssessContentTempRepository struct {
15 transactionContext *pgTransaction.TransactionContext 14 transactionContext *pgTransaction.TransactionContext
16 } 15 }
17 16
18 -// var _ domain.StaffAssessContentRepository = (*StaffAssessContentTempRepository)(nil) 17 +var _ domain.StaffAssessContentTempRepository = (*StaffAssessContentTempRepository)(nil)
19 18
20 func NewStaffAssessContentTempRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentTempRepository { 19 func NewStaffAssessContentTempRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentTempRepository {
21 return &StaffAssessContentTempRepository{transactionContext: transactionContext} 20 return &StaffAssessContentTempRepository{transactionContext: transactionContext}
22 } 21 }
23 22
24 -func (repo *StaffAssessContentTempRepository) TransformToDomain(d *models.StaffAssessContent) *domain.StaffAssessContent {  
25 - return &domain.StaffAssessContent{ 23 +func (repo *StaffAssessContentTempRepository) TransformToDomain(d *models.StaffAssessContentTemp) *domain.StaffAssessContentTemp {
  24 + return &domain.StaffAssessContentTemp{
26 Id: d.Id, 25 Id: d.Id,
27 StaffAssessId: d.StaffAssessId, 26 StaffAssessId: d.StaffAssessId,
28 SortBy: d.SortBy, 27 SortBy: d.SortBy,
29 Category: d.Category, 28 Category: d.Category,
30 Name: d.Name, 29 Name: d.Name,
31 - PromptTitle: d.PromptTitle,  
32 - PromptText: d.PromptText,  
33 Remark: d.Remark, 30 Remark: d.Remark,
34 Value: d.Value, 31 Value: d.Value,
35 - ReteResult: d.ReteResult,  
36 - Rule: d.Rule,  
37 - Weight: d.Weight,  
38 CreatedAt: d.CreatedAt, 32 CreatedAt: d.CreatedAt,
39 UpdatedAt: d.UpdatedAt, 33 UpdatedAt: d.UpdatedAt,
40 - DeletedAt: nil,  
41 } 34 }
42 } 35 }
43 36
44 -func (repo *StaffAssessContentTempRepository) Save(d *domain.StaffAssessContent) (*domain.StaffAssessContent, error) {  
45 - saveModel := models.StaffAssessContent{ 37 +func (repo *StaffAssessContentTempRepository) Save(d *domain.StaffAssessContentTemp) (*domain.StaffAssessContentTemp, error) {
  38 + saveModel := models.StaffAssessContentTemp{
46 Id: d.Id, 39 Id: d.Id,
47 StaffAssessId: d.StaffAssessId, 40 StaffAssessId: d.StaffAssessId,
48 SortBy: d.SortBy, 41 SortBy: d.SortBy,
49 Category: d.Category, 42 Category: d.Category,
50 Name: d.Name, 43 Name: d.Name,
51 - PromptTitle: d.PromptTitle,  
52 - PromptText: d.PromptText,  
53 Remark: d.Remark, 44 Remark: d.Remark,
54 Value: d.Value, 45 Value: d.Value,
55 - ReteResult: d.ReteResult,  
56 - Rule: d.Rule,  
57 CreatedAt: d.CreatedAt, 46 CreatedAt: d.CreatedAt,
58 UpdatedAt: d.UpdatedAt, 47 UpdatedAt: d.UpdatedAt,
59 - Weight: d.Weight,  
60 - DeletedAt: nil,  
61 } 48 }
62 tx := repo.transactionContext.PgTx 49 tx := repo.transactionContext.PgTx
63 var err error 50 var err error
@@ -78,19 +65,15 @@ func (repo *StaffAssessContentTempRepository) Save(d *domain.StaffAssessContent) @@ -78,19 +65,15 @@ func (repo *StaffAssessContentTempRepository) Save(d *domain.StaffAssessContent)
78 65
79 func (repo *StaffAssessContentTempRepository) Remove(id int) error { 66 func (repo *StaffAssessContentTempRepository) Remove(id int) error {
80 tx := repo.transactionContext.PgTx 67 tx := repo.transactionContext.PgTx
81 - nowTime := time.Now()  
82 - _, err := tx.Model(&models.StaffAssessContent{}).  
83 - Where("id=?", id).  
84 - Set("deleted_at=?", nowTime).  
85 - Update() 68 + _, err := tx.Model(&models.StaffAssessContentTemp{}).
  69 + Where("id=?", id).Delete()
86 return err 70 return err
87 } 71 }
88 72
89 -func (repo *StaffAssessContentTempRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssessContent, error) { 73 +func (repo *StaffAssessContentTempRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssessContentTemp, error) {
90 tx := repo.transactionContext.PgTx 74 tx := repo.transactionContext.PgTx
91 - m := new(models.StaffAssessContent) 75 + m := new(models.StaffAssessContentTemp)
92 query := tx.Model(m) 76 query := tx.Model(m)
93 - query.Where("deleted_at isnull")  
94 if id, ok := queryOptions["id"]; ok { 77 if id, ok := queryOptions["id"]; ok {
95 query.Where("id=?", id) 78 query.Where("id=?", id)
96 } 79 }
@@ -105,20 +88,13 @@ func (repo *StaffAssessContentTempRepository) FindOne(queryOptions map[string]in @@ -105,20 +88,13 @@ func (repo *StaffAssessContentTempRepository) FindOne(queryOptions map[string]in
105 return u, nil 88 return u, nil
106 } 89 }
107 90
108 -func (repo *StaffAssessContentTempRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssessContent, error) { 91 +func (repo *StaffAssessContentTempRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssessContentTemp, error) {
109 tx := repo.transactionContext.PgTx 92 tx := repo.transactionContext.PgTx
110 - var m []*models.StaffAssessContent  
111 - query := tx.Model(&m).  
112 - Where("deleted_at isnull") 93 + var m []*models.StaffAssessContentTemp
  94 + query := tx.Model(&m)
113 if companyId, ok := queryOptions["companyId"]; ok { 95 if companyId, ok := queryOptions["companyId"]; ok {
114 query.Where("company_id = ?", companyId) 96 query.Where("company_id = ?", companyId)
115 } 97 }
116 - if v, ok := queryOptions["limit"].(int); ok {  
117 - query.Limit(v)  
118 - }  
119 - if v, ok := queryOptions["offset"].(int); ok {  
120 - query.Offset(v)  
121 - }  
122 if v, ok := queryOptions["staffAssessId"]; ok { 98 if v, ok := queryOptions["staffAssessId"]; ok {
123 query.Where("staff_assess_id=?", v) 99 query.Where("staff_assess_id=?", v)
124 } 100 }
@@ -126,7 +102,7 @@ func (repo *StaffAssessContentTempRepository) Find(queryOptions map[string]inter @@ -126,7 +102,7 @@ func (repo *StaffAssessContentTempRepository) Find(queryOptions map[string]inter
126 if err != nil { 102 if err != nil {
127 return 0, nil, err 103 return 0, nil, err
128 } 104 }
129 - var arrays []*domain.StaffAssessContent 105 + var arrays []*domain.StaffAssessContentTemp
130 for _, v := range m { 106 for _, v := range m {
131 d := repo.TransformToDomain(v) 107 d := repo.TransformToDomain(v)
132 arrays = append(arrays, d) 108 arrays = append(arrays, d)