|
@@ -6,11 +6,11 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
-// GetListByUserId 获取用户的留言列表
|
|
|
|
-func GetListByUserId(userId uint64, reportId, reportChapterId int) (list []*YbComment, err error) {
|
|
|
|
|
|
+// GetListByUserIdReportId 获取用户的留言列表
|
|
|
|
+func GetListByUserIdReportId(userId uint64, reportId, reportChapterId int) (list []*YbComment, err error) {
|
|
err = global.DEFAULT_MYSQL.Model(YbComment{}).
|
|
err = global.DEFAULT_MYSQL.Model(YbComment{}).
|
|
- Where("user_id = ? and report_id = ? and report_chapter_id = ?", userId, reportId, reportChapterId).
|
|
|
|
- Order("create_time desc, id desc").
|
|
|
|
|
|
+ Where("user_id = ? and report_id = ? and report_chapter_id = ? and enabled = 1 ", userId, reportId, reportChapterId).
|
|
|
|
+ Order("create_time desc, comment_id desc").
|
|
Scan(&list).Error
|
|
Scan(&list).Error
|
|
if err == utils.ErrNoRow {
|
|
if err == utils.ErrNoRow {
|
|
err = nil
|
|
err = nil
|
|
@@ -22,18 +22,26 @@ func GetListByUserId(userId uint64, reportId, reportChapterId int) (list []*YbCo
|
|
func GetHotListByReportId(reportId, reportChapterId int, offset, limit int) (list []*YbComment, err error) {
|
|
func GetHotListByReportId(reportId, reportChapterId int, offset, limit int) (list []*YbComment, err error) {
|
|
err = global.DEFAULT_MYSQL.Model(YbComment{}).
|
|
err = global.DEFAULT_MYSQL.Model(YbComment{}).
|
|
Where("report_id = ? and report_chapter_id = ? and enabled = 1 and is_hot = 1 and type = 1", reportId, reportChapterId).
|
|
Where("report_id = ? and report_chapter_id = ? and enabled = 1 and is_hot = 1 and type = 1", reportId, reportChapterId).
|
|
- Order("hot_top_time desc, id desc").
|
|
|
|
|
|
+ Order("is_top desc, hot_top_time desc, comment_id desc").
|
|
Offset(offset).
|
|
Offset(offset).
|
|
Limit(limit).
|
|
Limit(limit).
|
|
Scan(&list).Error
|
|
Scan(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-// GetReplayListByReplyCommentId 获取报告的精选留言的回复列表
|
|
|
|
-func GetReplayListByReplyCommentId(reportId, reportChapterId int, replyCommentIds []int) (list []*YbComment, err error) {
|
|
|
|
|
|
+// GetHostListTotalByReportId 获取精选留言总条数
|
|
|
|
+func GetHostListTotalByReportId(reportId, reportChapterId int)(total int64, err error) {
|
|
|
|
+ err = global.DEFAULT_MYSQL.Model(YbComment{}).
|
|
|
|
+ Where("report_id = ? and report_chapter_id = ? and enabled = 1 and is_hot = 1 and type = 1", reportId, reportChapterId).
|
|
|
|
+ Count(&total).Error
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetReplyListByReplyCommentId 获取报告的精选留言的回复列表
|
|
|
|
+func GetReplyListByReplyCommentId(reportId, reportChapterId int, replyCommentIds []uint64) (list []*YbComment, err error) {
|
|
err = global.DEFAULT_MYSQL.Model(YbComment{}).
|
|
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("report_id = ? and report_chapter_id = ? and enabled = 1 and type = 2 and reply_comment_id in ?", reportId, reportChapterId, replyCommentIds).
|
|
- Order("create_time desc, id desc").
|
|
|
|
|
|
+ Order("create_time desc, comment_id desc").
|
|
Scan(&list).Error
|
|
Scan(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|