base_api_state.go 886 B

1234567891011121314151617181920212223242526272829303132
  1. package base_api
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/impl/pubsub"
  6. "gd_management/common.in/utils"
  7. "github.com/astaxie/beego/orm"
  8. "go.uber.org/zap"
  9. )
  10. func ManagementSetBaseApiState(ctx context.Context, req *apis.ManagementSetBaseApiStateReq, reply *apis.ManagementSetBaseApiStateReply) (err error) {
  11. o := orm.NewOrm()
  12. _, err = o.Raw("update t_gd_api set enable=? where id=?", req.Enable, req.ApiId).Exec()
  13. if err != nil {
  14. l.Error("func",
  15. zap.String("call", "ManagementSetBaseApiState"),
  16. zap.String("args", utils.MarshalJsonString(req)),
  17. zap.String("error", err.Error()))
  18. }
  19. tab := apis.TGdApi{}
  20. err = o.QueryTable("t_gd_api").Filter("id", req.ApiId).One(&tab)
  21. if err == nil {
  22. utils.RedisSet("t_gd_api", tab.Method+"-"+tab.Router, tab)
  23. }
  24. pubsub.PublishApiNotify(req.ApiId, "", "")
  25. l.Debug(utils.MarshalJsonString(req, reply))
  26. return
  27. }