Browse Source

微路演列表收藏状态

ziwen 2 năm trước cách đây
mục cha
commit
d1a076cff1
2 tập tin đã thay đổi với 37 bổ sung2 xóa
  1. 36 1
      controllers/micro_roadshow.go
  2. 1 1
      models/micro_roadshow.go

+ 36 - 1
controllers/micro_roadshow.go

@@ -67,7 +67,42 @@ func (this *MicroRoadShowController) List() {
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
 		return
 	}
-
+	for _, item := range list {
+		if item.Type  == 1 {
+			//音频
+			count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type  == 2 {
+			//活动视频
+			count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type  == 3 {
+			//微路演视频
+			count, err := models.GetVideoCollectCount(user.UserId, item.Id)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,Err:" + err.Error()
+				return
+			}
+			if count > 0 {
+				item.IsCollect = true
+			}
+		}
+	}
 	// 用户权限
 	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
 	if e != nil {

+ 1 - 1
models/micro_roadshow.go

@@ -27,6 +27,7 @@ type MicroRoadShowPageList struct {
 	IndustryName        string `description:"产业名称"`
 	PlaySeconds         string `description:"音视频时长"`
 	ActivityId          int    `description:"活动ID"`
+	IsCollect           bool   `description:"是否收藏"`
 	AuthInfo            *UserPermissionAuthInfo
 }
 
@@ -166,7 +167,6 @@ type MicroAudioUnionList struct {
 	AudioChartPermissionName string `description:"行业名称"`
 	AudioPlaySeconds         string `description:"音视频时长"`
 	AudioActivityId          int    `description:"活动ID"`
-	IsCollect                bool   `description:"是否收藏"`
 	AuthInfo                 *UserPermissionAuthInfo
 }