Quellcode durchsuchen

2.2版本完成联调

xingzai vor 2 Jahren
Ursprung
Commit
663a449593

+ 143 - 0
controllers/micro_roadshow.go

@@ -0,0 +1,143 @@
+package controllers
+
+import (
+	"encoding/json"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/services"
+	"strconv"
+	"time"
+)
+
+// 微路演
+type MicroRoadShowController struct {
+	BaseAuthController
+}
+
+// @Title 视频详情
+// @Description 时间线接口
+// @Param   VideoId   query   int  true       "视频ID"
+// @Success 200 {object} models.IndustryVideoDetailResp
+// @router /detail [get]
+func (this *MicroRoadShowController) Detail() {
+	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.GetindustryVideoDetailById(user, videoId)
+	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
+}
+
+// @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
+	}
+	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
+	//	}
+	//	err = models.UpdateCygxActivityVideoCounts(videoId)
+	//	if err != nil {
+	//		br.Msg = "更新失败"
+	//		br.ErrMsg = "更新失败,Err:" + err.Error()
+	//		return
+	//	}
+	//}
+
+	err = models.AddCygxMicroRoadshowVideoHistory(&item)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+	err = models.UpdateCygxActivityVideoCounts(videoId)
+	if err != nil {
+		br.Msg = "更新失败"
+		br.ErrMsg = "更新失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	return
+}

+ 1 - 1
controllers/report.go

@@ -1198,7 +1198,7 @@ func (this *MobileReportController) SearchReportAndResource() {
 // @Title 公司速览
 // @Description 公司速览接口
 // @Param   ChartPermissionId   query   int  false       "分类ID"
-// @Success 200 {object} models.TradeReportMappingResp
+// @Success 200 {object} models.ArticleDataLogoListResp
 // @router /companyList [get]
 func (this *ReportCommonController) CompanyList() {
 	br := new(models.BaseResponse).Init()

+ 3 - 3
controllers/report_billboard.go

@@ -7,7 +7,7 @@ import (
 	"time"
 )
 
-//报告
+//报告榜单
 type ReportBillboardController struct {
 	BaseAuthController
 }
@@ -24,7 +24,7 @@ type MobileReportBillboardController struct {
 // @Description 获取阅读飙升榜/报告收藏榜接口
 // @Param   ChartPermissionId   query   int  false       "分类ID"
 // @Param   Source   query   int  true       "来源 1:阅读飙升 ,2:报告收藏"
-// @Success 200 {object} models.ArticleReportBillboardLIstResp
+// @Success 200 {object} models.ReportBillboardListResp
 // @router /list [get]
 func (this *MobileReportBillboardController) ReadList() {
 	br := new(models.BaseResponse).Init()
@@ -124,7 +124,7 @@ func (this *MobileReportBillboardController) ReadList() {
 		}
 	}
 	var err error
-	resp := new(models.HomeArticleListResp)
+	resp := new(models.ReportBillboardListResp)
 	resp.List, err = services.HandleArticleCategoryImg(list)
 	if err != nil {
 		br.Msg = "获取失败"

+ 1 - 1
models/article_data.go

@@ -13,7 +13,7 @@ type CygxArticleDataResp struct {
 type ArticleDataLogoResp struct {
 	ArticleId   int                `description:"文章id"`
 	Cover       string             `description:"封面图片,公司logo"`
-	ComapnyList []*ComapnyNameResp `description:"公司称"`
+	ComapnyList []*ComapnyNameResp `description:"公司称"`
 }
 
 type ArticleDataLogoListResp struct {

+ 1 - 0
models/db.go

@@ -41,6 +41,7 @@ func init() {
 		new(Resource),
 		new(CygxXzsChooseCategory),
 		new(CygxReportIndustrialSeaarchHistory),
+		new(CygxMicroRoadshowVideoHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 4 - 0
models/home.go

@@ -16,6 +16,10 @@ type HomeArticleListResp struct {
 	List   []*ArticleListResp `description:"文章列表"`
 }
 
+type ReportBillboardListResp struct {
+	List []*ArticleListResp `description:"文章列表"`
+}
+
 type HomeArticle struct {
 	ArticleId        int                  `description:"文章id"`
 	Title            string               `description:"标题"`

+ 5 - 0
models/industrial_management.go

@@ -78,6 +78,11 @@ type IndustryArtCount struct {
 	IndustrialManagementId int `json:"industrial_management_id" description:"产业ID"`
 }
 
+type IndustryVideoDetailResp struct {
+	IndustryVideo *MicroVideoSimpleInfo
+	AuthInfo      *UserPermissionAuthInfo
+}
+
 //产业列表
 func GetIndustrialManagementAllCount(condition string) (count int, err error) {
 	o := orm.NewOrm()

+ 12 - 149
models/micro_roadshow.go

@@ -30,99 +30,9 @@ type MicroRoadShowPageList struct {
 	AuthInfo            *UserPermissionAuthInfo
 }
 
-// GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
-func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId int) (total int, list []*MicroRoadShowPageList, err error) {
-	o := orm.NewOrm()
-	var sql string
-	if audioId+activityVideoId == 0 {
-		sql += `SELECT
-			video_id AS id,
-			video_name AS title,
-			video_url AS resource_url,
-			3 AS type,
-			publish_date AS publish_time,
-			chart_permission_id,
-			chart_permission_name,
-            industry_name,
-			video_duration AS play_seconds,
-			img_url AS background_img,
-			share_img_url AS share_img,
-			"" as  activity_id
-		FROM
-			cygx_micro_roadshow_video 
-		WHERE
-			publish_status = 1 `
-		if condition != `` {
-			sql += condition
-		}
-	}
-	if audioId+videoId+activityVideoId == 0 {
-		sql += `  UNION ALL `
-	}
-
-	if audioId+videoId == 0 {
-		sql += `
-		SELECT
-			video_id AS id,
-			video_name AS title,
-			video_url AS resource_url,
-			2 AS type,
-		art.activity_time as publish_time,
-			art.chart_permission_id,
-			art.chart_permission_name,
-			"" AS play_seconds,
-			"" AS background_img,
-			"" AS share_img,
-			"" AS industry_name,
-			v.activity_id
-		FROM
-			cygx_activity_video as v
-			INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1  `
-		if conditionAct != `` {
-			sql += conditionAct
-		}
-	}
-	if audioId+videoId+activityVideoId == 0 {
-		sql += `  UNION ALL `
-	}
-
-	if videoId+activityVideoId == 0 {
-		sql += `
-			SELECT
-			a.activity_voice_id AS id,
-			a.voice_name AS title,
-			a.voice_url AS resource_url,
-			1 AS type,
-			b.activity_time AS publish_time,
-			b.chart_permission_id,
-			b.chart_permission_name,
-			a.voice_play_seconds AS play_seconds,
-			a.img_url AS background_img,
-			"" AS share_img,
-            "" AS industry_name,
-			a.activity_id 
-		FROM
-			cygx_activity_voice AS a
-			JOIN cygx_activity AS b ON a.activity_id = b.activity_id  WHERE 1= 1  `
-		if conditionAudio != `` {
-			sql += conditionAudio
-		}
-	}
-	sql += ` ORDER BY publish_time DESC`
-	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
-	err = o.Raw(totalSql, pars, parsAct, parsAudio).QueryRow(&total)
-	if err != nil {
-		return
-	}
-	sql += ` LIMIT ?,?`
-	_, err = o.Raw(sql, pars, parsAct, parsAudio, startSize, pageSize).QueryRows(&list)
-	return
-}
-
 type AddVideoHistoryReq struct {
 	VideoId     int `description:"视频ID"`
 	PlaySeconds int `description:"播放时长"`
-	SourceType  int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
 }
 
 type CygxMicroRoadshowVideoHistory struct {
@@ -195,62 +105,6 @@ type HomeNewestUnionList struct {
 	MicroAudioUnionList
 }
 
-// GetHomeNewestListUnionList 首页最新纪要-音频联合查询
-func GetHomeNewestListUnionList(condition string, pars []interface{}, startSize, pageSize int) (list []*HomeNewestUnionList, err error) {
-	sql := `SELECT
-				id, article_id, title, title_en, update_frequency, create_date, publish_date, body, abstract, category_name, sub_category_name, expert_background, category_id, source, annotation,
-				(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
-				0 AS home_type, "" AS audio_title, "" AS audio_resource_url, 0 AS audio_type, "" AS audio_publish_time, 0 AS audio_chart_permission_id, "" AS audio_chart_permission_name,
-				"" AS audio_play_seconds, "" AS audio_img_url, 0 AS audio_activity_id
-			FROM
-				cygx_article AS art
-			WHERE
-				art.publish_status = 1 `
-	if condition != `` {
-		sql += condition
-	}
-	sql += ` UNION ALL
-			
-			SELECT
-				a.activity_voice_id, 0, "", "", "", "", b.activity_time, "", "", "", "", "", 0, 0, "",
-				0, 1, a.voice_name, a.voice_url, 1, b.activity_time,
-				b.chart_permission_id, b.chart_permission_name, a.voice_play_seconds AS audio_play_seconds, a.img_url AS audio_img_url, a.activity_id AS audio_activity_id
-			FROM
-				cygx_activity_voice AS a
-			JOIN cygx_activity AS b ON a.activity_id = b.activity_id`
-	sql += ` ORDER BY publish_date DESC`
-	sql += ` LIMIT ?,?`
-	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
-	return
-}
-
-// GetHomeNewestListUnionCount 首页最新纪要-音频联合查询总数
-func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-				COUNT(1) AS count
-			FROM
-				(
-					SELECT
-						art.id
-					FROM
-						cygx_article AS art
-					WHERE
-						art.publish_status = 1 `
-	if condition != `` {
-		sql += condition
-	}
-	sql += ` UNION ALL
-				SELECT
-					a.activity_voice_id
-				FROM
-					cygx_activity_voice AS a
-				JOIN cygx_activity AS b ON a.activity_id = b.activity_id
-			) z `
-	err = o.Raw(sql, pars).QueryRow(&count)
-	return
-}
-
 func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
 	o := orm.NewOrm()
 	sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
@@ -284,16 +138,16 @@ func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error
 	return
 }
 
-func UpdateCygxActivityVideoCounts(activityId int) (err error) {
+func UpdateCygxActivityVideoCounts(videoId int) (err error) {
 	sql := `UPDATE cygx_micro_roadshow_video SET video_counts = video_counts+1 WHERE video_id = ?  `
 	o := orm.NewOrm()
-	_, err = o.Raw(sql, activityId).Exec()
+	_, err = o.Raw(sql, videoId).Exec()
 	return
 }
 
 // GetMicroRoadshowVideoByIndustryIds 根据行业ID查询产业视频列表
 func GetMicroRoadshowVideoByIndustryIds(industrialIdArr []int) (list []*MicroRoadshowVideo, err error) {
-	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id in (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)  and publish_status = 1 `
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id in (` + utils.GetOrmInReplace(len(industrialIdArr)) + `) `
 	_, err = orm.NewOrm().Raw(sql, industrialIdArr).QueryRows(&list)
 	return
 }
@@ -313,3 +167,12 @@ func GetMicroRoadshowVideoByIndustryIdCount(industryId int) (count int, err erro
 	err = o.Raw(sql, industryId).QueryRow(&count)
 	return
 }
+
+//GetMicroRoadshowVideoByVidoeIdCount  根据行业ID查询产业视频是否存在
+func GetMicroRoadshowVideoByVidoeIdCount(industryId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) count
+			FROM cygx_micro_roadshow_video WHERE video_id = ? `
+	err = o.Raw(sql, industryId).QueryRow(&count)
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -79,6 +79,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/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: "VideoHistoryAdd",
+            Router: `/videoHistory/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileHomeController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileHomeController"],
         beego.ControllerComments{
             Method: "List",

+ 5 - 0
routers/router.go

@@ -80,6 +80,11 @@ func init() {
 				&controllers.MobileReportBillboardController{},
 			),
 		),
+		web.NSNamespace("/micro_roadshow",
+			web.NSInclude(
+				&controllers.MicroRoadShowController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 66 - 0
services/micro_roadshow.go

@@ -104,3 +104,69 @@ func GetindustryVideo(user *models.WxUserItem, industrialManagementId int) (indu
 	AuthInfo = au
 	return
 }
+
+//GetindustryVideoDetailById 通过视频ID获取视频详情
+func GetindustryVideoDetailById(user *models.WxUserItem, videoId int) (industryVideo *models.MicroVideoSimpleInfo, AuthInfo *models.UserPermissionAuthInfo, err error) {
+	total, e := models.GetMicroRoadshowVideoByVidoeIdCount(videoId)
+	if e != nil {
+		err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryIdCount " + 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.GetMicroRoadshowVideoById(videoId)
+	if e != nil {
+		err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
+		return
+	} else {
+		videoSimple.Id = video.VideoId
+		videoSimple.Title = "5min逻辑【" + video.IndustryName + "】解析"
+		videoSimple.BackgroundImg = video.ImgUrl
+		videoSimple.DetailImgUrl = video.DetailImgUrl
+		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 = ""
+		}
+	}
+	industryVideo = videoSimple
+	AuthInfo = au
+	return
+}