作者 tangxvhui

剔除 无效代码

@@ -161,14 +161,6 @@ func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.Staf @@ -161,14 +161,6 @@ func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.Staf
161 return repository.NewStaffAssessTaskRepository(transactionContext) 161 return repository.NewStaffAssessTaskRepository(transactionContext)
162 } 162 }
163 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 -}  
171 -  
172 func CreateStaffAssessCacheRepository(options map[string]interface{}) domain.StaffAssessCacheRepository { 164 func CreateStaffAssessCacheRepository(options map[string]interface{}) domain.StaffAssessCacheRepository {
173 var transactionContext *pg.TransactionContext 165 var transactionContext *pg.TransactionContext
174 if value, ok := options["transactionContext"]; ok { 166 if value, ok := options["transactionContext"]; ok {
1 -package domain  
2 -  
3 -import "time"  
4 -  
5 -//填写的评估内容,临时保存的数据  
6 -type StaffAssessContentTemp struct {  
7 - Id int `json:"id"` //id  
8 - StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id  
9 - SortBy int `json:"sortBy"` //排序  
10 - Category string `json:"category"` //类别  
11 - Name string `json:"name"` //名称  
12 - Remark []AssessContemtRemark `json:"remark"` //填写的反馈  
13 - Value string `json:"value"` //评估填写的值  
14 - CreatedAt time.Time `json:"createdAt"` //数据创建时间  
15 - UpdatedAt time.Time `json:"updatedAt"` //数据更新时间  
16 -}  
17 -  
18 -type StaffAssessContentTempRepository interface {  
19 - Save(param *StaffAssessContentTemp) (*StaffAssessContentTemp, error)  
20 - Remove(id int) error  
21 - FindOne(queryOptions map[string]interface{}) (*StaffAssessContentTemp, error)  
22 - Find(queryOptions map[string]interface{}) (int, []*StaffAssessContentTemp, error)  
23 -}  
1 -package repository  
2 -  
3 -import (  
4 - "errors"  
5 - "fmt"  
6 -  
7 - "github.com/go-pg/pg/v10"  
8 - pgTransaction "github.com/linmadan/egglib-go/transaction/pg"  
9 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"  
10 - "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"  
11 -)  
12 -  
13 -type StaffAssessContentTempRepository struct {  
14 - transactionContext *pgTransaction.TransactionContext  
15 -}  
16 -  
17 -var _ domain.StaffAssessContentTempRepository = (*StaffAssessContentTempRepository)(nil)  
18 -  
19 -func NewStaffAssessContentTempRepository(transactionContext *pgTransaction.TransactionContext) *StaffAssessContentTempRepository {  
20 - return &StaffAssessContentTempRepository{transactionContext: transactionContext}  
21 -}  
22 -  
23 -func (repo *StaffAssessContentTempRepository) TransformToDomain(d *models.StaffAssessContentTemp) *domain.StaffAssessContentTemp {  
24 - return &domain.StaffAssessContentTemp{  
25 - Id: d.Id,  
26 - StaffAssessId: d.StaffAssessId,  
27 - SortBy: d.SortBy,  
28 - Category: d.Category,  
29 - Name: d.Name,  
30 - Remark: d.Remark,  
31 - Value: d.Value,  
32 - CreatedAt: d.CreatedAt,  
33 - UpdatedAt: d.UpdatedAt,  
34 - }  
35 -}  
36 -  
37 -func (repo *StaffAssessContentTempRepository) Save(d *domain.StaffAssessContentTemp) (*domain.StaffAssessContentTemp, error) {  
38 - saveModel := models.StaffAssessContentTemp{  
39 - Id: d.Id,  
40 - StaffAssessId: d.StaffAssessId,  
41 - SortBy: d.SortBy,  
42 - Category: d.Category,  
43 - Name: d.Name,  
44 - Remark: d.Remark,  
45 - Value: d.Value,  
46 - CreatedAt: d.CreatedAt,  
47 - UpdatedAt: d.UpdatedAt,  
48 - }  
49 - tx := repo.transactionContext.PgTx  
50 - var err error  
51 - if saveModel.Id == 0 {  
52 - _, err = tx.Model(&saveModel).Insert()  
53 - if err != nil {  
54 - return nil, err  
55 - }  
56 - } else {  
57 - _, err = tx.Model(&saveModel).WherePK().Update()  
58 - if err != nil {  
59 - return nil, err  
60 - }  
61 - }  
62 - d.Id = saveModel.Id  
63 - return d, nil  
64 -}  
65 -  
66 -func (repo *StaffAssessContentTempRepository) Remove(id int) error {  
67 - tx := repo.transactionContext.PgTx  
68 - _, err := tx.Model(&models.StaffAssessContentTemp{}).  
69 - Where("id=?", id).Delete()  
70 - return err  
71 -}  
72 -  
73 -func (repo *StaffAssessContentTempRepository) FindOne(queryOptions map[string]interface{}) (*domain.StaffAssessContentTemp, error) {  
74 - tx := repo.transactionContext.PgTx  
75 - m := new(models.StaffAssessContentTemp)  
76 - query := tx.Model(m)  
77 - if id, ok := queryOptions["id"]; ok {  
78 - query.Where("id=?", id)  
79 - }  
80 - if err := query.First(); err != nil {  
81 - if errors.Is(err, pg.ErrNoRows) {  
82 - return nil, fmt.Errorf("没有此资源")  
83 - } else {  
84 - return nil, err  
85 - }  
86 - }  
87 - u := repo.TransformToDomain(m)  
88 - return u, nil  
89 -}  
90 -  
91 -func (repo *StaffAssessContentTempRepository) Find(queryOptions map[string]interface{}) (int, []*domain.StaffAssessContentTemp, error) {  
92 - tx := repo.transactionContext.PgTx  
93 - var m []*models.StaffAssessContentTemp  
94 - query := tx.Model(&m)  
95 - if companyId, ok := queryOptions["companyId"]; ok {  
96 - query.Where("company_id = ?", companyId)  
97 - }  
98 - if v, ok := queryOptions["staffAssessId"]; ok {  
99 - query.Where("staff_assess_id=?", v)  
100 - }  
101 - count, err := query.SelectAndCount()  
102 - if err != nil {  
103 - return 0, nil, err  
104 - }  
105 - var arrays []*domain.StaffAssessContentTemp  
106 - for _, v := range m {  
107 - d := repo.TransformToDomain(v)  
108 - arrays = append(arrays, d)  
109 - }  
110 - return count, arrays, nil  
111 -}