123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package yb_like
- import (
- "hongze/hongze_yb/global"
- "hongze/hongze_yb/utils"
- )
- // GetLikeByUserIdAndReportId 获取点赞记录
- func GetLikeByUserIdAndReportId(userId uint64, reportId, reportChapterId int) (item *YbLike, err error) {
- err = global.DEFAULT_MYSQL.Model(YbLike{}).
- Where("user_id = ? and report_id = ? and report_chapter_id = ?", userId, reportId, reportChapterId).
- First(&item).Error
- if err == utils.ErrNoRow {
- err = nil
- }
- return
- }
- // GetLikeByUserIdAndOldReportId 获取点赞记录
- func GetLikeByUserIdAndOldReportId(userId uint64, oldReportId, oldReportChapterId int) (item *YbLike, err error) {
- err = global.DEFAULT_MYSQL.Model(YbLike{}).
- Where("user_id = ? and old_report_id = ? and old_report_chapter_id = ?", userId, oldReportId, oldReportChapterId).
- First(&item).Error
- if err == utils.ErrNoRow {
- err = nil
- }
- return
- }
- // GetLikeNumByReportId 统计报告的点赞数
- func GetLikeNumByReportId(reportId, reportChapterId int) (num int64, err error) {
- err = global.DEFAULT_MYSQL.Model(YbLike{}).
- Where("report_id = ? and report_chapter_id = ? and enabled=1", reportId, reportChapterId).
- Count(&num).Error
- return
- }
- // GetLikeNumByOldReportId 统计报告的点赞数
- func GetLikeNumByOldReportId(oldReportId, oldReportChapterId int) (num int64, err error) {
- err = global.DEFAULT_MYSQL.Model(YbLike{}).
- Where("old_report_id = ? and old_report_chapter_id = ? and enabled=1", oldReportId, oldReportChapterId).
- Count(&num).Error
- return
- }
|