auto.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "time"
  6. "go-common/library/log"
  7. )
  8. // AutoDismiss update account state to 6
  9. func (s *Service) AutoDismiss(c context.Context, operator string, typ int, mid int64, reason string) (err error) {
  10. ups, err := s.dao.UpsVideoInfo(c, fmt.Sprintf("mid = %d", mid))
  11. if err != nil {
  12. log.Error("s.dao.UpsVideoInfo error(%v)", err)
  13. return
  14. }
  15. if len(ups) <= 0 {
  16. return
  17. }
  18. up := ups[0]
  19. return s.Dismiss(c, operator, typ, up.AccountState, mid, reason)
  20. }
  21. // AutoForbid update account state to 7 and add a n days CD
  22. func (s *Service) AutoForbid(c context.Context, operator string, typ int, mid int64, reason string, days, second int) (err error) {
  23. ups, err := s.dao.UpsVideoInfo(c, fmt.Sprintf("mid = %d", mid))
  24. if err != nil {
  25. log.Error("s.dao.UpsVideoInfo error(%v)", err)
  26. return
  27. }
  28. if len(ups) <= 0 {
  29. return
  30. }
  31. up := ups[0]
  32. switch up.AccountState {
  33. case 3:
  34. return s.Forbid(c, operator, typ, 3, mid, reason, days, second)
  35. case 7:
  36. return s.Forbid(c, operator, typ, 7, mid, reason, days, int(int64(up.ExpiredIn)+int64(second)-time.Now().Unix()))
  37. }
  38. return
  39. }