|
@@ -3,6 +3,7 @@ package repository |
|
@@ -3,6 +3,7 @@ package repository |
3
|
import (
|
3
|
import (
|
4
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
4
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
6
|
+ "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
|
6
|
)
|
7
|
)
|
7
|
|
8
|
|
8
|
type EvaluationItemUsedRepository struct {
|
9
|
type EvaluationItemUsedRepository struct {
|
|
@@ -15,33 +16,76 @@ func NewEvaluationItemUsedRepository(transactionContext *pgTransaction.Transacti |
|
@@ -15,33 +16,76 @@ func NewEvaluationItemUsedRepository(transactionContext *pgTransaction.Transacti |
15
|
return &EvaluationItemUsedRepository{transactionContext: transactionContext}
|
16
|
return &EvaluationItemUsedRepository{transactionContext: transactionContext}
|
16
|
}
|
17
|
}
|
17
|
|
18
|
|
18
|
-// func (repo *EvaluationItemUsedRepository) TransformToDomain(d *models.SummaryEvaluation) *domain.SummaryEvaluation {
|
|
|
19
|
-// return &domain.SummaryEvaluation{
|
|
|
20
|
-// Id: d.Id,
|
|
|
21
|
-// CompanyId: d.CompanyId,
|
|
|
22
|
-// EvaluationProjectId: d.EvaluationProjectId,
|
|
|
23
|
-// EvaluationProjectName: d.EvaluationProjectName,
|
|
|
24
|
-// CycleId: d.CycleId,
|
|
|
25
|
-// CycleName: d.CycleName,
|
|
|
26
|
-// TargetUser: d.TargetUser,
|
|
|
27
|
-// TargetDepartment: d.TargetDepartment,
|
|
|
28
|
-// Executor: d.Executor,
|
|
|
29
|
-// Types: domain.EvaluationType(d.Types),
|
|
|
30
|
-// Status: domain.EvaluationStatus(d.Status),
|
|
|
31
|
-// CheckResult: d.CheckResult,
|
|
|
32
|
-// BeginTime: d.BeginTime,
|
|
|
33
|
-// EndTime: d.EndTime,
|
|
|
34
|
-// TotalScore: d.TotalScore,
|
|
|
35
|
-// CreatedAt: d.CreatedAt,
|
|
|
36
|
-// UpdatedAt: d.UpdatedAt,
|
|
|
37
|
-// DeletedAt: d.DeletedAt,
|
|
|
38
|
-// }
|
|
|
39
|
-// }
|
19
|
+func (repo *EvaluationItemUsedRepository) TransformToDomain(d *models.EvaluationItemUsed) *domain.EvaluationItemUsed {
|
|
|
20
|
+ return &domain.EvaluationItemUsed{
|
|
|
21
|
+ Id: d.Id,
|
|
|
22
|
+ CompanyId: d.CompanyId,
|
|
|
23
|
+ EvaluationProjectId: d.EvaluationProjectId,
|
|
|
24
|
+ NodeId: d.NodeId,
|
|
|
25
|
+ NodeType: d.NodeType,
|
|
|
26
|
+ SortBy: d.SortBy,
|
|
|
27
|
+ Category: d.Category,
|
|
|
28
|
+ Name: d.Name,
|
|
|
29
|
+ PromptTitle: d.PromptTitle,
|
|
|
30
|
+ PromptText: d.PromptText,
|
|
|
31
|
+ EntryItems: d.EntryItems,
|
|
|
32
|
+ RuleType: d.RuleType,
|
|
|
33
|
+ Rule: d.Rule,
|
|
|
34
|
+ Weight: d.Weight,
|
|
|
35
|
+ Required: d.Required,
|
|
|
36
|
+ CreatedAt: d.CreatedAt,
|
|
|
37
|
+ UpdatedAt: d.UpdatedAt,
|
|
|
38
|
+ }
|
|
|
39
|
+}
|
40
|
|
40
|
|
41
|
-func (repo EvaluationItemUsedRepository) Insert(Item []*domain.EvaluationItemUsed) error {
|
|
|
42
|
- panic("not implemented") // TODO: Implement
|
41
|
+func (repo *EvaluationItemUsedRepository) BatchInsert(items []*domain.EvaluationItemUsed) error {
|
|
|
42
|
+ mList := []*models.EvaluationItemUsed{}
|
|
|
43
|
+ for _, v := range items {
|
|
|
44
|
+ m := models.EvaluationItemUsed{
|
|
|
45
|
+ Id: v.Id,
|
|
|
46
|
+ CompanyId: v.CompanyId,
|
|
|
47
|
+ EvaluationProjectId: v.EvaluationProjectId,
|
|
|
48
|
+ NodeId: v.NodeId,
|
|
|
49
|
+ NodeType: v.NodeType,
|
|
|
50
|
+ SortBy: v.SortBy,
|
|
|
51
|
+ Category: v.Category,
|
|
|
52
|
+ Name: v.Name,
|
|
|
53
|
+ PromptTitle: v.PromptTitle,
|
|
|
54
|
+ PromptText: v.PromptText,
|
|
|
55
|
+ EntryItems: v.EntryItems,
|
|
|
56
|
+ RuleType: v.RuleType,
|
|
|
57
|
+ Rule: v.Rule,
|
|
|
58
|
+ Weight: v.Weight,
|
|
|
59
|
+ Required: v.Required,
|
|
|
60
|
+ CreatedAt: v.CreatedAt,
|
|
|
61
|
+ UpdatedAt: v.UpdatedAt,
|
|
|
62
|
+ }
|
|
|
63
|
+ mList = append(mList, &m)
|
|
|
64
|
+ }
|
|
|
65
|
+ db := repo.transactionContext.PgTx
|
|
|
66
|
+ _, err := db.Model(&mList).Insert()
|
|
|
67
|
+ return err
|
43
|
}
|
68
|
}
|
44
|
|
69
|
|
45
|
-func (repo EvaluationItemUsedRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.EvaluationItemUsed, error) {
|
|
|
46
|
- panic("not implemented") // TODO: Implement
|
70
|
+func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface{}) (int, []*domain.EvaluationItemUsed, error) {
|
|
|
71
|
+ tx := repo.transactionContext.PgTx
|
|
|
72
|
+ var m []*models.EvaluationItemUsed
|
|
|
73
|
+ query := tx.Model(&m).
|
|
|
74
|
+ Where("deleted_at isnull").Limit(20)
|
|
|
75
|
+ if v, ok := queryOptions["limit"].(int); ok {
|
|
|
76
|
+ query.Limit(v)
|
|
|
77
|
+ }
|
|
|
78
|
+ if v, ok := queryOptions["offset"].(int); ok {
|
|
|
79
|
+ query.Offset(v)
|
|
|
80
|
+ }
|
|
|
81
|
+ count, err := query.SelectAndCount()
|
|
|
82
|
+ if err != nil {
|
|
|
83
|
+ return 0, nil, err
|
|
|
84
|
+ }
|
|
|
85
|
+ var datas []*domain.EvaluationItemUsed
|
|
|
86
|
+ for _, v := range m {
|
|
|
87
|
+ d := repo.TransformToDomain(v)
|
|
|
88
|
+ datas = append(datas, d)
|
|
|
89
|
+ }
|
|
|
90
|
+ return count, datas, nil
|
47
|
} |
91
|
} |