blacklist.go 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. package dao
  2. import (
  3. "strings"
  4. "go-common/app/admin/main/growup/model"
  5. )
  6. // ListBlacklist find blacklist by query
  7. func (d *Dao) ListBlacklist(query string, from, limit int, sort string) (list []*model.Blacklist, total int, err error) {
  8. err = d.db.Table("av_black_list").Where(query).Count(&total).Error
  9. if err != nil {
  10. return
  11. }
  12. if strings.HasPrefix(sort, "-") {
  13. sort = strings.TrimPrefix(sort, "-")
  14. sort = sort + " " + "desc"
  15. }
  16. err = d.db.Table("av_black_list").Order(sort).Offset(from).Where(query).Limit(limit).Find(&list).Error
  17. return
  18. }
  19. // GetAvIncomeStatis get av total income
  20. func (d *Dao) GetAvIncomeStatis(query string) (avIncome []*model.AvIncomeStatis, err error) {
  21. err = d.db.Table("av_income_statis").Where(query).Find(&avIncome).Error
  22. return
  23. }
  24. // UpdateBlacklist update blacklist
  25. func (d *Dao) UpdateBlacklist(avID int64, ctype int, update map[string]interface{}) (err error) {
  26. return d.db.Table("av_black_list").Where("av_id = ? AND ctype = ? AND is_delete = 0", avID, ctype).Updates(update).Error
  27. }