1234567891011121314151617181920212223242526272829303132 |
- package base_api
- import (
- "context"
- "gd_management/apis"
- "gd_management/impl/pubsub"
- "gd_management/common.in/utils"
- "github.com/astaxie/beego/orm"
- "go.uber.org/zap"
- )
- func ManagementSetBaseApiState(ctx context.Context, req *apis.ManagementSetBaseApiStateReq, reply *apis.ManagementSetBaseApiStateReply) (err error) {
- o := orm.NewOrm()
- _, err = o.Raw("update t_gd_api set enable=? where id=?", req.Enable, req.ApiId).Exec()
- if err != nil {
- l.Error("func",
- zap.String("call", "ManagementSetBaseApiState"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- }
- tab := apis.TGdApi{}
- err = o.QueryTable("t_gd_api").Filter("id", req.ApiId).One(&tab)
- if err == nil {
- utils.RedisSet("t_gd_api", tab.Method+"-"+tab.Router, tab)
- }
- pubsub.PublishApiNotify(req.ApiId, "", "")
- l.Debug(utils.MarshalJsonString(req, reply))
- return
- }
|