123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package yb_comment
- import (
- "hongze/hongze_yb/global"
- "hongze/hongze_yb/utils"
- )
- func GetListByUserIdReportId(userId uint64, reportId, reportChapterId int) (list []*YbComment, err error) {
-
-
-
-
- tmp := global.DEFAULT_MYSQL.Model(YbComment{}).
- Where("user_id = ? and report_id = ? and enabled = 1 ", userId, reportId)
- if reportChapterId > 0 {
- tmp = tmp.Where("report_chapter_id = ?", reportChapterId)
- }
- err = tmp.Order("create_time desc, comment_id desc").
- Scan(&list).Error
- if err == utils.ErrNoRow {
- err = nil
- }
- return
- }
- func GetListByUserIdOldReportId(userId uint64, oldReportId, oldReportChapterId int) (list []*YbComment, err error) {
- err = global.DEFAULT_MYSQL.Model(YbComment{}).
- Where("user_id = ? and old_report_id = ? and old_report_chapter_id = ? and enabled = 1 ", userId, oldReportId, oldReportChapterId).
- Order("create_time desc, comment_id desc").
- Scan(&list).Error
- if err == utils.ErrNoRow {
- err = nil
- }
- return
- }
- func GetHotListByReportId(reportId, reportChapterId int, offset, limit int) (list []*YbComment, err error) {
-
-
-
-
-
-
- tmp := global.DEFAULT_MYSQL.Model(YbComment{}).
- Where("report_id = ? and enabled = 1 and is_hot = 1 and type = 1", reportId)
-
- if reportChapterId > 0 {
- tmp = tmp.Where("report_chapter_id = ? ", reportChapterId)
- }
- err = tmp.Order("is_top desc, hot_top_time desc, comment_id desc").
- Offset(offset).
- Limit(limit).
- Scan(&list).Error
- return
- }
- func GetHotListTotalByReportId(reportId, reportChapterId int) (total int64, err error) {
- tmp := global.DEFAULT_MYSQL.Model(YbComment{}).
- Where("report_id = ? and enabled = 1 and is_hot = 1 and type = 1", reportId)
-
- if reportChapterId > 0 {
- tmp = tmp.Where(" report_chapter_id = ? ", reportChapterId)
- }
- err = tmp.Count(&total).Error
- return
- }
- func GetHotListByOldReportId(oldReportId, oldReportChapterId int, offset, limit int) (list []*YbComment, err error) {
- err = global.DEFAULT_MYSQL.Model(YbComment{}).
- Where("old_report_id = ? and old_report_chapter_id = ? and enabled = 1 and is_hot = 1 and type = 1", oldReportId, oldReportChapterId).
- Order("is_top desc, hot_top_time desc, comment_id desc").
- Offset(offset).
- Limit(limit).
- Scan(&list).Error
- return
- }
- func GetHotListTotalByOldReportId(oldReportId, oldReportChapterId int) (total int64, err error) {
- err = global.DEFAULT_MYSQL.Model(YbComment{}).
- Where("old_report_id = ? and old_report_chapter_id = ? and enabled = 1 and is_hot = 1 and type = 1", oldReportId, oldReportChapterId).
- Count(&total).Error
- return
- }
- func GetReplyListByReplyCommentId(replyCommentIds []uint64) (list []*YbComment, err error) {
- err = global.DEFAULT_MYSQL.Model(YbComment{}).
- Where("enabled = 1 and type = 2 and reply_comment_id in ?", replyCommentIds).
- Order("comment_id asc").
- Scan(&list).Error
- return
- }
- 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
- }
- func GetMyLatestComment(userId uint64) (item *YbComment, err error) {
- err = global.DEFAULT_MYSQL.Model(YbComment{}).
- Select("comment_id, user_id, type, enabled, is_show_name").
- Where("user_id = ? and type=1", userId).Order("comment_id desc").First(&item).Error
- return
- }
|