作者 tangxvhui

更新 数据结构,IsTemporary

... ... @@ -5,6 +5,7 @@ type EditEvaluationValue struct {
ExecutorId int `json:"-"` // 执行人id
CompanyId int `json:"-"` // 公司id
EvaluationItems []UpdatedItemValue `json:"evaluationItems"`
IsTemporary bool `json:"isTemporary"` //是否是临时提交
}
type UpdatedItemValue struct {
... ...
... ... @@ -465,11 +465,13 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil)
err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if !param.IsTemporary {
evaluationData.Status = domain.EvaluationCompleted
}
//保存填写值
for _, v := range itemValueList {
err = itemValueRepo.Save(v)
... ... @@ -801,12 +803,14 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval
return nil, err
}
err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue)
err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if !param.IsTemporary {
//变更评估状态为已填写
evaluationData.Status = domain.EvaluationCompleted
}
for _, v := range itemValueList {
//保存填写值
err = itemValueRepo.Save(v)
... ... @@ -1337,6 +1341,7 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
evaluationItems []*domain.EvaluationItemUsed,
updatedValue []command.UpdatedItemValue,
defaultItemValue []*domain.SummaryEvaluationValue,
IsTemporary bool,
) error {
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
... ... @@ -1344,6 +1349,9 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
for _, v := range evaluationItems {
newValue := &domain.SummaryEvaluationValue{}
newValue.SetBlankValue(evaluationData, v)
if IsTemporary {
newValue.IsTemporary = 1
}
evaluationValueMap[v.Id] = newValue
evaluationItemMap[v.Id] = v
//重置计数
... ...
... ... @@ -390,12 +390,15 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil)
err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if !param.IsTemporary {
//变更评估状态为已填写
summaryEvaluation.Status = domain.EvaluationCompleted
}
//保存填写值
for _, v := range itemValueList {
err = itemValueRepo.Save(v)
... ... @@ -702,12 +705,14 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil)
err = srv.editEvaluationValue(summaryEvaluation, &itemValueList, itemList, param.EvaluationItems, nil, param.IsTemporary)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if !param.IsTemporary {
//变更评估状态为已填写
summaryEvaluation.Status = domain.EvaluationCompleted
}
//保存填写值
for _, v := range itemValueList {
err = itemValueRepo.Save(v)
... ...
... ... @@ -19,6 +19,7 @@ type SummaryEvaluationValue struct {
Rating RatingLevel `json:"rating"` //评级时的填写值
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
IsTemporary int `json:"IsTemporary"` // 0-正式数据 1-临时提交的数据
}
type SummaryEvaluationValueRepository interface {
... ...
... ... @@ -20,4 +20,5 @@ type SummaryEvaluationValue struct {
Remark string //填写的内容反馈
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
IsTemporary int `pg:",use_zero"` // 0-正式数据 1-临时提交的数据
}
... ...
... ... @@ -34,6 +34,7 @@ func (repo *SummaryEvaluationValueRepository) TransformToDomain(d *models.Summar
Rating: d.Rating,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
IsTemporary: d.IsTemporary,
}
}
... ... @@ -50,6 +51,7 @@ func (repo *SummaryEvaluationValueRepository) Save(param *domain.SummaryEvaluati
Remark: param.Remark,
CreatedAt: param.CreatedAt,
UpdatedAt: param.UpdatedAt,
IsTemporary: param.IsTemporary,
}
db := repo.transactionContext.PgTx
if m.Id == 0 {
... ...