query.go 1011 B

123456789101112131415161718192021222324252627282930
  1. package yb_apply_record
  2. import (
  3. "errors"
  4. "hongze/hongze_yb/global"
  5. "hongze/hongze_yb/utils"
  6. )
  7. // GetByWhereMap 根据查询条件map获取信息
  8. func GetByWhereMap(where map[string]interface{}) (item *YbApplyRecord, err error) {
  9. cond, whereVal, buildErr := utils.WhereBuild(where)
  10. if buildErr != nil {
  11. err = errors.New("系统异常,生成查询语句失败")
  12. return
  13. }
  14. err = global.DEFAULT_MYSQL.Where(cond, whereVal...).First(&item).Error
  15. return
  16. }
  17. // GetByRecordId 根据apply_record_id获取申请记录信息
  18. func GetByRecordId(recordId int) (item *YbApplyRecord, err error) {
  19. err = global.DEFAULT_MYSQL.Where("apply_record_id = ? ", recordId).First(&item).Error
  20. return
  21. }
  22. // GetLastNotOpRecordByUserId 根据用户id获取最近的一条未被操作过的申请记录信息
  23. func GetLastNotOpRecordByUserId(userId int) (item *YbApplyRecord, err error) {
  24. err = global.DEFAULT_MYSQL.Where("user_id = ? AND op_status = 0", userId).Order("apply_record_id desc").First(&item).Error
  25. return
  26. }