作者 yangfu

修改 机会详情(自查内容)

... ... @@ -49,8 +49,8 @@ type selfCheckResult struct {
type SelfCheck struct {
CheckItem string `json:"checkItem"`
GroupId int64 `json:"groupId"` //分组
Answer string `json:"answer,omitempty"`
Reason string `json:"reason,omitempty"`
Answer string `json:"answer"`
Reason string `json:"reason"`
Id int64 `json:"id"`
ParentId int64 `json:"parentId"`
... ... @@ -234,15 +234,29 @@ func (s SelfChecks) SetSelfChecksLevel1ByRule() (err error) {
}
//格式化数据结构
func (s SelfChecks) Format() {
func (s SelfChecks) Format() SelfChecks {
if len(s) == 0 {
return
return s
}
for i := range s {
if strings.TrimSpace(s[i].Answer) == OptionNo {
s[i].Reason = strings.TrimSpace(s[i].Reason)
}
}
return s
}
//格式化数据结构
func (s SelfChecks) ClearEmpty() (rsp SelfChecks) {
if len(s) == 0 {
return
}
for i := range s {
if len(s[i].Answer) > 0 {
rsp = append(rsp, s[i])
}
}
return
}
//新建自查问题
... ...
... ... @@ -567,6 +567,6 @@ func GetChanceSelfChecks(chanceInfo *models.Chance) []protocol.SelfCheck {
}
return lv1List
}
protocol.SelfChecks(selfChecks).Format()
selfChecks = protocol.SelfChecks(selfChecks).Format().ClearEmpty()
return selfChecks
}
... ...