provider_delete_platform.go 638 B

1234567891011121314151617181920212223242526
  1. package provider
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/errors"
  6. "github.com/astaxie/beego/orm"
  7. )
  8. func ManagementDelProviderPlatform(ctx context.Context, req *apis.ManagementDelProviderPlatformReq, reply *apis.ManagementDelProviderPlatformReply) error {
  9. if req.ProviderId == 0 {
  10. return errors.ArgsError
  11. }
  12. exist := orm.NewOrm().QueryTable("t_gd_provider_api").Filter("provider_id", req.ProviderId).Exist()
  13. if exist {
  14. return errors.ProviderHaveApi
  15. }
  16. _, err := orm.NewOrm().Raw("delete from t_gd_provider where id = ?", req.ProviderId).Exec()
  17. if err != nil {
  18. return errors.DataBaseError
  19. }
  20. return nil
  21. }