query.go 352 B

123456789101112131415
  1. package yb_comment_anonymous_user
  2. import (
  3. "hongze/hongze_yb/global"
  4. "hongze/hongze_yb/utils"
  5. )
  6. // GetByUserId 根据用户ID,查询记录
  7. func GetByUserId(userId uint64) (item *YbCommentAnonymousUser, err error) {
  8. err = global.DEFAULT_MYSQL.Where("user_id = ? ", userId).First(&item).Error
  9. if err == utils.ErrNoRow {
  10. err = nil
  11. }
  12. return
  13. }