作者 tangxvhui

新添加 结构

... ... @@ -24,6 +24,6 @@ type EvaluationItemUsed struct {
}
type EvaluationItemUsedRepository interface {
Insert(Item []EvaluationItemUsed) (*EvaluationItemUsed, error)
Insert(Item []*EvaluationItemUsed) error
Find(queryOptions map[string]interface{}) (int64, []*EvaluationItemUsed, error)
}
... ...
... ... @@ -52,3 +52,10 @@ const (
EvaluationCheckUncompleted EvaluationCheckResult = "uncompleted" //未确认结果
EvaluationCheckCompleted EvaluationCheckResult = "completed" //已确认结果
)
type SummaryEvaluationRepository interface {
Save(param *SummaryEvaluation) error
Remove(id int) error
FindOne(queryOptions map[string]interface{}) (*SummaryEvaluation, error)
Find(queryOptions map[string]interface{}) (int, []*SummaryEvaluation, error)
}
... ...
... ... @@ -15,3 +15,10 @@ type SummaryEvaluationValue struct {
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time //数据删除时间
}
type SummaryEvaluationValueRepository interface {
Save(param *SummaryEvaluationValue) error
Remove(id int) error
FindOne(queryOptions map[string]interface{}) (*SummaryEvaluationValue, error)
Find(queryOptions map[string]interface{}) (int, []*SummaryEvaluationValue, error)
}
... ...
package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 实际被应用的评估条目
type EvaluationItemUsed struct {
Id int //id
CompanyId int //公司id
EvaluationProjectId int //对应的项目id
NodeId int //填写评估评估节点对应id
NodeType string //填写评估评估节点对应类型同evaluation_template.go->LinkNode.Type,
SortBy int //排序
Category string //类别
Name string //名称
PromptTitle string //提示项标题
PromptText string //提示项正文
EntryItems []domain.EntryItem //填写的反馈
RuleType int //评估方式(0评级、1评分)
Rule domain.EvaluationRule //评估的选项规则
Weight float64 //"权重"
Required int // 必填项
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
}
... ...
package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 周综合评估
type SummaryEvaluation struct {
tableName struct{} `comment:"周综合评估" pg:"summary_evaluation"`
Id int `pg:",pk"`
CompanyId int //公司id
EvaluationProjectId int //对应的项目id
EvaluationProjectName string //对应的项目名称
CycleId int64 //对应的周期id
CycleName string //对应的周期名称
TargetUser domain.StaffDesc //被评估的目标用户,被执行的
TargetDepartment []domain.StaffDepartment //被评估的目标用户所在的部门
Executor domain.StaffDesc //填写评估的用户,执行人
Types int //评估类型
Status string //评估的填写状态
CheckResult int //被执行的人确认评估结果
BeginTime time.Time //开始时间
EndTime time.Time //截止时间
TotalScore string //最终上级评估得分.
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time //数据删除时间
}
... ...
package models
import "time"
// 周期综合评估填写的内容
type SummaryEvaluationValue struct {
tableName struct{} `comment:"周期综合评估填写的内容" pg:"summary_evaluation"`
Id int //
EvaluationItemId int //评估条目的id
SummaryEvaluationId int //综合评估任务(SummaryEvaluation)的id
Value string //评估填写的评分
Score string //评定得分
Types int //评估类型
Remark string //填写的内容反馈
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time //数据删除时间
}
... ...
package repository
import (
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type EvaluationItemUsedRepository struct {
transactionContext *pgTransaction.TransactionContext
}
var _ domain.EvaluationItemUsedRepository = (*EvaluationItemUsedRepository)(nil)
func NewEvaluationItemUsedRepository(transactionContext *pgTransaction.TransactionContext) *EvaluationItemUsedRepository {
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) Insert(Item []*domain.EvaluationItemUsed) error {
panic("not implemented") // TODO: Implement
}
func (repo EvaluationItemUsedRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.EvaluationItemUsed, error) {
panic("not implemented") // TODO: Implement
}
... ...
package repository
import (
"errors"
"fmt"
"time"
"github.com/go-pg/pg/v10"
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 SummaryEvaluationRepository struct {
transactionContext *pgTransaction.TransactionContext
}
var _ domain.SummaryEvaluationRepository = (*SummaryEvaluationRepository)(nil)
func NewSummaryEvaluationRepository(transactionContext *pgTransaction.TransactionContext) *SummaryEvaluationRepository {
return &SummaryEvaluationRepository{transactionContext: transactionContext}
}
func (repo *SummaryEvaluationRepository) 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 *SummaryEvaluationRepository) Save(param *domain.SummaryEvaluation) error {
m := models.SummaryEvaluation{
Id: param.Id,
CompanyId: param.CompanyId,
EvaluationProjectId: param.EvaluationProjectId,
EvaluationProjectName: param.EvaluationProjectName,
CycleId: param.CycleId,
CycleName: param.CycleName,
TargetUser: param.TargetUser,
TargetDepartment: param.TargetDepartment,
Executor: param.Executor,
Types: int(param.Types),
Status: string(param.Status),
CheckResult: param.CheckResult,
BeginTime: param.BeginTime,
EndTime: param.EndTime,
TotalScore: param.TotalScore,
CreatedAt: param.CreatedAt,
UpdatedAt: param.UpdatedAt,
DeletedAt: param.DeletedAt,
}
db := repo.transactionContext.PgTx
if m.Id == 0 {
_, err := db.Model(&m).Insert()
if err != nil {
return err
}
} else {
_, err := db.Model(&m).Update()
if err != nil {
return err
}
}
param.Id = m.Id
return nil
}
func (repo *SummaryEvaluationRepository) Remove(id int) error {
tx := repo.transactionContext.PgTx
nowTime := time.Now()
_, err := tx.Model(&models.SummaryEvaluation{}).
Where("id=?", id).
Set("deleted_at=?", nowTime).
Update()
return err
}
func (repo *SummaryEvaluationRepository) FindOne(queryOptions map[string]interface{}) (*domain.SummaryEvaluation, error) {
tx := repo.transactionContext.PgTx
m := new(models.SummaryEvaluation)
query := tx.Model(m)
query.Where("deleted_at isnull")
if id, ok := queryOptions["id"]; ok {
query.Where("id=?", id)
}
if err := query.First(); err != nil {
if errors.Is(err, pg.ErrNoRows) {
return nil, fmt.Errorf("没有此资源")
} else {
return nil, err
}
}
u := repo.TransformToDomain(m)
return u, nil
}
func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{}) (int, []*domain.SummaryEvaluation, error) {
tx := repo.transactionContext.PgTx
var m []*models.SummaryEvaluation
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.SummaryEvaluation
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
}
return count, datas, nil
}
... ...
package repository
import (
"errors"
"fmt"
"time"
"github.com/go-pg/pg/v10"
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 SummaryEvaluationValueRepository struct {
transactionContext *pgTransaction.TransactionContext
}
var _ domain.SummaryEvaluationValueRepository = (*SummaryEvaluationValueRepository)(nil)
func NewSummaryEvaluationValueRepository(transactionContext *pgTransaction.TransactionContext) *SummaryEvaluationValueRepository {
return &SummaryEvaluationValueRepository{transactionContext: transactionContext}
}
func (repo *SummaryEvaluationValueRepository) TransformToDomain(d *models.SummaryEvaluationValue) *domain.SummaryEvaluationValue {
return &domain.SummaryEvaluationValue{
Id: d.Id,
EvaluationItemId: d.EvaluationItemId,
SummaryEvaluationId: d.SummaryEvaluationId,
Value: d.Value,
Score: d.Score,
Types: domain.EvaluationType(d.Types),
Remark: d.Remark,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: d.DeletedAt,
}
}
func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluationValue) error {
m := models.SummaryEvaluationValue{
Id: param.Id,
EvaluationItemId: param.EvaluationItemId,
SummaryEvaluationId: param.SummaryEvaluationId,
Value: param.Value,
Score: param.Score,
Types: int(param.Types),
Remark: param.Remark,
CreatedAt: param.CreatedAt,
UpdatedAt: param.UpdatedAt,
DeletedAt: param.DeletedAt,
}
db := repo.transactionContext.PgTx
if m.Id == 0 {
_, err := db.Model(&m).Insert()
if err != nil {
return err
}
} else {
_, err := db.Model(&m).Update()
if err != nil {
return err
}
}
param.Id = m.Id
return nil
}
func (repo *SummaryEvaluationValueRepository) Remove(id int) error {
tx := repo.transactionContext.PgTx
nowTime := time.Now()
_, err := tx.Model(&models.SummaryEvaluationValue{}).
Where("id=?", id).
Set("deleted_at=?", nowTime).
Update()
return err
}
func (repo *SummaryEvaluationValueRepository) FindOne(queryOptions map[string]interface{}) (*domain.SummaryEvaluationValue, error) {
tx := repo.transactionContext.PgTx
m := new(models.SummaryEvaluationValue)
query := tx.Model(m)
query.Where("deleted_at isnull")
if id, ok := queryOptions["id"]; ok {
query.Where("id=?", id)
}
if err := query.First(); err != nil {
if errors.Is(err, pg.ErrNoRows) {
return nil, fmt.Errorf("没有此资源")
} else {
return nil, err
}
}
u := repo.TransformToDomain(m)
return u, nil
}
func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]interface{}) (int, []*domain.SummaryEvaluationValue, error) {
tx := repo.transactionContext.PgTx
var m []*models.SummaryEvaluationValue
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.SummaryEvaluationValue
for _, v := range m {
d := repo.TransformToDomain(v)
datas = append(datas, d)
}
return count, datas, nil
}
... ...