123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- package controllers
- import (
- "encoding/json"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- "hongze/hongze_cygx/utils"
- "strconv"
- "time"
- )
- // 微路演
- type MicroRoadShowController struct {
- BaseAuthController
- }
- // @Title 微路演列表
- // @Description 微路演列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param KeyWord query string false "搜索关键词"
- // @Param AudioId query int false "音频ID"
- // @Param VideoId query int false "视频ID"
- // @Success 200 {object} models.HomeListResp
- // @router /list [get]
- func (this *MicroRoadShowController) List() {
- 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
- }
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- keywords := this.GetString("KeyWord")
- audioId, _ := this.GetInt("AudioId")
- videoId, _ := this.GetInt("VideoId")
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- list, total, e := services.GetMicroRoadShowPageList(pageSize, currentIndex, audioId, videoId, keywords)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
- return
- }
- resp := new(models.MicroRoadShowListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 记录用户浏览音频回放接口
- // @Description 记录用户浏览音频回放接口
- // @Param request body models.ActivityIdRep true "type json string"
- // @Success Ret=200 {object} models.AppointmentResp
- // @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
- }
- uid := user.UserId
- var req models.AddVideoHistoryReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- videoId := req.VideoId
- playSeconds := req.PlaySeconds
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item := models.CygxMicroRoadshowVideoHistory{
- VideoId: videoId,
- UserId: uid,
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- RealName: user.RealName,
- SellerName: sellerName,
- PlaySeconds: strconv.Itoa(playSeconds),
- CreateTime: time.Now(),
- ModifyTime: time.Now(),
- }
- if playSeconds != 0 {
- lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
- return
- }
- err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
- return
- }
- } else {
- err = models.AddCygxMicroRoadshowVideoHistory(&item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
|