1234567891011121314151617181920212223242526 |
- 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
- }
- // 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
- }
|