Browse Source

no message

xingzai 2 years ago
parent
commit
b2367f25aa
5 changed files with 154 additions and 10 deletions
  1. 33 0
      controllers/activity.go
  2. 40 3
      models/activity_video.go
  3. 9 0
      routers/commentsRouter.go
  4. 70 5
      services/activity.go
  5. 2 2
      services/activity_special.go

+ 33 - 0
controllers/activity.go

@@ -1490,3 +1490,36 @@ func (this *ActivityController) AskAdd() {
 	br.Data = resp
 	br.Data = resp
 	br.Msg = "提交成功"
 	br.Msg = "提交成功"
 }
 }
+
+// @Title 视频详情
+// @Description 时间线接口
+// @Param   VideoId   query   int  true       "视频ID"
+// @Success 200 {object} models.IndustryVideoDetailResp
+// @router /detailVideo [get]
+func (this *ActivityController) DetailVideo() {
+	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
+	}
+	videoId, _ := this.GetInt("VideoId")
+	videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
+		return
+	}
+	resp := new(models.ActivityVideoDetailResp)
+	resp.VideoDetail = videoSimple
+	resp.AuthInfo = au
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 40 - 3
models/activity_video.go

@@ -90,9 +90,46 @@ func GetCygxActivityVideoByActivityId(activityId int) (item *CygxActivityVideo,
 	return
 	return
 }
 }
 
 
+type CygxActivityVideoDetailResp struct {
+	ActivityId          int    ` description:"活动ID"`
+	Id                  int    `description:"视频ID"`
+	Title               string `description:"标题"`
+	ResourceUrl         string `description:"链接"`
+	BackgroundImg       string `description:"背景图"`
+	PlaySeconds         int    `description:"音视频时长"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+}
+
 // GetCygxActivityVideoById 获取活动视频
 // GetCygxActivityVideoById 获取活动视频
-func GetCygxActivityVideoById(activityId int) (item *CygxActivityVideo, err error) {
-	sql := `SELECT * FROM cygx_activity_video WHERE video_id = ? LIMIT 1 `
-	err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
+func GetCygxActivityVideoById(videoId int) (item *CygxActivityVideoDetailResp, err error) {
+	sql := `SELECT
+			v.video_id AS id,
+			v.video_name AS title,
+			v.video_url AS resource_url,
+			v.video_duration AS play_seconds,
+			v.activity_id,
+			a.chart_permission_id 
+		FROM
+			cygx_activity_video AS v
+			INNER JOIN cygx_activity AS a 
+		WHERE
+			video_id = ? 
+			LIMIT 1 `
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
+	return
+}
+
+//GetMicroRoadshowVideoByVideoIdCount  根据视频ID查询产业视频是否存在
+func GetActivityVideoByVideoIdCount(videoId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) count
+			FROM cygx_activity_video WHERE video_id = ? `
+	err = o.Raw(sql, videoId).QueryRow(&count)
 	return
 	return
 }
 }
+
+type ActivityVideoDetailResp struct {
+	VideoDetail *CygxActivityVideoDetailResp
+	AuthInfo    *UserPermissionAuthInfo
+}

+ 9 - 0
routers/commentsRouter.go

@@ -43,6 +43,15 @@ func init() {
             Filters: nil,
             Filters: nil,
             Params: nil})
             Params: nil})
 
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "DetailVideo",
+            Router: `/detailVideo`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
         beego.ControllerComments{
         beego.ControllerComments{
             Method: "LabelTypeList",
             Method: "LabelTypeList",

+ 70 - 5
services/activity.go

@@ -108,11 +108,10 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 		} else if whichDay == "2" {
 		} else if whichDay == "2" {
 			startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
 			startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
 			endDate = startDate
 			endDate = startDate
-		} else {
+		} else if whichDay == "1,2" {
 			startDate = time.Now().Format(utils.FormatDate)
 			startDate = time.Now().Format(utils.FormatDate)
 			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
 			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
-		}
-		if whichDay == "3" {
+		} else if whichDay == "3" {
 			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
 			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
 			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
 			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
 		} else if whichDay == "4" {
 		} else if whichDay == "4" {
@@ -136,8 +135,7 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
 		}
 		}
 		condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
 		condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
 		condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
 		condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
-		condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
-		condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+
 	}
 	}
 
 
 	//有搜索条件传过来时,不判进行状态条件
 	//有搜索条件传过来时,不判进行状态条件
@@ -743,3 +741,70 @@ func IsShowAppointment(activityTypeId int, chartPermissionName string) (isShowAp
 	}
 	}
 	return
 	return
 }
 }
+
+//GetindustryVideoDetailById 通过视频ID获取视频详情
+func GetActivityVideoDetailById(user *models.WxUserItem, videoId int) (industryVideo *models.CygxActivityVideoDetailResp, AuthInfo *models.UserPermissionAuthInfo, err error) {
+	total, e := models.GetActivityVideoByVideoIdCount(videoId)
+	if e != nil {
+		err = errors.New("获取活动的视频失败,GetActivityVideoByVideoIdCount " + 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.CygxActivityVideoDetailResp)
+	// 权限
+	var au *models.UserPermissionAuthInfo
+	videoSimple, e = models.GetCygxActivityVideoById(videoId)
+	if e != nil {
+		err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
+		return
+	} else {
+		//videoSimple.Id = video.Id
+		//videoSimple.Title = video.Title
+		//videoSimple.ResourceUrl = video.ResourceUrl
+		//videoSimple.PlaySeconds = video.PlaySeconds
+		//videoSimple.ActivityId = video.ActivityId
+		//videoSimple.ChartPermissionId = video.ChartPermissionId
+
+		if videoSimple.BackgroundImg == "" {
+			// 获取默认图配置
+			_, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig()
+			if e != nil {
+				err = errors.New("获取视频默认配置图失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
+				return
+			}
+			videoSimple.BackgroundImg = videoMap[videoSimple.ChartPermissionId]
+		}
+		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 videoSimple.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, videoSimple.ChartPermissionName) {
+				au.HasPermission = 2
+			}
+		}
+		// 无权限的弹框提示
+		if au.HasPermission != 1 {
+			if au.OperationMode == UserPermissionOperationModeCall {
+				au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+			} else {
+				au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+			}
+			videoSimple.ResourceUrl = ""
+		}
+	}
+	industryVideo = videoSimple
+	AuthInfo = au
+	return
+}

+ 2 - 2
services/activity_special.go

@@ -118,8 +118,8 @@ func GetActivityLabelSpecialList(user *models.WxUserItem, chartPermissionIds str
 		return
 		return
 	}
 	}
 	if len(specialList) < 8 {
 	if len(specialList) < 8 {
-		conditionTrip += ` AND art.days = 0  ORDER BY art.last_updated_time DESC`
-		specialListNotrip, e := models.GetActivityLabelSpecialListAll(condition, pars, 0, 8-len(specialList))
+		condition += ` AND art.days = 0  ORDER BY art.last_updated_time DESC`
+		specialListNotrip, e := models.GetActivityLabelSpecialListAll(condition, pars, 0, 20)
 		if e != nil {
 		if e != nil {
 			err = e
 			err = e
 			return
 			return