作者 tangxvhui

bug 修复

... ... @@ -370,76 +370,3 @@ func (c *AuditController) ChanceStoreChange() {
msg = protocol.NewReturnResponse(nil, nil)
return
}
//GetChangeMedia 获取机会的图片、音频、视频的地址
//@router /v1/chance/media
func (c *AuditController) GetChangeMedia() {
var msg *protocol.ResponseMessage
defer func() {
c.ResposeJson(msg)
}()
type Parameter struct {
ChanceId string `json:"chance_id"`
CheckSum string `json:"check_sum"`
}
var param Parameter
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &param); err != nil {
log.Error("json 解析失败", err)
msg = protocol.BadRequestParam("1")
return
}
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
}
... ...
... ... @@ -2,7 +2,7 @@ package routers
import (
"oppmg/controllers"
"oppmg/controllers/openapi"
"oppmg/middleware"
"github.com/astaxie/beego"
... ... @@ -172,7 +172,7 @@ func init() {
nsCommon := beego.NewNamespace("/common",
beego.NSBefore(middleware.AllowOption),
beego.NSBefore(middleware.LogRequestData),
beego.NSRouter("/common/chance/media", &controllers.AuditController{}, "post:GetChangeMedia"),
beego.NSRouter("/common/chance/media", &openapi.OpenApiController{}, "post:GetChangeMedia"), //外链获取机会的图片、视频、音频数据
)
beego.AddNamespace(nsV1)
beego.AddNamespace(nsAuth)
... ... @@ -181,6 +181,5 @@ func init() {
beego.SetStaticPath("/log", beego.AppConfig.String("log_filename"))
beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path"))
beego.SetStaticPath("/static", "./static")
//外链获取机会的图片、视频、音频数据
}
... ...