作者 tangxvhui

获取静态数据

@@ -388,11 +388,58 @@ func (c *AuditController) GetChangeMedia() { @@ -388,11 +388,58 @@ func (c *AuditController) GetChangeMedia() {
388 msg = protocol.BadRequestParam("1") 388 msg = protocol.BadRequestParam("1")
389 return 389 return
390 } 390 }
391 - // chanceId, _ := strconv.ParseInt(param.ChanceId, 10, 64)  
392 - // var (  
393 - // err error  
394 - // chanceData models.ChanceData  
395 - // )  
396 - // models.GetChanceDataByChanceId(chanceId) 391 + chanceId, _ := strconv.ParseInt(param.ChanceId, 10, 64)
  392 + var (
  393 + err error
  394 + chanceData *models.ChanceData
  395 + imageData []models.ChanceDataImage
  396 + speedchsData []models.ChanceDataSpeechs
  397 + videosData []models.ChanceDataVideos
  398 + )
  399 + chanceData, err = models.GetChanceDataByChanceId(chanceId)
  400 + rsp := []map[string]interface{}{}
  401 + if err != nil {
  402 + msg = protocol.NewReturnResponse(nil, nil)
  403 + return
  404 + }
  405 + json.Unmarshal([]byte(chanceData.Images), &imageData)
  406 + json.Unmarshal([]byte(chanceData.Speechs), &speedchsData)
  407 + json.Unmarshal([]byte(chanceData.Videos), &videosData)
  408 + videoMapData := []map[string]interface{}{}
  409 + for i := range videosData {
  410 + m := map[string]interface{}{
  411 + "path": videosData[i].Path,
  412 + "cover": map[string]string{
  413 + "path": videosData[i].Cover.Path,
  414 + },
  415 + }
  416 + videoMapData = append(videoMapData, m)
  417 + }
  418 + rsp = append(rsp, map[string]interface{}{
  419 + "type": 1, "data": videoMapData,
  420 + })
  421 +
  422 + imgMapData := []map[string]interface{}{}
  423 + for i := range imageData {
  424 + m := map[string]interface{}{
  425 + "path": imageData[i].Path,
  426 + }
  427 + imgMapData = append(imgMapData, m)
  428 + }
  429 + rsp = append(rsp, map[string]interface{}{
  430 + "type": 2, "data": imgMapData,
  431 + })
  432 + speedchMapData := []map[string]interface{}{}
  433 + for i := range speedchsData {
  434 + m := map[string]interface{}{
  435 + "path": speedchsData[i].Path,
  436 + }
  437 + speedchMapData = append(speedchMapData, m)
  438 + }
  439 + rsp = append(rsp, map[string]interface{}{
  440 + "type": 3, "data": speedchMapData,
  441 + })
  442 + msg = protocol.NewReturnResponse(rsp, nil)
397 return 443 return
  444 +
398 } 445 }
@@ -172,8 +172,9 @@ func init() { @@ -172,8 +172,9 @@ func init() {
172 beego.AddNamespace(nsV1) 172 beego.AddNamespace(nsV1)
173 beego.AddNamespace(nsAuth) 173 beego.AddNamespace(nsAuth)
174 beego.AddNamespace(nsUcenter) 174 beego.AddNamespace(nsUcenter)
175 -  
176 beego.SetStaticPath("/log", beego.AppConfig.String("log_filename")) 175 beego.SetStaticPath("/log", beego.AppConfig.String("log_filename"))
177 beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path")) 176 beego.SetStaticPath("/file/opp", beego.AppConfig.String("file_save_path"))
178 beego.SetStaticPath("/static", "./static") 177 beego.SetStaticPath("/static", "./static")
  178 + //外链获取机会的图片、视频、音频数据
  179 + beego.Router("/common/chance/media", &controllers.AuditController{}, "post:GetChangeMedia")
179 } 180 }