base_api_get_id.go 661 B

123456789101112131415161718192021222324
  1. package base_api
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/errors"
  6. "fmt"
  7. "github.com/astaxie/beego/orm"
  8. )
  9. func ManagementGetBaseApiId(ctx context.Context, req *apis.ManagementGetBaseApiIdReq, reply *apis.ManagementGetBaseApiIdReply) error {
  10. fmt.Printf("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n")
  11. err := orm.NewOrm().Raw("select id from t_gd_api where router = ? and method = ?", req.Router, req.Method).QueryRow(&reply.ApiId)
  12. fmt.Printf("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:%v\n", err)
  13. if err != nil {
  14. if err != orm.ErrNoRows {
  15. return errors.DataBaseError
  16. } else {
  17. return errors.ServiceError
  18. }
  19. }
  20. return nil
  21. }