作者 郑周

1. 环节内容,增加必填项属性,旧数据输出时设置默认值

... ... @@ -20,8 +20,8 @@ const (
)
const (
NodeRequiredYes int = 1 // 是否必填项-必填(默认)
NodeRequiredNo int = 2 // 是否必填项-非必填
NodeRequiredYes int = 1 // 必填项-必填(默认)
NodeRequiredNo int = 2 // 必填项-非必填
)
type EntryItem struct {
... ...
... ... @@ -21,6 +21,17 @@ func NewEvaluationCycleTemplateRepository(transactionContext *pgTransaction.Tran
}
func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.EvaluationCycleTemplate) domain.EvaluationCycleTemplate {
// 历史旧数据,默认输出转成1
if m.Template != nil {
for i := range m.Template.LinkNodes {
node := m.Template.LinkNodes[i]
for j := range node.NodeContents {
if node.NodeContents[j].Required == 0 {
node.NodeContents[j].Required = domain.NodeRequiredYes
}
}
}
}
return domain.EvaluationCycleTemplate{
Id: m.Id,
Name: m.Name,
... ...
... ... @@ -21,6 +21,18 @@ func NewEvaluationProjectRepository(transactionContext *pgTransaction.Transactio
}
func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationProject) domain.EvaluationProject {
// 历史旧数据,默认输出转成1
if m.Template != nil {
for i := range m.Template.LinkNodes {
node := m.Template.LinkNodes[i]
for j := range node.NodeContents {
if node.NodeContents[j].Required == 0 {
node.NodeContents[j].Required = domain.NodeRequiredYes
}
}
}
}
return domain.EvaluationProject{
Id: m.Id,
Name: m.Name,
... ...
... ... @@ -21,6 +21,15 @@ func NewEvaluationTemplateRepository(transactionContext *pgTransaction.Transacti
}
func (repo *EvaluationTemplateRepository) TransformToDomain(m *models.EvaluationTemplate) domain.EvaluationTemplate {
// 历史旧数据,默认输出转成1
for i := range m.LinkNodes {
node := m.LinkNodes[i]
for j := range node.NodeContents {
if node.NodeContents[j].Required == 0 {
node.NodeContents[j].Required = domain.NodeRequiredYes
}
}
}
return domain.EvaluationTemplate{
Id: m.Id,
Name: m.Name,
... ...