ziwen 2 years ago
parent
commit
e6670845cb
4 changed files with 125 additions and 12 deletions
  1. 51 3
      controllers/user.go
  2. 20 3
      models/activity_help_ask.go
  3. 20 4
      models/article_comment.go
  4. 34 2
      services/activity.go

+ 51 - 3
controllers/user.go

@@ -747,6 +747,7 @@ func (this *UserController) CollectList() {
 			}
 			item.IndustrialManagementId = v.IndustrialManagementId
 			item.IndustryName = v.IndustryName
+			item.ChartPermissionId = v.ChartPermissionId
 			industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
 		}
 	}
@@ -825,6 +826,8 @@ func (this *UserController) CollectList() {
 
 // @Title 获取我的留言
 // @Description 获取我的留言列表
+// @Param   PageSize    query   int true       "PageSize"
+// @Param   CurrentIndex    query   int true       "CurrentIndex"
 // @Success 200 {object} models.CygxCommentListResp
 // @router /comment/list [get]
 func (this *UserController) CommnetList() {
@@ -841,8 +844,25 @@ func (this *UserController) CommnetList() {
 		return
 	}
 
+	var pageSize, currentIndex, startSize int
+	pageSize, _ = this.GetInt("PageSize")
+	currentIndex, _ = this.GetInt("CurrentIndex")
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
 	userId := this.User.UserId
-	commentlist, err := models.GetCommentList(userId)
+	total, err := models.GetCommentListCount(userId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	commentlist, err := models.GetCommentList(userId, startSize, pageSize)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取我的留言列表失败,Err:" + err.Error()
@@ -858,7 +878,7 @@ func (this *UserController) CommnetList() {
 			ArticleId:   comment.ArticleId,
 			IndustryId:  comment.IndustryId,
 			ActivityId:  comment.ActivityId,
-			CreateTime:  comment.CreateTime,
+			CreateTime:  comment.CreateTime.Format(utils.FormatDateTime),
 			Mobile:      comment.Mobile,
 			Email:       comment.Email,
 			CompanyId:   comment.CompanyId,
@@ -876,6 +896,9 @@ func (this *UserController) CommnetList() {
 		resp.List = append(resp.List, &item)
 	}
 
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+
 	br.Msg = "获取成功!"
 	br.Ret = 200
 	br.Success = true
@@ -1040,6 +1063,8 @@ func (this *UserController) BrowseHistoryList() {
 
 // @Title 获取我的提问
 // @Description 获取我的提问列表
+// @Param   PageSize    query   int true       "PageSize"
+// @Param   CurrentIndex    query   int true       "CurrentIndex"
 // @Success 200 {object} models.CygxAskListResp
 // @router /ask/list [get]
 func (this *UserController) AskList() {
@@ -1055,8 +1080,28 @@ func (this *UserController) AskList() {
 		br.Ret = 408
 		return
 	}
+
+	var pageSize, currentIndex, startSize int
+	pageSize, _ = this.GetInt("PageSize")
+	currentIndex, _ = this.GetInt("CurrentIndex")
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+
 	userId := this.User.UserId
-	listActcivity, err := models.GetActivityAskList(userId)
+	total, err := models.GetActivityAskCount(userId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	listActcivity, err := models.GetActivityAskList(userId, startSize, pageSize)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取活动问题失败,Err:" + err.Error()
@@ -1076,6 +1121,9 @@ func (this *UserController) AskList() {
 		listActcivity = append(listActcivity, v)
 	}
 	resp := new(models.CygxAskListResp)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+
 	resp.List = listActcivity
 	br.Msg = "获取成功!"
 	br.Ret = 200

+ 20 - 3
models/activity_help_ask.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -40,12 +41,14 @@ type CygxAskList struct {
 
 type CygxAskListResp struct {
 	List []*CygxAskList
+	Paging *paging.PagingItem
 }
 
+
 //report_or_activity_id
 
 //主题列表
-func GetActivityAskList(userId int) (items []*CygxAskList, err error) {
+func GetActivityAskList(userId, startSize, pageSize int) (items []*CygxAskList, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			k.activity_id as report_or_activity_id,
@@ -56,8 +59,22 @@ func GetActivityAskList(userId int) (items []*CygxAskList, err error) {
 			cygx_activity_help_ask AS k
 			INNER JOIN cygx_activity AS a ON a.activity_id = k.activity_id 
 		WHERE
-			user_id = ? AND a.publish_status = 1 ORDER BY k.ask_id DESC`
-	_, err = o.Raw(sql, userId).QueryRows(&items)
+			user_id = ? AND a.publish_status = 1 ORDER BY k.ask_id DESC  LIMIT ?,?  `
+	_, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//主题列表
+func GetActivityAskCount(userId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) as count 
+		FROM
+			cygx_activity_help_ask AS k
+			INNER JOIN cygx_activity AS a ON a.activity_id = k.activity_id 
+		WHERE
+			user_id = ? AND a.publish_status = 1 ORDER BY k.ask_id DESC `
+	err = o.Raw(sql, userId).QueryRow(&count)
 	return
 }
 

+ 20 - 4
models/article_comment.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -36,16 +37,30 @@ type AddCygxArticleCommentReq struct {
 }
 
 //我的留言列表
-func GetCommentList(userId int) (items []*CygxArticleComment, err error) {
+func GetCommentList(userId, startSize, pageSize int) (items []*CygxArticleComment, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			* 
 		FROM
 			cygx_article_comment AS c
 		WHERE
-			user_id = ? ORDER BY c.create_time DESC`
+			user_id = ? ORDER BY c.create_time DESC LIMIT ?,?  `
 
-	_, err = o.Raw(sql, userId).QueryRows(&items)
+	_, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//我的留言列表
+func GetCommentListCount(userId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) as count 
+		FROM
+			cygx_article_comment AS c
+		WHERE
+			user_id = ? ORDER BY c.create_time DESC  `
+
+	err = o.Raw(sql, userId).QueryRow(&count)
 	return
 }
 
@@ -55,7 +70,7 @@ type CygxArticleCommentResp struct {
 	ArticleId    int       `description:"文章id"`
 	IndustryId   int       `description:"产业id"`
 	ActivityId   int       `description:"活动id"`
-	CreateTime   time.Time `description:"创建时间"`
+	CreateTime   string `description:"创建时间"`
 	Mobile       string    `description:"手机号"`
 	Email        string    `description:"邮箱"`
 	CompanyId    int       `description:"公司id"`
@@ -67,4 +82,5 @@ type CygxArticleCommentResp struct {
 
 type CygxCommentListResp struct {
 	List []*CygxArticleCommentResp
+	Paging *paging.PagingItem
 }

+ 34 - 2
services/activity.go

@@ -459,7 +459,11 @@ func ActivityButtonShow(item *models.ActivityDetail, user *models.WxUserItem) (i
 			}
 		}
 	}
-
+	authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		e = errors.New("获取用户权限失败, Err: " + e.Error())
+		return
+	}
 	v := articleDetail
 	itemActivity = &models.ActivityListResp{
 		ActivityId:              v.ActivityId,
@@ -515,11 +519,39 @@ func ActivityButtonShow(item *models.ActivityDetail, user *models.WxUserItem) (i
 		SourceType:              v.SourceType,
 		SignupNum:               v.SignupNum,
 		YidongActivityUrl:       yidongActivityUrl,
-		AuthInfo:                v.AuthInfo,
 		Explain:                 utils.ACtIVITY_SPECIAL_EXPLAIN,
 		TripImgLink:             v.TripImgLink,
 		Days:                    v.Days,
 	}
+	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 v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
+			au.HasPermission = 2
+		}
+	}
+
+	// 无权限的弹框提示
+	if au.HasPermission != 1 {
+		if au.OperationMode == UserPermissionOperationModeCall {
+			if v.FileType == 1 {
+				au.PopupMsg = UserPermissionPopupMsgCallMicroVoice
+			} else {
+				au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+			}
+		} else {
+			if v.FileType == 1 {
+				au.PopupMsg = UserPermissionPopupMsgApplyMicroVoice
+			} else {
+				au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+			}
+		}
+	}
+	itemActivity.AuthInfo = au
 	//处理用户已经报名了的行程
 	var activityIds []int
 	activityIds = append(activityIds, v.ActivityId)