作者 tangxvhui

获取静态数据

... ... @@ -388,11 +388,58 @@ func (c *AuditController) GetChangeMedia() {
msg = protocol.BadRequestParam("1")
return
}
// chanceId, _ := strconv.ParseInt(param.ChanceId, 10, 64)
// var (
// err error
// chanceData models.ChanceData
// )
// models.GetChanceDataByChanceId(chanceId)
chanceId, _ := strconv.ParseInt(param.ChanceId, 10, 64)
var (
err error
chanceData *models.ChanceData
imageData []models.ChanceDataImage
speedchsData []models.ChanceDataSpeechs
videosData []models.ChanceDataVideos
)
chanceData, err = models.GetChanceDataByChanceId(chanceId)
rsp := []map[string]interface{}{}
if err != nil {
msg = protocol.NewReturnResponse(nil, nil)
return
}
json.Unmarshal([]byte(chanceData.Images), &imageData)
json.Unmarshal([]byte(chanceData.Speechs), &speedchsData)
json.Unmarshal([]byte(chanceData.Videos), &videosData)
videoMapData := []map[string]interface{}{}
for i := range videosData {
m := map[string]interface{}{
"path": videosData[i].Path,
"cover": map[string]string{
"path": videosData[i].Cover.Path,
},
}
videoMapData = append(videoMapData, m)
}
rsp = append(rsp, map[string]interface{}{
"type": 1, "data": videoMapData,
})
imgMapData := []map[string]interface{}{}
for i := range imageData {
m := map[string]interface{}{
"path": imageData[i].Path,
}
imgMapData = append(imgMapData, m)
}
rsp = append(rsp, map[string]interface{}{
"type": 2, "data": imgMapData,
})
speedchMapData := []map[string]interface{}{}
for i := range speedchsData {
m := map[string]interface{}{
"path": speedchsData[i].Path,
}
speedchMapData = append(speedchMapData, m)
}
rsp = append(rsp, map[string]interface{}{
"type": 3, "data": speedchMapData,
})
msg = protocol.NewReturnResponse(rsp, nil)
return
}
... ...
... ... @@ -172,8 +172,9 @@ func init() {
beego.AddNamespace(nsV1)
beego.AddNamespace(nsAuth)
beego.AddNamespace(nsUcenter)
beego.SetStaticPath("/log", beego.AppConfig.String("log_filename"))
beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path"))
beego.SetStaticPath("/static", "./static")
//外链获取机会的图片、视频、音频数据
beego.Router("/common/chance/media", &controllers.AuditController{}, "post:GetChangeMedia")
}
... ...