Browse Source

Merge branch 'cygx_12.4' of http://8.136.199.33:3000/cxzhang/hongze_clpt into debug

xingzai 1 year ago
parent
commit
862adf9741

+ 33 - 0
controllers/micro_roadshow.go

@@ -707,3 +707,36 @@ func (this *MicroRoadShowController) Collect() {
 		br.Data = resp
 	}
 }
+
+// @Title 问答系列视频详情
+// @Description 问答系列视频详情接口
+// @Param   VideoId   query   int  true       "视频ID"
+// @Success 200 {object} models.IndustryVideoDetailResp
+// @router /askserie_video/detail [get]
+func (this *MicroRoadShowController) AskserieVideoDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	askserieVideoId, _ := this.GetInt("VideoId")
+	videoSimple, au, err := services.GetAskserieVideoDetailById(user, askserieVideoId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
+		return
+	}
+	resp := new(models.IndustryVideoDetailResp)
+	resp.IndustryVideo = videoSimple
+	resp.AuthInfo = au
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 0
models/activity_video.go

@@ -41,6 +41,7 @@ type CygxActivityVideoListResp struct {
 	Title         string `orm:"column(video_name)";description:"视频名称"`
 	ResourceUrl   string `orm:"column(video_url)";description:"视频地址"`
 	VideoDuration string `description:"视频时长"`
+	Type          int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
 }
 
 type CygxActivityVideoListRep struct {

+ 1 - 0
models/activity_voice.go

@@ -38,6 +38,7 @@ type CygxActivityVoiceReq struct {
 	Url         string `description:"音频资源url地址"`
 	Name        string `description:"音频名称"`
 	PlaySeconds int    `description:"音频时长"`
+	Type        int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
 }
 
 // GetCygxActivityVoiceReqList 获取活动ID的音频

+ 43 - 0
models/askserie_video.go

@@ -0,0 +1,43 @@
+package models
+
+import "github.com/beego/beego/v2/client/orm"
+
+type CygxAskserieVideoResp struct {
+	AskserieVideoId     int    `orm:"column(askserie_video_id);pk"description:"视频id"`
+	VideoName           string `description:"视频标题"`
+	VideoUrl            string `description:"视频地址"`
+	VideoDuration       int    `description:"视频时长"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	PublishStatus       int    `description:"发布状态 1发布 0没有"`
+	VideoCounts         int    `description:"播放量"`
+	CommentNum          int    `description:"留言总数"`
+	BackgroundImg       string `description:"封面图片"`
+	ShareImg            string `description:"分享图片"`
+	AdminId             int    `description:"管理员、销售ID"`
+	IndustryName        string `description:"产业名称"`
+	ModifyDate          string `description:"更新时间"`
+	PublishDate         string `description:"发布时间"`
+	CreateTime          string `description:"创建时间"`
+}
+
+// GetCygxAskserieVideoCountByVideoId  根据视频ID查询产业视频是否存在
+func GetCygxAskserieVideoCountByVideoId(askserieVideoId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) count
+			FROM cygx_askserie_video WHERE askserie_video_id = ?`
+	err = o.Raw(sql, askserieVideoId).QueryRow(&count)
+	return
+}
+
+type GetCygxAskserieVideoDetailResp struct {
+	Detail *CygxAskserieVideoResp
+}
+
+// 通过ID获取详情
+func GetCygxAskserieVideoDetail(askserieVideoId int) (item *CygxAskserieVideoResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_askserie_video  WHERE askserie_video_id=? `
+	err = o.Raw(sql, askserieVideoId).QueryRow(&item)
+	return
+}

+ 1 - 1
models/micro_roadshow.go

@@ -39,7 +39,7 @@ type MicroRoadShowPageList struct {
 	SourceId               int       `description:"资源ID"`
 	Title                  string    `description:"标题"`
 	ResourceUrl            string    `description:"链接"`
-	Type                   int       `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
+	Type                   int       `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
 	PublishTime            string    `description:"发布时间"`
 	BackgroundImg          string    `description:"背景图"`
 	ShareImg               string    `description:"分享封面图"`

+ 1 - 0
models/report.go

@@ -36,6 +36,7 @@ type IndustrialManagement struct {
 
 type MicroVideoSimpleInfo struct {
 	Id                  int    `description:"视频ID"`
+	Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
 	Title               string `description:"标题"`
 	ResourceUrl         string `description:"链接"`
 	BackgroundImg       string `description:"背景图"`

+ 9 - 0
routers/commentsRouter.go

@@ -439,6 +439,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"],
+        beego.ControllerComments{
+            Method: "AskserieVideoDetail",
+            Router: `/askserie_video/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"],
         beego.ControllerComments{
             Method: "Collect",

+ 2 - 0
services/activity.go

@@ -571,6 +571,7 @@ func GetActivityVoiceResp(mapActivityId []int) (mapItem map[int]*models.CygxActi
 	mapActivityVoice := make(map[int]*models.CygxActivityVoiceReq)
 	if len(activityVoiceList) > 0 {
 		for _, v := range activityVoiceList {
+			v.Type = 1 //活动音频为1
 			mapActivityVoice[v.ActivityId] = v
 		}
 	}
@@ -603,6 +604,7 @@ func GetActivityVideoResp(mapActivityId []int) (mapItem map[int]*models.CygxActi
 	mapActivityVideo := make(map[int]*models.CygxActivityVideoListResp)
 	if len(videoList) > 0 {
 		for _, v := range videoList {
+			v.Type = 2 // 活动视频为 2
 			mapActivityVideo[v.ActivityId] = v
 		}
 	}

+ 68 - 0
services/micro_roadshow.go

@@ -169,6 +169,7 @@ func GetindustryVideoDetailById(user *models.WxUserItem, videoId int) (industryV
 			videoSimple.ResourceUrl = ""
 		}
 	}
+	videoSimple.Type = 3
 	industryVideo = videoSimple
 	AuthInfo = au
 	return
@@ -682,3 +683,70 @@ func MicroRoadshowVideoUserRmind(user *models.WxUserItem, videoId int) (err erro
 	}
 	return
 }
+
+// GetindustryVideoDetailById 通过视频ID获取视频详情
+func GetAskserieVideoDetailById(user *models.WxUserItem, askserieVideoId int) (industryVideo *models.MicroVideoSimpleInfo, AuthInfo *models.UserPermissionAuthInfo, err error) {
+	total, e := models.GetCygxAskserieVideoCountByVideoId(askserieVideoId)
+	if e != nil {
+		err = errors.New("获取产业关联的视频失败,GetCygxAskserieVideoCountByVideoId " + e.Error())
+		return
+	}
+	if total == 0 {
+		err = errors.New("视频不存在,或已取消发布")
+		return
+	}
+	// 用户权限
+	authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		err = errors.New("获取用户权限失败,GetUserRaiPermissionInfo " + e.Error())
+		return
+	}
+	videoSimple := new(models.MicroVideoSimpleInfo)
+	// 权限
+	var au *models.UserPermissionAuthInfo
+	video, e := models.GetCygxAskserieVideoDetail(askserieVideoId)
+	if e != nil {
+		err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
+		return
+	} else {
+		videoSimple.Id = video.AskserieVideoId
+		videoSimple.Title = video.VideoName
+		videoSimple.BackgroundImg = video.BackgroundImg
+		videoSimple.DetailImgUrl = video.ShareImg
+		if videoSimple.BackgroundImg == "" {
+			// 获取默认图配置
+			_, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig()
+			if e != nil {
+				err = errors.New("获取视频默认配置图失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
+				return
+			}
+			videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
+		}
+		videoSimple.PlaySeconds = video.VideoDuration
+		videoSimple.ResourceUrl = video.VideoUrl
+		au = new(models.UserPermissionAuthInfo)
+		au.SellerName = authInfo.SellerName
+		au.SellerMobile = authInfo.SellerMobile
+		au.HasPermission = authInfo.HasPermission
+		au.OperationMode = authInfo.OperationMode
+		if au.HasPermission == 1 {
+			// 非宏观权限进一步判断是否有权限
+			if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
+				au.HasPermission = 2
+			}
+		}
+		// 无权限的弹框提示
+		if au.HasPermission != 1 {
+			if au.OperationMode == UserPermissionOperationModeCall {
+				au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+			} else {
+				au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+			}
+			videoSimple.ResourceUrl = ""
+		}
+	}
+	videoSimple.Type = 4
+	industryVideo = videoSimple
+	AuthInfo = au
+	return
+}