Browse Source

我的留言列表增加,上次选择

xiexiaoyuan 2 years ago
parent
commit
bcf2afd25a
3 changed files with 30 additions and 11 deletions
  1. 1 1
      controller/comment/comment.go
  2. 15 10
      models/response/comment.go
  3. 14 0
      services/comment/comment.go

+ 1 - 1
controller/comment/comment.go

@@ -160,7 +160,7 @@ func MyList(c *gin.Context)  {
 
 	userinfo := userService.GetInfoByClaims(c)
 
-	list, err := commentService.List(userinfo, reportId, reportChapterId, oldReportId,oldReportChapterId, false, 0, 0)
+	list, err := commentService.MyList(userinfo, reportId, reportChapterId, oldReportId,oldReportChapterId)
 	if err != nil {
 		response.Fail(err.Error(), c)
 		return

+ 15 - 10
models/response/comment.go

@@ -6,17 +6,22 @@ type RespCommentList struct {
 	List       []*RespCommentItem   `json:"list"`
 	Paging     *PagingItem  		`json:"paging"`
 }
+type RespMyCommentList struct {
+	List       []*RespCommentItem   `json:"list"`
+	IsShowName int8 `description:"是否匿名 0-匿名,1-不匿名" json:"is_show_name"`
+}
 type RespCommentItem struct {
-	CommentId         uint64 `description:"留言ID" json:"comment_id"`
-	UserId            uint64 `description:"用户id" json:"user_id"`
-	Content           string `description:"留言内容" json:"content"`
-	IsTop             int8 `description:"是否置顶(0-未置顶,1-置顶)json:"is_top""`
-	IsHot             int8 `description:"是否设置精选(0-未设置,1-已设置)json:"is_hot""`
-	HotTopTime        time.Time `description:"设置精选或者设置置顶的时间" json:"hot_top_time"`
-	UserName          string `description:"用户昵称" json:"user_name"`
-	UserImgUrl           string `description:"用户头像" json:"user_img_url"`
-	CreateTime        time.Time `description:"留言创建时间" json:"create_time"`
-	ReplyList        []*ReplyItem
+	CommentId  uint64    `description:"留言ID" json:"comment_id"`
+	UserId     uint64    `description:"用户id" json:"user_id"`
+	Content    string    `description:"留言内容" json:"content"`
+	IsTop      int8      `description:"是否置顶(0-未置顶,1-置顶)json:"is_top""`
+	IsHot      int8      `description:"是否设置精选(0-未设置,1-已设置)json:"is_hot""`
+	HotTopTime time.Time `description:"设置精选或者设置置顶的时间" json:"hot_top_time"`
+	IsShowName int8      `description:"是否匿名 0-匿名,1-不匿名" json:"is_show_name"`
+	UserName   string    `description:"用户昵称" json:"user_name"`
+	UserImgUrl string    `description:"用户头像" json:"user_img_url"`
+	CreateTime time.Time `description:"留言创建时间" json:"create_time"`
+	ReplyList  []*ReplyItem
 }
 
 type ReplyItem struct {

+ 14 - 0
services/comment/comment.go

@@ -155,6 +155,19 @@ func Delete(user user.UserInfo, req *reqComment.ReqDel) (err error) {
 	return
 }
 
+// MyList 我的留言列表
+func MyList(user user.UserInfo,  reportId, reportChapterId, oldReportId, oldReportChapterId int) (ret response.RespMyCommentList, err error) {
+	list, err := List(user, reportId, reportChapterId, oldReportId, oldReportChapterId, false, 0, 0)
+	if err != nil {
+		return
+	}
+	if len(list.List) > 0 {
+		ret.IsShowName = list.List[0].IsShowName
+	}
+	ret.List = list.List
+	return
+}
+
 // List 查询精选留言列表或我的留言列表
 func List(user user.UserInfo,  reportId, reportChapterId, oldReportId, oldReportChapterId int, hotFlag bool, pageIndex, pageSize int) (ret response.RespCommentList, err error) {
 	var errMsg string
@@ -295,6 +308,7 @@ func List(user user.UserInfo,  reportId, reportChapterId, oldReportId, oldReport
 		tmp.IsTop = v.IsTop
 		tmp.HotTopTime = v.HotTopTime
 		tmp.CreateTime = v.CreateTime
+		tmp.IsShowName = v.IsShowName
 		if existList, ok := replyListMap[v.CommentId]; ok {
 			tmp.ReplyList = existList
 		}