data_api_delete_api.go 807 B

123456789101112131415161718192021222324252627282930
  1. package data_api
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/common.in/utils"
  6. "gd_management/errors"
  7. "github.com/astaxie/beego/orm"
  8. "go.uber.org/zap"
  9. )
  10. func DataApiDeleteApi(ctx context.Context, req *apis.ManagementDataApiDeleteApiReq, reply *apis.ManagementDataApiDeleteApiReply) error {
  11. if req.DataApiId == 0 {
  12. return errors.ArgsError
  13. }
  14. o := orm.NewOrm()
  15. exist := o.QueryTable("t_gd_data_api_query_type").Filter("data_api_id", req.DataApiId).Exist()
  16. if exist {
  17. return errors.QeuryTypeInDataApi
  18. }
  19. _, err := o.Delete(&apis.DataApi{Id: req.DataApiId})
  20. if err != nil {
  21. l.Error("mysql",
  22. zap.String("sql", "delete from t_gd_data_api"),
  23. zap.String("fileds", utils.MarshalJsonString(req)),
  24. zap.String("error", err.Error()))
  25. return errors.DataBaseError
  26. }
  27. return nil
  28. }