package controllers import ( "encoding/json" "hongze/hongze_mfyx/models" "hongze/hongze_mfyx/services" ) // 微路演 (查看留言详情,之前老的项目写到这个模块下了) type MicroRoadShowController struct { BaseAuthController } // @Title 模版消息留言详情 // @Description 模版消息留言详情接口 // @Param SourceId query int true "资源ID" // @Param SourceType query int true "留言类型,1:文章、2:活动、3:微路演视频、4:活动视频、5:活动音频" // @Success Ret=200 {object} models.CygxArticleCommentWxResp // @router /comment/detail [get] func (this *MicroRoadShowController) CommentDetail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } sourceId, _ := this.GetInt("SourceId") sourceType, _ := this.GetInt("SourceType") resp := new(models.CygxArticleCommentWxResp) if sourceType == 1 || sourceType == 3 || sourceType == 4 || sourceType == 5 { detail, err := models.GetArticleCommentById(sourceId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取用户权限失败, Err: " + err.Error() return } resp.Content = detail.Content if sourceType == 1 { resp.SourceId = detail.ArticleId resp.RedirectType = 1 } else if sourceType == 3 { resp.SourceId = detail.IndustryId resp.RedirectType = 3 } else { resp.SourceId = detail.ActivityId resp.RedirectType = 2 } } else { detail, err := models.GetCygxActivityHelpAskById(sourceId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取用户权限失败, Err: " + err.Error() return } resp.Content = detail.Content resp.SourceId = detail.ActivityId resp.RedirectType = 2 } br.Ret = 200 br.Success = true br.Data = resp br.Msg = "操作成功" return } // @Title 记录用户浏览音频回放接口 // @Description 记录用户浏览音频回放接口 // @Param request body models.ActivityIdRep true "type json string" // @Success Ret=200 {object} models.AddVideoHistoryReq // @router /videoHistory/add [post] func (this *MicroRoadShowController) VideoHistoryAdd() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req models.AddVideoHistoryReq err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } sourceId := req.SourceId playSeconds := req.PlaySeconds sourceType := req.SourceType inviteShareCode := req.InviteShareCode if sourceType == 0 { sourceType = 1 } if sourceType == 1 { //添加活动音频的播放记录 go services.AddActivityVoiceHistory(user, sourceId, playSeconds, inviteShareCode) } else if sourceType == 2 { //添加活动视频的播放记录 go services.AddActivityVideoHistory(user, sourceId, playSeconds, inviteShareCode) } else if sourceType == 3 { //添加产业视频播放记录 go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds) } else if sourceType == 4 { //问答系列音频播放记录 //go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds) } go services.AddAllCygxVoiceAndVideoHistory(user, sourceId, sourceType, playSeconds) br.Ret = 200 br.Success = true br.Msg = "操作成功" return }