platform.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/main/vip/model"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. )
  8. // PlatformAll .
  9. func (s *Service) PlatformAll(c context.Context, order string) (res []*model.ConfPlatform, err error) {
  10. if res, err = s.dao.PlatformAll(c, order); err != nil {
  11. return
  12. }
  13. return
  14. }
  15. // PlatformByID .
  16. func (s *Service) PlatformByID(c context.Context, arg *model.ArgID) (dlg *model.ConfPlatform, err error) {
  17. return s.dao.PlatformByID(c, arg.ID)
  18. }
  19. // PlatformSave .
  20. func (s *Service) PlatformSave(c context.Context, arg *model.ConfPlatform) (eff int64, err error) {
  21. return s.dao.PlatformSave(c, arg)
  22. }
  23. // PlatformDel .
  24. func (s *Service) PlatformDel(c context.Context, arg *model.ArgID, operator string) (eff int64, err error) {
  25. pcount, err := s.dao.CountVipPriceConfigByPlat(c, arg.ID)
  26. if err != nil {
  27. return
  28. }
  29. dcount, err := s.dao.CountDialogByPlatID(c, arg.ID)
  30. if err != nil {
  31. return
  32. }
  33. if pcount > 0 || dcount > 0 {
  34. err = ecode.VipPlatformConfDelErr
  35. return
  36. }
  37. eff, err = s.dao.PlatformDel(c, arg.ID, operator)
  38. log.Warn("user(%s) delete dialog(%d) effect row(%d)", operator, arg.ID, eff)
  39. return
  40. }