作者 唐旭辉

新增接口 机会详情

... ... @@ -77,7 +77,7 @@ func (c *AuditController) AuditInfo() {
msg = protocol.BadRequestParam("1")
return
}
chanceid, _ := strconv.ParseInt(param.ChanceId, 10, 64)
chanceid, err := strconv.ParseInt(param.ChanceId, 10, 64)
companyId := c.GetCompanyId()
list, err := serveaudit.GetChanceDetail(chanceid, companyId)
msg = protocol.NewReturnResponse(list, err)
... ...
... ... @@ -7,7 +7,7 @@ import (
)
type ChanceData struct {
Id int `orm:"column(id);pk" description:"唯一编号"`
Id int64 `orm:"column(id);pk" description:"唯一编号"`
ChanceId int64 `orm:"column(chance_id);null" description:"表chance.id 机会编号"`
Images string `orm:"column(images);null" description:"图片 json"`
Speechs string `orm:"column(speechs);null" description:"语音 json"`
... ... @@ -40,3 +40,13 @@ type ChanceDataVideos struct {
Cover ChanceDataImage `json:"cover"`
Duration int `json:"duration"`
}
func GetChanceDataByChanceId(chanceid int64) (v *ChanceData, err error) {
o := orm.NewOrm()
v = &ChanceData{}
err = o.QueryTable(v).Filter("chance_id", chanceid).One(v)
if err == nil {
return v, nil
}
return nil, err
}
... ...
... ... @@ -150,7 +150,7 @@ func GetAuditList(param protocol.RequestAuditList, companyid int64, userid int64
}
type ResponseChanceInfo struct {
CreateTime int64 `json:"create_time"`
CreateTime string `json:"create_time"`
UserName string `json:"user_name"`
ChanceTypeName string `json:"chance_type_name"`
TemplateName string `json:"template_name"`
... ... @@ -170,10 +170,10 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error
returnData = ResponseChanceInfo{
BaseContent: make([]protocol.InputElement, 0),
ExtraContent: make([]protocol.InputElement, 0),
ImageData: make([]models.ChanceDataImage, 0),
VideoData: make([]models.ChanceDataVideos, 0),
SpeechData: make([]models.ChanceDataSpeechs, 0),
FlowLog: make([]protocol.ChanceFlowLog, 0),
// ImageData: make([]models.ChanceDataImage, 0),
// VideoData: make([]models.ChanceDataVideos, 0),
// SpeechData: make([]models.ChanceDataSpeechs, 0),
// FlowLog: make([]protocol.ChanceFlowLog, 0),
}
)
chanceInfo, err = models.GetChanceById(chanceid)
... ... @@ -185,7 +185,7 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error
log.Error("机会的公司不匹配")
return returnData, protocol.NewErrWithMessage("1")
}
returnData.CreateTime = chanceInfo.CreateAt.Unix()
returnData.CreateTime = chanceInfo.CreateAt.Format("2006-01-02 15:16:17")
var (
chanceContent []protocol.InputElement
... ... @@ -202,6 +202,20 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error
returnData.ExtraContent = append(returnData.ExtraContent, chanceContent[i])
}
}
var (
imgData = make([]models.ChanceDataImage, 0)
videosData = make([]models.ChanceDataVideos, 0)
speechsData = make([]models.ChanceDataSpeechs, 0)
)
chancedata, err := models.GetChanceDataByChanceId(chanceid)
if err == nil {
json.Unmarshal([]byte(chancedata.Images), &imgData)
json.Unmarshal([]byte(chancedata.Videos), &videosData)
json.Unmarshal([]byte(chancedata.Speechs), &speechsData)
}
returnData.ImageData = imgData
returnData.VideoData = videosData
returnData.SpeechData = speechsData
ucompany, err := models.GetUserCompanyById(chanceInfo.UserId)
if err == nil {
userinfo, err := models.GetUserById(ucompany.UserId)
... ... @@ -230,6 +244,7 @@ func GetChanceDetail(chanceid int64, companyid int64) (ResponseChanceInfo, error
log.Warn("获取获取记录失败")
}
returnData.FlowLog = flowlogs
return returnData, nil
}
... ...