浏览代码

微路演列表

xingzai 2 年之前
父节点
当前提交
51acbacdda

+ 52 - 0
controllers/activity.go

@@ -0,0 +1,52 @@
+package controllers
+
+import "hongze/hongze_clpt/models"
+
+type ActivityController struct {
+	BaseAuthController
+}
+
+// @Title 活动类型下的主题列表(5.3版本)
+// @Description 获取活动类型下的主题列表接口(5.3版本)
+// @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   ActivityTypeIds   query   string  false     "活动类型id 多个用 , 隔开"
+// @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
+// @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2,多个用 , 隔开"
+// @Param   WhichTime   query   string  false       " 本周:1 上周:2,本月:3上月:4"
+// @Param   IsPower   query   int  false       "是否选择有权限行业 ,1是 0 否 默认0"
+// @Success 200 {object} models.ActivityTypeListHomeResp
+// @router /labelTypeList [get]
+func (this *ActivityController) LabelTypeList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	chartPermissionIds := this.GetString("ChartPermissionIds")
+	//isPower, _ := this.GetInt("IsPower")
+	//whichDay := this.GetString("WhichDay")
+	//activeState := this.GetString("ActiveState")
+
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
+	list, err := models.GetActivityTypeHomeList()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ActivityTypeListHomeResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 125 - 0
controllers/micro_roadshow.go

@@ -2,8 +2,10 @@ package controllers
 
 import (
 	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/services"
+	"hongze/hongze_clpt/utils"
 	"strconv"
 	"time"
 )
@@ -13,6 +15,129 @@ 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"
+// @Param   ActivityVideoId			query	int		false	"活动视频ID"
+// @Param   Filter			query	int		false	"筛选条件 0:全部 1:视频 2:音频"
+// @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")
+	activityVideoId, _ := this.GetInt("ActivityVideoId")
+	filter, _ := this.GetInt("Filter", 0)
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	// 微路演列表
+	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+
+	// 用户权限
+	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
+		return
+	}
+
+	// 获取默认图配置
+	audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+
+	for i := range list {
+		// 权限
+		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 list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
+				au.HasPermission = 2
+			}
+		}
+		// 无权限的弹框提示
+		if au.HasPermission != 1 {
+			if au.OperationMode == services.UserPermissionOperationModeCall {
+				if list[i].Type == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgCallActivity
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
+				}
+			} else {
+				if list[i].Type == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
+				}
+			}
+		}
+		list[i].AuthInfo = au
+		list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
+		// 默认图
+		if list[i].BackgroundImg == "" {
+			if list[i].Type == 1 {
+				list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
+			} else {
+				list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
+			}
+		}
+		// 分享图
+		if list[i].ShareImg == "" {
+			if list[i].Type == 1 {
+				list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
+			} else {
+				list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
+			}
+		}
+	}
+
+	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   VideoId   query   int  true       "视频ID"

+ 69 - 0
models/activity.go

@@ -0,0 +1,69 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+//活动详情
+type CygxActivity struct {
+	ActivityId              int       `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
+	ActivityTypeId          int       `description:"活动类型id"`
+	ActivityTypeName        string    `description:"活动类型名称"`
+	ChartPermissionId       int       `description:"行业id"`
+	ChartPermissionName     string    `description:"行业名称"`
+	ChartPermissionNames    string    `description:"行业名称辅助字段,区分研选子分类"`
+	Body                    string    `description:"内容"`
+	CreateTime              time.Time `description:"创建时间"`
+	PublishDate             time.Time `description:"发布时间"`
+	IsLimitPeople           int       `description:"是否限制人数 1是,0否"`
+	LimitPeopleNum          int       `description:"限制的人数数量"`
+	CustomerTypeIds         string    `description:"活动可见的客户类型,多个ID用 , 隔开"`
+	PublishStatus           int       `description:"发布状态 1已发布,0未发布"`
+	LastUpdatedTime         time.Time `description:"更新时间"`
+	ActivityTime            string    `description:"活动时间"`
+	ActivityTimeText        string    `description:"活动时间带文字"`
+	DistinguishedGuest      string    `description:"嘉宾"`
+	Host                    string    `description:"主持人"`
+	MainlandTell            string    `description:"大陆拨入号"`
+	HongKongTell            string    `description:"香港拨入号"`
+	TaiwanTell              string    `description:"台湾拨入号"`
+	AmericaTell             string    `description:"美国拨入号"`
+	ParticipationCode       string    `description:"参会密码"`
+	Theme                   string    `description:"主题"`
+	Expert                  string    `description:"专家"`
+	ActivityName            string    `description:"活动名称"`
+	ActivityNameTask        string    `description:"活动名称定时任务同步的时候使用"`
+	OnlineParticipation     string    `description:"网络参会"`
+	ReportLink              string    `description:"报告链接"`
+	City                    string    `description:"城市"`
+	Address                 string    `description:"活动地址"`
+	Highlights              string    `description:"活动亮点"`
+	Remarks                 string    `description:"备注"`
+	Speaker                 string    `description:"主讲人"`
+	ArticleId               int       `description:"关联报告id"`
+	Label                   string    `description:"标签"`
+	LinkParticipants        string    `description:"链接参会"`
+	AppAttendance           string    `description:"App参会"`
+	ConferencePassword      string    `description:"会议密码"`
+	TemporaryLabel          string    `description:"临时标签"`
+	IsMakerShow             int       `description:"是否仅决策人可见 0,否 、1,是"`
+	VisibleRange            int       `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
+	Scale                   string    `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
+	IsShowSubjectName       int       `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
+	IsHideAppointment       int       `description:"是否隐藏预约纪要按钮 1是 ,0 否 默认0 "`
+	AdminId                 int       `description:"销售/管理员ID"`
+	AdminName               string    `description:"销售/管理员姓名"`
+	IsCanAppointmentMinutes int       `description:"是否可预约纪要 1是 ,0 否 默认0 "`
+}
+
+//列表
+func GetCygxActivityList(condition string, pars []interface{}) (items []*CygxActivity, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity WHERE  1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 68 - 0
models/activity_type.go

@@ -0,0 +1,68 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type ActivityType struct {
+	ActivityTypeId   int    `description:"活动类型id"`
+	ActivityTypeName string `description:"活动名称"`
+	ShowType         string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
+	IsChoose         bool   `description:"是否选择"`
+	OnlineIco        string `description:"线上线下Ico图标"`
+}
+
+type ActivityTypeListResp struct {
+	List []*ActivityType
+}
+
+//列表
+func GetActivityTypeList() (items []*ActivityType, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_type ORDER BY sort DESC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func GetActivityTypeDetailById(activityTypeId int) (item *ActivityType, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_type WHERE activity_type_id = ? `
+	err = o.Raw(sql, activityTypeId).QueryRow(&item)
+	return
+}
+
+type ActivityTypeListHomeResp struct {
+	List []*ActivityTypeHome
+}
+
+type ActivityTypeHome struct {
+	ActivityTypeId   int    `description:"活动类型id"`
+	Resource         int    `description:"位置 ,1:活动 ,2:专项产业调研"`
+	ActivityTypeName string `description:"活动名称"`
+	OnlineIco        string `description:"线上线下Ico图标"`
+	ImgUrlBgPc       string `description:"Pc端背景图片"`
+	List             []*CygxActivityLabelList
+}
+
+//活动详情
+type CygxActivityLabelList struct {
+	KeyWord           string `orm:"column(label)";description:"主题"`
+	Timesort          string `description:"最大时间"`
+	Mintimesort       string `description:"最小时间"`
+	ImgUrlBg          string `description:"背景图片"`
+	ActivityId        int    `description:"活动ID "`
+	IsShowSubjectName int    `description:"小程序内是否展示标的名称 1是 ,0否 默认0 "`
+	Resource          int    `description:"位置 ,1:活动 ,2:专项产业调研"`
+	TemporaryLabel    string `description:"临时标签"`
+	IsNew             bool   `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
+	YidongActivityId  int    `description:"易董活动ID"`
+	IsExternalLabel   bool   `description:"是否为外部资源"`
+}
+
+//列表
+func GetActivityTypeHomeList() (items []*ActivityTypeHome, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_type WHERE activity_type_id != 7   ORDER BY sort DESC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 89 - 0
models/micro_roadshow.go

@@ -183,3 +183,92 @@ func GetMicroRoadshowVideoList() (list []*MicroRoadshowVideo, err error) {
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&list)
 	return
 }
+
+// GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
+func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId, filter int) (total int, list []*MicroRoadShowPageList, err error) {
+	o := orm.NewOrm()
+	var sql string
+	if audioId+activityVideoId == 0 && filter != 2 {
+		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,
+			video_duration AS play_seconds,
+			img_url AS background_img,            
+			industry_name,
+			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 && filter != 2 {
+		sql += `  UNION ALL `
+	}
+
+	if audioId+videoId == 0 && filter != 2 {
+		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 industry_name,
+			"" AS share_img,
+			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 && filter == 0 {
+		sql += `  UNION ALL `
+	}
+
+	if videoId+activityVideoId == 0 && filter != 1 {
+		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 industry_name,
+			"" AS share_img,
+			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
+}

+ 18 - 0
routers/commentsRouter.go

@@ -7,6 +7,15 @@ import (
 
 func init() {
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "LabelTypeList",
+            Router: `/labelTypeList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ArticleController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ArticleController"],
         beego.ControllerComments{
             Method: "AskAdd",
@@ -97,6 +106,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: "List",
+            Router: `/list`,
+            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",

+ 5 - 0
routers/router.go

@@ -85,6 +85,11 @@ func init() {
 				&controllers.MicroRoadShowController{},
 			),
 		),
+		web.NSNamespace("/activity",
+			web.NSInclude(
+				&controllers.ActivityController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 6 - 0
services/activity.go

@@ -0,0 +1,6 @@
+package services
+
+func GetActivityList() {
+
+	return
+}

+ 81 - 0
services/micro_roadshow.go

@@ -3,6 +3,7 @@ package services
 import (
 	"encoding/json"
 	"errors"
+	"fmt"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
 )
@@ -185,3 +186,83 @@ func GetMicroRoadshowVideoMap() (items map[int]int, err error) {
 	items = mapindustrialId
 	return
 }
+
+// GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
+func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter int, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+	var e error
+	// 根据每页数据量获取音视频配比
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	videoList := make([]*models.MicroRoadShowPageList, 0)
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+	}
+
+	//音频的查询
+	var audioCond string
+	var audioPars []interface{}
+	// 如果筛选条件为指定视频ID或只看视频则不做音频查询
+
+	if videoId > 0 || activityVideoId > 0 || filter == 1 {
+		audioCond = ""
+	} else {
+		// 活动已发布且已结束
+		audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
+		//活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间
+		//endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
+		//audioCond += ` AND b.activity_time > ? `
+		//audioPars = append(audioPars, endTime)
+		if keywords != "" {
+			audioCond += ` AND a.voice_name LIKE ? OR b.label LIKE ?`
+			audioPars = append(audioPars, keywords, keywords)
+		}
+		if audioId > 0 {
+			audioCond += ` AND a.activity_voice_id = ?`
+			audioPars = append(audioPars, audioId)
+		}
+	}
+	//视频的处理
+	var videoCond string
+	var videoCondAct string
+	var videoPars []interface{}
+	var videoParsAct []interface{}
+	if audioId > 0 || filter == 2 {
+		fmt.Println("22222")
+		videoCond = ""
+	} else {
+		if keywords != "" {
+			videoCond += ` AND video_name LIKE ?`
+			videoPars = append(videoPars, keywords)
+			videoCondAct += ` AND video_name LIKE ?`
+			videoParsAct = append(videoParsAct, keywords)
+		}
+		if videoId > 0 {
+			videoCond += ` AND video_id = ?`
+			videoPars = append(videoPars, videoId)
+		}
+		if activityVideoId > 0 {
+			videoCondAct += ` AND video_id = ?`
+			videoParsAct = append(videoParsAct, activityVideoId)
+		}
+
+		//如果传了路演的或者活动的视频ID只查询一个
+		if videoId > 0 {
+			videoCondAct += ` AND video_id = 0 `
+		}
+		if activityVideoId > 0 {
+			videoCond += ` AND video_id = 0 `
+		}
+		//if videoId == 0 {
+		//	endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
+		//	videoCondAct += ` AND art.activity_time > ? `
+		//	videoParsAct = append(videoParsAct, endTime)
+		//}
+		videoCond += ` AND publish_status = 1`
+	}
+	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId, filter)
+	if e != nil {
+		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
+		return
+	}
+	respList = videoList
+	return
+}