正在显示
9 个修改的文件
包含
389 行增加
和
1 行删除
| @@ -24,6 +24,6 @@ type EvaluationItemUsed struct { | @@ -24,6 +24,6 @@ type EvaluationItemUsed struct { | ||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | type EvaluationItemUsedRepository interface { | 26 | type EvaluationItemUsedRepository interface { |
| 27 | - Insert(Item []EvaluationItemUsed) (*EvaluationItemUsed, error) | 27 | + Insert(Item []*EvaluationItemUsed) error |
| 28 | Find(queryOptions map[string]interface{}) (int64, []*EvaluationItemUsed, error) | 28 | Find(queryOptions map[string]interface{}) (int64, []*EvaluationItemUsed, error) |
| 29 | } | 29 | } |
| @@ -52,3 +52,10 @@ const ( | @@ -52,3 +52,10 @@ const ( | ||
| 52 | EvaluationCheckUncompleted EvaluationCheckResult = "uncompleted" //未确认结果 | 52 | EvaluationCheckUncompleted EvaluationCheckResult = "uncompleted" //未确认结果 |
| 53 | EvaluationCheckCompleted EvaluationCheckResult = "completed" //已确认结果 | 53 | EvaluationCheckCompleted EvaluationCheckResult = "completed" //已确认结果 |
| 54 | ) | 54 | ) |
| 55 | + | ||
| 56 | +type SummaryEvaluationRepository interface { | ||
| 57 | + Save(param *SummaryEvaluation) error | ||
| 58 | + Remove(id int) error | ||
| 59 | + FindOne(queryOptions map[string]interface{}) (*SummaryEvaluation, error) | ||
| 60 | + Find(queryOptions map[string]interface{}) (int, []*SummaryEvaluation, error) | ||
| 61 | +} |
| @@ -15,3 +15,10 @@ type SummaryEvaluationValue struct { | @@ -15,3 +15,10 @@ type SummaryEvaluationValue struct { | ||
| 15 | UpdatedAt time.Time //数据更新时间 | 15 | UpdatedAt time.Time //数据更新时间 |
| 16 | DeletedAt *time.Time //数据删除时间 | 16 | DeletedAt *time.Time //数据删除时间 |
| 17 | } | 17 | } |
| 18 | + | ||
| 19 | +type SummaryEvaluationValueRepository interface { | ||
| 20 | + Save(param *SummaryEvaluationValue) error | ||
| 21 | + Remove(id int) error | ||
| 22 | + FindOne(queryOptions map[string]interface{}) (*SummaryEvaluationValue, error) | ||
| 23 | + Find(queryOptions map[string]interface{}) (int, []*SummaryEvaluationValue, error) | ||
| 24 | +} |
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "time" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +// 实际被应用的评估条目 | ||
| 10 | +type EvaluationItemUsed struct { | ||
| 11 | + Id int //id | ||
| 12 | + CompanyId int //公司id | ||
| 13 | + EvaluationProjectId int //对应的项目id | ||
| 14 | + NodeId int //填写评估评估节点对应id | ||
| 15 | + NodeType string //填写评估评估节点对应类型同evaluation_template.go->LinkNode.Type, | ||
| 16 | + SortBy int //排序 | ||
| 17 | + Category string //类别 | ||
| 18 | + Name string //名称 | ||
| 19 | + PromptTitle string //提示项标题 | ||
| 20 | + PromptText string //提示项正文 | ||
| 21 | + EntryItems []domain.EntryItem //填写的反馈 | ||
| 22 | + RuleType int //评估方式(0评级、1评分) | ||
| 23 | + Rule domain.EvaluationRule //评估的选项规则 | ||
| 24 | + Weight float64 //"权重" | ||
| 25 | + Required int // 必填项 | ||
| 26 | + CreatedAt time.Time //数据创建时间 | ||
| 27 | + UpdatedAt time.Time //数据更新时间 | ||
| 28 | +} |
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "time" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +// 周综合评估 | ||
| 10 | +type SummaryEvaluation struct { | ||
| 11 | + tableName struct{} `comment:"周综合评估" pg:"summary_evaluation"` | ||
| 12 | + Id int `pg:",pk"` | ||
| 13 | + CompanyId int //公司id | ||
| 14 | + EvaluationProjectId int //对应的项目id | ||
| 15 | + EvaluationProjectName string //对应的项目名称 | ||
| 16 | + CycleId int64 //对应的周期id | ||
| 17 | + CycleName string //对应的周期名称 | ||
| 18 | + TargetUser domain.StaffDesc //被评估的目标用户,被执行的 | ||
| 19 | + TargetDepartment []domain.StaffDepartment //被评估的目标用户所在的部门 | ||
| 20 | + Executor domain.StaffDesc //填写评估的用户,执行人 | ||
| 21 | + Types int //评估类型 | ||
| 22 | + Status string //评估的填写状态 | ||
| 23 | + CheckResult int //被执行的人确认评估结果 | ||
| 24 | + BeginTime time.Time //开始时间 | ||
| 25 | + EndTime time.Time //截止时间 | ||
| 26 | + TotalScore string //最终上级评估得分. | ||
| 27 | + CreatedAt time.Time //数据创建时间 | ||
| 28 | + UpdatedAt time.Time //数据更新时间 | ||
| 29 | + DeletedAt *time.Time //数据删除时间 | ||
| 30 | +} |
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import "time" | ||
| 4 | + | ||
| 5 | +// 周期综合评估填写的内容 | ||
| 6 | +type SummaryEvaluationValue struct { | ||
| 7 | + tableName struct{} `comment:"周期综合评估填写的内容" pg:"summary_evaluation"` | ||
| 8 | + Id int // | ||
| 9 | + EvaluationItemId int //评估条目的id | ||
| 10 | + SummaryEvaluationId int //综合评估任务(SummaryEvaluation)的id | ||
| 11 | + Value string //评估填写的评分 | ||
| 12 | + Score string //评定得分 | ||
| 13 | + Types int //评估类型 | ||
| 14 | + Remark string //填写的内容反馈 | ||
| 15 | + CreatedAt time.Time //数据创建时间 | ||
| 16 | + UpdatedAt time.Time //数据更新时间 | ||
| 17 | + DeletedAt *time.Time //数据删除时间 | ||
| 18 | +} |
| 1 | package repository | 1 | package repository |
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +type EvaluationItemUsedRepository struct { | ||
| 9 | + transactionContext *pgTransaction.TransactionContext | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +var _ domain.EvaluationItemUsedRepository = (*EvaluationItemUsedRepository)(nil) | ||
| 13 | + | ||
| 14 | +func NewEvaluationItemUsedRepository(transactionContext *pgTransaction.TransactionContext) *EvaluationItemUsedRepository { | ||
| 15 | + return &EvaluationItemUsedRepository{transactionContext: transactionContext} | ||
| 16 | +} | ||
| 17 | + | ||
| 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 | +// } | ||
| 40 | + | ||
| 41 | +func (repo EvaluationItemUsedRepository) Insert(Item []*domain.EvaluationItemUsed) error { | ||
| 42 | + panic("not implemented") // TODO: Implement | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +func (repo EvaluationItemUsedRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.EvaluationItemUsed, error) { | ||
| 46 | + panic("not implemented") // TODO: Implement | ||
| 47 | +} |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "errors" | ||
| 5 | + "fmt" | ||
| 6 | + "time" | ||
| 7 | + | ||
| 8 | + "github.com/go-pg/pg/v10" | ||
| 9 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SummaryEvaluationRepository struct { | ||
| 15 | + transactionContext *pgTransaction.TransactionContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var _ domain.SummaryEvaluationRepository = (*SummaryEvaluationRepository)(nil) | ||
| 19 | + | ||
| 20 | +func NewSummaryEvaluationRepository(transactionContext *pgTransaction.TransactionContext) *SummaryEvaluationRepository { | ||
| 21 | + return &SummaryEvaluationRepository{transactionContext: transactionContext} | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func (repo *SummaryEvaluationRepository) TransformToDomain(d *models.SummaryEvaluation) *domain.SummaryEvaluation { | ||
| 25 | + return &domain.SummaryEvaluation{ | ||
| 26 | + Id: d.Id, | ||
| 27 | + CompanyId: d.CompanyId, | ||
| 28 | + EvaluationProjectId: d.EvaluationProjectId, | ||
| 29 | + EvaluationProjectName: d.EvaluationProjectName, | ||
| 30 | + CycleId: d.CycleId, | ||
| 31 | + CycleName: d.CycleName, | ||
| 32 | + TargetUser: d.TargetUser, | ||
| 33 | + TargetDepartment: d.TargetDepartment, | ||
| 34 | + Executor: d.Executor, | ||
| 35 | + Types: domain.EvaluationType(d.Types), | ||
| 36 | + Status: domain.EvaluationStatus(d.Status), | ||
| 37 | + CheckResult: d.CheckResult, | ||
| 38 | + BeginTime: d.BeginTime, | ||
| 39 | + EndTime: d.EndTime, | ||
| 40 | + TotalScore: d.TotalScore, | ||
| 41 | + CreatedAt: d.CreatedAt, | ||
| 42 | + UpdatedAt: d.UpdatedAt, | ||
| 43 | + DeletedAt: d.DeletedAt, | ||
| 44 | + } | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +func (repo *SummaryEvaluationRepository) Save(param *domain.SummaryEvaluation) error { | ||
| 48 | + m := models.SummaryEvaluation{ | ||
| 49 | + Id: param.Id, | ||
| 50 | + CompanyId: param.CompanyId, | ||
| 51 | + EvaluationProjectId: param.EvaluationProjectId, | ||
| 52 | + EvaluationProjectName: param.EvaluationProjectName, | ||
| 53 | + CycleId: param.CycleId, | ||
| 54 | + CycleName: param.CycleName, | ||
| 55 | + TargetUser: param.TargetUser, | ||
| 56 | + TargetDepartment: param.TargetDepartment, | ||
| 57 | + Executor: param.Executor, | ||
| 58 | + Types: int(param.Types), | ||
| 59 | + Status: string(param.Status), | ||
| 60 | + CheckResult: param.CheckResult, | ||
| 61 | + BeginTime: param.BeginTime, | ||
| 62 | + EndTime: param.EndTime, | ||
| 63 | + TotalScore: param.TotalScore, | ||
| 64 | + CreatedAt: param.CreatedAt, | ||
| 65 | + UpdatedAt: param.UpdatedAt, | ||
| 66 | + DeletedAt: param.DeletedAt, | ||
| 67 | + } | ||
| 68 | + db := repo.transactionContext.PgTx | ||
| 69 | + if m.Id == 0 { | ||
| 70 | + _, err := db.Model(&m).Insert() | ||
| 71 | + if err != nil { | ||
| 72 | + return err | ||
| 73 | + } | ||
| 74 | + } else { | ||
| 75 | + _, err := db.Model(&m).Update() | ||
| 76 | + if err != nil { | ||
| 77 | + return err | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + param.Id = m.Id | ||
| 81 | + return nil | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +func (repo *SummaryEvaluationRepository) Remove(id int) error { | ||
| 85 | + tx := repo.transactionContext.PgTx | ||
| 86 | + nowTime := time.Now() | ||
| 87 | + _, err := tx.Model(&models.SummaryEvaluation{}). | ||
| 88 | + Where("id=?", id). | ||
| 89 | + Set("deleted_at=?", nowTime). | ||
| 90 | + Update() | ||
| 91 | + return err | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +func (repo *SummaryEvaluationRepository) FindOne(queryOptions map[string]interface{}) (*domain.SummaryEvaluation, error) { | ||
| 95 | + tx := repo.transactionContext.PgTx | ||
| 96 | + m := new(models.SummaryEvaluation) | ||
| 97 | + query := tx.Model(m) | ||
| 98 | + query.Where("deleted_at isnull") | ||
| 99 | + if id, ok := queryOptions["id"]; ok { | ||
| 100 | + query.Where("id=?", id) | ||
| 101 | + } | ||
| 102 | + if err := query.First(); err != nil { | ||
| 103 | + if errors.Is(err, pg.ErrNoRows) { | ||
| 104 | + return nil, fmt.Errorf("没有此资源") | ||
| 105 | + } else { | ||
| 106 | + return nil, err | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + u := repo.TransformToDomain(m) | ||
| 110 | + return u, nil | ||
| 111 | +} | ||
| 112 | + | ||
| 113 | +func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{}) (int, []*domain.SummaryEvaluation, error) { | ||
| 114 | + tx := repo.transactionContext.PgTx | ||
| 115 | + var m []*models.SummaryEvaluation | ||
| 116 | + query := tx.Model(&m). | ||
| 117 | + Where("deleted_at isnull").Limit(20) | ||
| 118 | + if v, ok := queryOptions["limit"].(int); ok { | ||
| 119 | + query.Limit(v) | ||
| 120 | + } | ||
| 121 | + if v, ok := queryOptions["offset"].(int); ok { | ||
| 122 | + query.Offset(v) | ||
| 123 | + } | ||
| 124 | + count, err := query.SelectAndCount() | ||
| 125 | + if err != nil { | ||
| 126 | + return 0, nil, err | ||
| 127 | + } | ||
| 128 | + var datas []*domain.SummaryEvaluation | ||
| 129 | + for _, v := range m { | ||
| 130 | + d := repo.TransformToDomain(v) | ||
| 131 | + datas = append(datas, d) | ||
| 132 | + } | ||
| 133 | + return count, datas, nil | ||
| 134 | +} |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "errors" | ||
| 5 | + "fmt" | ||
| 6 | + "time" | ||
| 7 | + | ||
| 8 | + "github.com/go-pg/pg/v10" | ||
| 9 | + pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SummaryEvaluationValueRepository struct { | ||
| 15 | + transactionContext *pgTransaction.TransactionContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var _ domain.SummaryEvaluationValueRepository = (*SummaryEvaluationValueRepository)(nil) | ||
| 19 | + | ||
| 20 | +func NewSummaryEvaluationValueRepository(transactionContext *pgTransaction.TransactionContext) *SummaryEvaluationValueRepository { | ||
| 21 | + return &SummaryEvaluationValueRepository{transactionContext: transactionContext} | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func (repo *SummaryEvaluationValueRepository) TransformToDomain(d *models.SummaryEvaluationValue) *domain.SummaryEvaluationValue { | ||
| 25 | + return &domain.SummaryEvaluationValue{ | ||
| 26 | + Id: d.Id, | ||
| 27 | + EvaluationItemId: d.EvaluationItemId, | ||
| 28 | + SummaryEvaluationId: d.SummaryEvaluationId, | ||
| 29 | + Value: d.Value, | ||
| 30 | + Score: d.Score, | ||
| 31 | + Types: domain.EvaluationType(d.Types), | ||
| 32 | + Remark: d.Remark, | ||
| 33 | + CreatedAt: d.CreatedAt, | ||
| 34 | + UpdatedAt: d.UpdatedAt, | ||
| 35 | + DeletedAt: d.DeletedAt, | ||
| 36 | + } | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluationValue) error { | ||
| 40 | + m := models.SummaryEvaluationValue{ | ||
| 41 | + Id: param.Id, | ||
| 42 | + EvaluationItemId: param.EvaluationItemId, | ||
| 43 | + SummaryEvaluationId: param.SummaryEvaluationId, | ||
| 44 | + Value: param.Value, | ||
| 45 | + Score: param.Score, | ||
| 46 | + Types: int(param.Types), | ||
| 47 | + Remark: param.Remark, | ||
| 48 | + CreatedAt: param.CreatedAt, | ||
| 49 | + UpdatedAt: param.UpdatedAt, | ||
| 50 | + DeletedAt: param.DeletedAt, | ||
| 51 | + } | ||
| 52 | + db := repo.transactionContext.PgTx | ||
| 53 | + if m.Id == 0 { | ||
| 54 | + _, err := db.Model(&m).Insert() | ||
| 55 | + if err != nil { | ||
| 56 | + return err | ||
| 57 | + } | ||
| 58 | + } else { | ||
| 59 | + _, err := db.Model(&m).Update() | ||
| 60 | + if err != nil { | ||
| 61 | + return err | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + param.Id = m.Id | ||
| 65 | + return nil | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +func (repo *SummaryEvaluationValueRepository) Remove(id int) error { | ||
| 69 | + tx := repo.transactionContext.PgTx | ||
| 70 | + nowTime := time.Now() | ||
| 71 | + _, err := tx.Model(&models.SummaryEvaluationValue{}). | ||
| 72 | + Where("id=?", id). | ||
| 73 | + Set("deleted_at=?", nowTime). | ||
| 74 | + Update() | ||
| 75 | + return err | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +func (repo *SummaryEvaluationValueRepository) FindOne(queryOptions map[string]interface{}) (*domain.SummaryEvaluationValue, error) { | ||
| 79 | + tx := repo.transactionContext.PgTx | ||
| 80 | + m := new(models.SummaryEvaluationValue) | ||
| 81 | + query := tx.Model(m) | ||
| 82 | + query.Where("deleted_at isnull") | ||
| 83 | + if id, ok := queryOptions["id"]; ok { | ||
| 84 | + query.Where("id=?", id) | ||
| 85 | + } | ||
| 86 | + if err := query.First(); err != nil { | ||
| 87 | + if errors.Is(err, pg.ErrNoRows) { | ||
| 88 | + return nil, fmt.Errorf("没有此资源") | ||
| 89 | + } else { | ||
| 90 | + return nil, err | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | + u := repo.TransformToDomain(m) | ||
| 94 | + return u, nil | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]interface{}) (int, []*domain.SummaryEvaluationValue, error) { | ||
| 98 | + tx := repo.transactionContext.PgTx | ||
| 99 | + var m []*models.SummaryEvaluationValue | ||
| 100 | + query := tx.Model(&m). | ||
| 101 | + Where("deleted_at isnull").Limit(20) | ||
| 102 | + if v, ok := queryOptions["limit"].(int); ok { | ||
| 103 | + query.Limit(v) | ||
| 104 | + } | ||
| 105 | + if v, ok := queryOptions["offset"].(int); ok { | ||
| 106 | + query.Offset(v) | ||
| 107 | + } | ||
| 108 | + count, err := query.SelectAndCount() | ||
| 109 | + if err != nil { | ||
| 110 | + return 0, nil, err | ||
| 111 | + } | ||
| 112 | + var datas []*domain.SummaryEvaluationValue | ||
| 113 | + for _, v := range m { | ||
| 114 | + d := repo.TransformToDomain(v) | ||
| 115 | + datas = append(datas, d) | ||
| 116 | + } | ||
| 117 | + return count, datas, nil | ||
| 118 | +} |
-
请 注册 或 登录 后发表评论