Procházet zdrojové kódy

消息设置已读,bug修改

xiexiaoyuan před 2 roky
rodič
revize
3318946bbf

+ 1 - 1
logic/user/user.go

@@ -112,7 +112,7 @@ type Detail struct {
 	AdminInfo      *admin2.Admin	   `json:"admin_info" description:"系统管理员信息"`
 	UnRead         int64               `json:"un_read" description:"消息未读数"`
 	NickName       string              `json:"nick_name" description:"用户昵称"`
-	HeadImgUrl     string              `json:"headImgUrl" description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
+	HeadImgUrl     string              `json:"head_img_url" description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
 }
 
 // GetUserInfo 获取用户我的页面详情数据

+ 14 - 12
models/response/message.go

@@ -3,19 +3,21 @@ package response
 import "time"
 
 type RespMessageItem struct {
-	MsgId               uint64 `description:"消息ID" json:"msg_id"`
-	UserId              uint64 `description:"用户ID" json:"user_id"`
-	Type                int8   `description:"消息类型:1-留言回复通知,2-精选留言通知" json:"type"`
-	CreateTime          time.Time `description:"创建时间" json:"create_time"`
-	ContentFirst        string `description:"消息第一行留言内容" json:"content_first"`
-	ContentSecond       string `description:"消息第二行内容" json:"content_second"`
-	IsRead              int8   `description:"是否已读 0-未读,1-已读" json:"is_read"`
-	ReportId            int `description:"报告ID"  json:"report_id" `
-	ReportChapterId     int `description:"报告章节ID" json:"report_chapter_id" `
-	Img                 string `description:"左边头像" json:"img"`
+	MsgId              uint64    `description:"消息ID" json:"msg_id"`
+	UserId             uint64    `description:"用户ID" json:"user_id"`
+	Type               int8      `description:"消息类型:1-留言回复通知,2-精选留言通知" json:"type"`
+	CreateTime         time.Time `description:"创建时间" json:"create_time"`
+	ContentFirst       string    `description:"消息第一行留言内容" json:"content_first"`
+	ContentSecond      string    `description:"消息第二行内容" json:"content_second"`
+	IsRead             int8      `description:"是否已读 0-未读,1-已读" json:"is_read"`
+	ReportId           int       `description:"报告ID"  json:"report_id" `
+	ReportChapterId    int       `description:"报告章节ID" json:"report_chapter_id" `
+	OldReportId        int       `description:"老报告ID" json:"old_report_id"`
+	OldReportChapterId int       `description:"老报告章节ID" json:"old_report_chapter_id"`
+	Img                string    `description:"左边头像" json:"img"`
 }
 
 type RespMessageList struct {
-	List []*RespMessageItem         `json:"list"`
-	Paging     *PagingItem  		`json:"paging"`
+	List   []*RespMessageItem `json:"list"`
+	Paging *PagingItem        `json:"paging"`
 }

+ 6 - 6
models/response/report.go

@@ -5,12 +5,12 @@ import (
 )
 
 type ReportDetail struct {
-	ReportInfo          *ReportItem              `json:"report_info"`
-	ReportChapterList   []*ReportChapterListItem `json:"report_chapter_list"`
-	PermissionCheck     *PermissionCheckInfo     `json:"permission_check"`
-	AuthOk              bool                     `json:"auth_ok"`
-	LikeNum             int64  `description:"点赞总数" json:"like_num"`
-	LikeEnabled         int8 `description:"是否已点赞: 0-未点赞 1-已点赞" json:"like_enabled"`
+	ReportInfo        *ReportItem              `json:"report_info"`
+	ReportChapterList []*ReportChapterListItem `json:"report_chapter_list"`
+	PermissionCheck   *PermissionCheckInfo     `json:"permission_check"`
+	AuthOk            bool                     `json:"auth_ok"`
+	LikeNum           int64                    `description:"点赞总数" json:"like_num"`
+	LikeEnabled       int8                     `description:"是否已点赞: 0-未点赞 1-已点赞" json:"like_enabled"`
 }
 
 type ReportChapterListItem struct {

+ 2 - 2
models/tables/yb_comment/query.go

@@ -69,9 +69,9 @@ func GetHotListTotalByOldReportId(oldReportId, oldReportChapterId int)(total int
 }
 
 // GetReplyListByReplyCommentId 获取报告的精选留言的回复列表
-func GetReplyListByReplyCommentId(reportId, reportChapterId int, replyCommentIds []uint64) (list []*YbComment, err error) {
+func GetReplyListByReplyCommentId(replyCommentIds []uint64) (list []*YbComment, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbComment{}).
-		Where("report_id = ? and report_chapter_id = ? and enabled = 1 and type = 2 and reply_comment_id in ?", reportId, reportChapterId, replyCommentIds).
+		Where("enabled = 1 and type = 2 and reply_comment_id in ?", replyCommentIds).
 		Order("create_time desc, comment_id desc").
 		Scan(&list).Error
 	return

+ 2 - 2
models/tables/yb_message/update.go

@@ -14,8 +14,8 @@ func (ym *YbMessage) Update(updateCols []string) (err error) {
 func SetBatchRead(userId uint64, msgType int)(err error) {
 	var pars []interface{}
 	pars = append(pars, userId)
-	sql := ` UPDATE yb_message set is_read = 0, modify_time=NOW()
-WHERE user_id = ? and is_read = 1 `
+	sql := ` UPDATE yb_message set is_read = 1, modify_time=NOW()
+WHERE user_id = ? and is_read = 0 `
 	if msgType > 0 {
 		sql += " and type= ?"
 		pars = append(pars, msgType)

+ 14 - 12
models/tables/yb_message/yb_message.go

@@ -4,18 +4,20 @@ import "time"
 
 // 研报 消息表
 type YbMessage struct {
-	MsgId               uint64 `gorm:"primaryKey;column:msg_id"` //消息序号
-	UserId              uint64 `gorm:"column:user_id"` //用户id
-	Type                int8 `gorm:"column:type"` //消息类型:1-留言回复通知,2-精选留言通知
-	Enabled             int8 `gorm:"column:enabled"` //是否有效, 0-无效 1-有效
-	CreateTime          time.Time `gorm:"column:create_time"` //创建时间
-	ModifyTime          time.Time `gorm:"column:modify_time"` //修改时间
-	CommentId           uint64 `gorm:"column:comment_id"` //留言ID
-	IsRead              int8 `gorm:"column:is_read"` //是否已读 0-未读,1-已读
-	ContentFirst        string `gorm:"column:content_first"` //消息第一行留言内容
-	ContentSecond       string `gorm:"column:content_second"` //消息第二行内容
-	ReportId            int `gorm:"column:report_id"` //报告ID
-	ReportChapterId     int `gorm:"column:report_chapter_id"` //报告章节ID
+	MsgId              uint64    `gorm:"primaryKey;column:msg_id"`     //消息序号
+	UserId             uint64    `gorm:"column:user_id"`               //用户id
+	Type               int8      `gorm:"column:type"`                  //消息类型:1-留言回复通知,2-精选留言通知
+	Enabled            int8      `gorm:"column:enabled"`               //是否有效, 0-无效 1-有效
+	CreateTime         time.Time `gorm:"column:create_time"`           //创建时间
+	ModifyTime         time.Time `gorm:"column:modify_time"`           //修改时间
+	CommentId          uint64    `gorm:"column:comment_id"`            //留言ID
+	IsRead             int8      `gorm:"column:is_read"`               //是否已读 0-未读,1-已读
+	ContentFirst       string    `gorm:"column:content_first"`         //消息第一行留言内容
+	ContentSecond      string    `gorm:"column:content_second"`        //消息第二行内容
+	ReportId           int       `gorm:"column:report_id"`             //报告ID
+	ReportChapterId    int       `gorm:"column:report_chapter_id"`     //报告章节ID
+	OldReportId        int       `gorm:"column:old_report_id"`         //老报告ID
+	OldReportChapterId int       `gorm:"column:old_report_chapter_id"` //老报告章节ID
 }
 
 func (ym *YbMessage) TableName() string {

+ 2 - 1
services/comment/comment.go

@@ -223,7 +223,7 @@ func List(user user.UserInfo,  reportId, reportChapterId, oldReportId, oldReport
 	// 查询所有的回复列表
 	replyListMap := make(map[uint64][]*response.ReplyItem)
 	if len(commentIds) > 0 {
-		replyList, tErr := yb_comment.GetReplyListByReplyCommentId(reportId, reportChapterId, commentIds)
+		replyList, tErr := yb_comment.GetReplyListByReplyCommentId(commentIds)
 		if tErr != nil {
 			errMsg = tErr.Error()
 			err = errors.New("查询回复出错")
@@ -235,6 +235,7 @@ func List(user user.UserInfo,  reportId, reportChapterId, oldReportId, oldReport
 			t.Content = v.Content
 			t.AdminId = v.AdminId
 			t.CreateTime = v.CreateTime
+			t.ReplyCommentId = v.ReplyCommentId
 			t.AdminName = "弘则研究"
 			t.AdminImgUrl = utils.DEFAULT_HONGZE_SYS_LOGO
 			replyListMap[v.ReplyCommentId] = append(replyListMap[v.ReplyCommentId], t)

+ 4 - 2
services/message/message.go

@@ -48,6 +48,8 @@ func GetList(user user.UserInfo, msgType, pageIndex, pageSize int) (ret response
 		tmp.CreateTime = v.CreateTime
 		tmp.ReportChapterId = v.ReportChapterId
 		tmp.ReportId = v.ReportId
+		tmp.OldReportId = v.OldReportId
+		tmp.OldReportChapterId = v.OldReportChapterId
 		tmp.ContentFirst = v.ContentFirst
 		tmp.ContentSecond = v.ContentSecond
 		tmp.Img = ""
@@ -97,10 +99,10 @@ func SingleRead(user user.UserInfo, req message.ReqMessage) (err error) {
 		err = errors.New("消息不存在")
 		return
 	}
-	if msgInfo.IsRead == 0 {
+	if msgInfo.IsRead == 1 {
 		return
 	}
-	msgInfo.IsRead = 0
+	msgInfo.IsRead = 1
 	msgInfo.ModifyTime = time.Now()
 	//根据类型设置一键已读
 	err = msgInfo.Update([]string{"is_read","modify_time"})