...
|
...
|
@@ -3,6 +3,7 @@ package repository |
|
|
import (
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
|
|
|
)
|
|
|
|
|
|
type EvaluationItemUsedRepository struct {
|
...
|
...
|
@@ -15,33 +16,76 @@ func NewEvaluationItemUsedRepository(transactionContext *pgTransaction.Transacti |
|
|
return &EvaluationItemUsedRepository{transactionContext: transactionContext}
|
|
|
}
|
|
|
|
|
|
// func (repo *EvaluationItemUsedRepository) TransformToDomain(d *models.SummaryEvaluation) *domain.SummaryEvaluation {
|
|
|
// return &domain.SummaryEvaluation{
|
|
|
// Id: d.Id,
|
|
|
// CompanyId: d.CompanyId,
|
|
|
// EvaluationProjectId: d.EvaluationProjectId,
|
|
|
// EvaluationProjectName: d.EvaluationProjectName,
|
|
|
// CycleId: d.CycleId,
|
|
|
// CycleName: d.CycleName,
|
|
|
// TargetUser: d.TargetUser,
|
|
|
// TargetDepartment: d.TargetDepartment,
|
|
|
// Executor: d.Executor,
|
|
|
// Types: domain.EvaluationType(d.Types),
|
|
|
// Status: domain.EvaluationStatus(d.Status),
|
|
|
// CheckResult: d.CheckResult,
|
|
|
// BeginTime: d.BeginTime,
|
|
|
// EndTime: d.EndTime,
|
|
|
// TotalScore: d.TotalScore,
|
|
|
// CreatedAt: d.CreatedAt,
|
|
|
// UpdatedAt: d.UpdatedAt,
|
|
|
// DeletedAt: d.DeletedAt,
|
|
|
// }
|
|
|
// }
|
|
|
func (repo *EvaluationItemUsedRepository) TransformToDomain(d *models.EvaluationItemUsed) *domain.EvaluationItemUsed {
|
|
|
return &domain.EvaluationItemUsed{
|
|
|
Id: d.Id,
|
|
|
CompanyId: d.CompanyId,
|
|
|
EvaluationProjectId: d.EvaluationProjectId,
|
|
|
NodeId: d.NodeId,
|
|
|
NodeType: d.NodeType,
|
|
|
SortBy: d.SortBy,
|
|
|
Category: d.Category,
|
|
|
Name: d.Name,
|
|
|
PromptTitle: d.PromptTitle,
|
|
|
PromptText: d.PromptText,
|
|
|
EntryItems: d.EntryItems,
|
|
|
RuleType: d.RuleType,
|
|
|
Rule: d.Rule,
|
|
|
Weight: d.Weight,
|
|
|
Required: d.Required,
|
|
|
CreatedAt: d.CreatedAt,
|
|
|
UpdatedAt: d.UpdatedAt,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (repo EvaluationItemUsedRepository) Insert(Item []*domain.EvaluationItemUsed) error {
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
func (repo *EvaluationItemUsedRepository) BatchInsert(items []*domain.EvaluationItemUsed) error {
|
|
|
mList := []*models.EvaluationItemUsed{}
|
|
|
for _, v := range items {
|
|
|
m := models.EvaluationItemUsed{
|
|
|
Id: v.Id,
|
|
|
CompanyId: v.CompanyId,
|
|
|
EvaluationProjectId: v.EvaluationProjectId,
|
|
|
NodeId: v.NodeId,
|
|
|
NodeType: v.NodeType,
|
|
|
SortBy: v.SortBy,
|
|
|
Category: v.Category,
|
|
|
Name: v.Name,
|
|
|
PromptTitle: v.PromptTitle,
|
|
|
PromptText: v.PromptText,
|
|
|
EntryItems: v.EntryItems,
|
|
|
RuleType: v.RuleType,
|
|
|
Rule: v.Rule,
|
|
|
Weight: v.Weight,
|
|
|
Required: v.Required,
|
|
|
CreatedAt: v.CreatedAt,
|
|
|
UpdatedAt: v.UpdatedAt,
|
|
|
}
|
|
|
mList = append(mList, &m)
|
|
|
}
|
|
|
db := repo.transactionContext.PgTx
|
|
|
_, err := db.Model(&mList).Insert()
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
func (repo EvaluationItemUsedRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.EvaluationItemUsed, error) {
|
|
|
panic("not implemented") // TODO: Implement
|
|
|
func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface{}) (int, []*domain.EvaluationItemUsed, error) {
|
|
|
tx := repo.transactionContext.PgTx
|
|
|
var m []*models.EvaluationItemUsed
|
|
|
query := tx.Model(&m).
|
|
|
Where("deleted_at isnull").Limit(20)
|
|
|
if v, ok := queryOptions["limit"].(int); ok {
|
|
|
query.Limit(v)
|
|
|
}
|
|
|
if v, ok := queryOptions["offset"].(int); ok {
|
|
|
query.Offset(v)
|
|
|
}
|
|
|
count, err := query.SelectAndCount()
|
|
|
if err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
var datas []*domain.EvaluationItemUsed
|
|
|
for _, v := range m {
|
|
|
d := repo.TransformToDomain(v)
|
|
|
datas = append(datas, d)
|
|
|
}
|
|
|
return count, datas, nil
|
|
|
} |
...
|
...
|
|