作者 tangxvhui

机会详情添加 自查内容

1 package models 1 package models
2 2
3 import ( 3 import (
  4 + "encoding/json"
4 "fmt" 5 "fmt"
5 "time" 6 "time"
6 7
@@ -101,6 +102,12 @@ type ChanceSelfCheck struct { @@ -101,6 +102,12 @@ type ChanceSelfCheck struct {
101 Answer string `json::"answer"` 102 Answer string `json::"answer"`
102 } 103 }
103 104
  105 +func (m *Chance) GetSelfCheckData() []ChanceSelfCheck {
  106 + var data []ChanceSelfCheck
  107 + json.Unmarshal([]byte(m.SelfChecks), &data)
  108 + return data
  109 +}
  110 +
104 // AddChance insert a new Chance into database and returns 111 // AddChance insert a new Chance into database and returns
105 // last inserted Id on success. 112 // last inserted Id on success.
106 func AddChance(m *Chance) (id int64, err error) { 113 func AddChance(m *Chance) (id int64, err error) {
@@ -421,7 +421,7 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error @@ -421,7 +421,7 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error
421 log.Warn("获取获取记录失败") 421 log.Warn("获取获取记录失败")
422 } 422 }
423 returnData.FlowLog = flowlogs 423 returnData.FlowLog = flowlogs
424 - returnData.SelfCheck = getChanceSelfChecks(chanceid) 424 + returnData.SelfCheck = getChanceSelfChecks(chanceInfo)
425 return returnData, nil 425 return returnData, nil
426 } 426 }
427 427
@@ -444,8 +444,16 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) { @@ -444,8 +444,16 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) {
444 return flowLogs, err 444 return flowLogs, err
445 } 445 }
446 446
447 -func getChanceSelfChecks(chanceId int64) []ChanceSelfCheckData { 447 +func getChanceSelfChecks(chanceInfo *models.Chance) []ChanceSelfCheckData {
448 selfchecks := []ChanceSelfCheckData{} 448 selfchecks := []ChanceSelfCheckData{}
  449 + mSelfChecks := chanceInfo.GetSelfCheckData()
  450 + for _, v := range mSelfChecks {
  451 + m := ChanceSelfCheckData{
  452 + Title: v.ChickItem,
  453 + Result: v.Answer,
  454 + }
  455 + selfchecks = append(selfchecks, m)
  456 + }
449 return selfchecks 457 return selfchecks
450 } 458 }
451 459