1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package yb_comment
- import (
- "hongze/hongze_yb/global"
- "hongze/hongze_yb/utils"
- )
- // GetListByUserId 获取用户的留言列表
- func GetListByUserId(userId uint64, reportId, reportChapterId int) (list []*YbComment, err error) {
- 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").
- Scan(&list).Error
- if err == utils.ErrNoRow {
- err = nil
- }
- return
- }
- // GetHotListByReportId 获取报告的精选留言列表
- func GetHotListByReportId(reportId, reportChapterId int, offset, limit int) (list []*YbComment, 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).
- Order("hot_top_time desc, id desc").
- Offset(offset).
- Limit(limit).
- Scan(&list).Error
- return
- }
- // GetReplayListByReplyCommentId 获取报告的精选留言的回复列表
- func GetReplayListByReplyCommentId(reportId, reportChapterId int, replyCommentIds []int) (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).
- Order("create_time desc, id desc").
- Scan(&list).Error
- return
- }
- // GetSimpleByCommentId 根据评论ID,查询评论
- func GetSimpleByCommentId(commentId uint64)(item *YbComment, err error) {
- err = global.DEFAULT_MYSQL.Model(YbComment{}).
- Select("comment_id, user_id, type, enabled").
- Where("comment_id = ?", commentId).First(&item).Error
- if err == utils.ErrNoRow {
- err = nil
- }
- return
- }
|