sec_task_info_dao.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. package dao
  2. import (
  3. "youngee_b_api/app/entity"
  4. )
  5. type SecTaskInfoDao struct{}
  6. func (s SecTaskInfoDao) CountBySelectionId(selectionId string) (int64, error) {
  7. var count int64
  8. err := Db.Model(&entity.SecTaskInfo{}).Where("selection_id = ?", selectionId).Count(&count).Error
  9. return count, err
  10. }
  11. // 获取带货子任务中指定悬赏阶段的数据
  12. func (s SecTaskInfoDao) GetRewardDetailByRewardStage(selectionId string, rewardStage int64, order int64, page int, pageSize int) ([]*entity.SecTaskInfo, int64, error) {
  13. secTaskInfos := []*entity.SecTaskInfo{}
  14. var total int64
  15. query := Db.Debug().Model(&entity.SecTaskInfo{}).Where("selection_id = ? AND reward_stage = ?", selectionId, rewardStage)
  16. query.Count(&total)
  17. query = query.Select("talent_id, sale_actual, withdraw_date")
  18. offset := (page - 1) * pageSize
  19. var err error
  20. if order == 1 {
  21. err = query.Order("withdraw_date asc").Offset(offset).Limit(pageSize).Find(&secTaskInfos).Error
  22. } else {
  23. err = query.Order("withdraw_date desc").Offset(offset).Limit(pageSize).Find(&secTaskInfos).Error
  24. }
  25. if err != nil {
  26. return nil, 0, err
  27. }
  28. return secTaskInfos, total, nil
  29. }