Browse Source

收藏接口 留言接口修改

ziwen 2 years ago
parent
commit
33a1842f01

+ 5 - 1
controllers/micro_roadshow.go

@@ -22,6 +22,8 @@ type MicroRoadShowController struct {
 // @Param   KeyWord			query	string	false	"搜索关键词"
 // @Param   AudioId			query	int		false	"音频ID"
 // @Param   VideoId			query	int		false	"视频ID"
+// @Param   AudioIds			query	string		false	"音频IDs"
+// @Param   VideoIds			query	string		false	"视频IDs"
 // @Param   ActivityVideoId			query	int		false	"活动视频ID"
 // @Param   Filter			query	int		false	"筛选条件 0:全部 1:视频 2:音频"
 // @Success 200 {object} models.HomeListResp
@@ -44,6 +46,8 @@ func (this *MicroRoadShowController) List() {
 	keywords := this.GetString("KeyWord")
 	audioId, _ := this.GetInt("AudioId")
 	videoId, _ := this.GetInt("VideoId")
+	audioIds := this.GetString("AudioIds")
+	videoIds := this.GetString("VideoIds")
 	activityVideoId, _ := this.GetInt("ActivityVideoId")
 	filter, _ := this.GetInt("Filter", 0)
 
@@ -55,7 +59,7 @@ func (this *MicroRoadShowController) List() {
 	}
 
 	// 微路演列表
-	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords)
+	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords, audioIds, videoIds)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()

+ 64 - 1
controllers/user.go

@@ -1556,7 +1556,70 @@ func (this *UserController) CommnetList() {
 	}
 
 	resp := new(models.CygxCommentListResp)
-	resp.List = commentlist
+
+	for _, comment := range commentlist {
+		item := models.CygxArticleCommentResp{
+			Id:           comment.Id,
+			UserId:       comment.UserId,
+			ArticleId:    comment.ArticleId,
+			IndustryId:   comment.IndustryId,
+			ActivityId:      comment.ActivityId,
+			CreateTime:   comment.CreateTime,
+			Mobile:       comment.Mobile,
+			Email:        comment.Email,
+			CompanyId:    comment.CompanyId,
+			CompanyName:  comment.CompanyName,
+			Content:      comment.Content,
+			Title:        comment.Title,
+		}
+		if comment.ArticleId > 0 {
+			item.RedirectType = 1
+		} else if comment.IndustryId > 0{
+			item.RedirectType = 2
+		}else if comment.ActivityId > 0 {
+			item.RedirectType = 3
+		}
+		resp.List = append(resp.List, &item)
+	}
+
+	br.Msg = "获取成功!"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}
+
+// @Title 获取我的收藏
+// @Description 获取我的收藏列表
+// @Success 200 {object} models.ArticleCollectListResp
+// @router /collect/list/microRoadshow [get]
+func (this *UserController) MicroRoadshowCollectList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	userId := this.User.UserId
+
+	list, err := models.GetUserMicroRoadshowCollectList(userId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.MicroRoadshowCollectList)
+	var audioIds []string
+	var videoIds []string
+	for _, item := range list {
+		if item.ActivityVoiceId > 0 {
+			audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
+		} else if item.VideoId > 0 {
+			videoIds = append(videoIds, strconv.Itoa(item.VideoId))
+		}
+	}
+	resp.AudioIds = strings.Join(audioIds, ",")
+	resp.VideoIds = strings.Join(videoIds, ",")
+
 	br.Msg = "获取成功!"
 	br.Ret = 200
 	br.Success = true

+ 7 - 0
models/article_collect.go

@@ -9,6 +9,8 @@ import (
 type CygxArticleCollect struct {
 	Id          int `orm:"column(id);pk"`
 	ArticleId   int
+	ActivityVoiceId   int
+	VideoId   int
 	UserId      int
 	CreateTime  time.Time
 	Mobile      string `description:"手机号"`
@@ -149,3 +151,8 @@ func GetArticleCollectNum(articleId []string, uid int) (items []*CygxArticleNum,
 	_, err = o.Raw(sql, uid, articleId).QueryRows(&items)
 	return
 }
+
+type MicroRoadshowCollectList struct {
+	AudioIds string
+	VideoIds string
+}

+ 23 - 9
models/article_comment.go

@@ -6,21 +6,20 @@ import (
 )
 
 type CygxArticleComment struct {
-	Id       int       `orm:"column(id);pk" description:"留言id"`
+	Id          int       `orm:"column(id);pk" description:"留言id"`
 	UserId      int       `description:"用户id"`
-	ArticleId  int       `description:"文章id"`
+	ArticleId   int       `description:"文章id"`
 	ActivityId  int       `description:"活动id"`
-	VideoId  int       `description:"视频id"`
+	IndustryId  int       `description:"产业id"`
 	CreateTime  time.Time `description:"创建时间"`
 	Mobile      string    `description:"手机号"`
 	Email       string    `description:"邮箱"`
 	CompanyId   int       `description:"公司id"`
 	CompanyName string    `description:"公司名称"`
 	Content     string    `description:"内容"`
-	Title     string    `description:"标题"`
+	Title       string    `description:"标题"`
 }
 
-
 //添加留言
 func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
 	o := orm.NewOrm()
@@ -28,10 +27,9 @@ func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
 	return
 }
 
-
 type AddCygxArticleCommentReq struct {
 	ArticleId int    `description:"文章id"`
-	Content    string `description:"内容"`
+	Content   string `description:"内容"`
 }
 
 //我的留言列表
@@ -47,6 +45,22 @@ func GetCommentList(userId int) (items []*CygxArticleComment, err error) {
 	return
 }
 
+type CygxArticleCommentResp struct {
+	Id           int       `orm:"column(id);pk" description:"留言id"`
+	UserId       int       `description:"用户id"`
+	ArticleId    int       `description:"文章id"`
+	IndustryId   int       `description:"产业id"`
+	ActivityId   int       `description:"活动id"`
+	CreateTime   time.Time `description:"创建时间"`
+	Mobile       string    `description:"手机号"`
+	Email        string    `description:"邮箱"`
+	CompanyId    int       `description:"公司id"`
+	CompanyName  string    `description:"公司名称"`
+	Content      string    `description:"内容"`
+	Title        string    `description:"标题"`
+	RedirectType int       `description:"跳转类型 1文章 2活动 3产业资源包"`
+}
+
 type CygxCommentListResp struct {
-	List []*CygxArticleComment
-}
+	List []*CygxArticleCommentResp
+}

+ 9 - 0
models/user.go

@@ -472,3 +472,12 @@ type UserPermissionAuthInfo struct {
 	OperationMode string `description:"操作方式:Apply-立即申请; Call-拨号"`
 	PopupMsg      string `description:"权限弹窗信息"`
 }
+
+func GetUserMicroRoadshowCollectList(userId int) (items []*CygxArticleCollect, err error) {
+	sql := `SELECT a.* FROM cygx_article_collect AS a 
+			WHERE a.user_id=?  
+			AND a.article_id =0 
+           ORDER BY a.create_time DESC `
+	_, err = orm.NewOrm().Raw(sql, userId).QueryRows(&items)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -1096,6 +1096,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "MicroRoadshowCollectList",
+            Router: `/collect/list/microRoadshow`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
             Method: "CommnetList",

+ 18 - 1
services/micro_roadshow.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strings"
 )
 
 // GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
@@ -163,7 +164,7 @@ func GetHomeNewestList(userId, companyId, startSize, pageSize int, condition str
 }
 
 // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
-func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter int, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter int, keywords, audioIds, videoIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
 	var e error
 	// 根据每页数据量获取音视频配比
 	startSize := utils.StartIndex(currentIndex, pageSize)
@@ -195,6 +196,14 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 			audioCond += ` AND a.activity_voice_id = ?`
 			audioPars = append(audioPars, audioId)
 		}
+		if audioIds != "" {
+			sliceId := strings.Split(audioIds, ",")
+			var idSqlStr string
+			for _, v := range sliceId {
+				idSqlStr += "'" + v + "',"
+			}
+			audioCond += ` AND a.activity_voice_id IN (` + idSqlStr + `)`
+		}
 	}
 	//视频的处理
 	var videoCond string
@@ -232,6 +241,14 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 		//	videoCondAct += ` AND art.activity_time > ? `
 		//	videoParsAct = append(videoParsAct, endTime)
 		//}
+		if videoIds != "" {
+			sliceId := strings.Split(videoIds, ",")
+			var idSqlStr string
+			for _, v := range sliceId {
+				idSqlStr += "'" + v + "',"
+			}
+			audioCond += ` AND video_id IN (` + idSqlStr + `)`
+		}
 		videoCond += ` AND publish_status = 1`
 	}
 	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId, filter)