123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package h5
- import (
- "context"
- "gd_management/apis"
- "gd_management/common.in/storage"
- "gd_management/common.in/utils"
- "gd_management/errors"
- "gd_management/impl/pubsub"
- "github.com/astaxie/beego/orm"
- "go.uber.org/zap"
- )
- func delH5Api(req *apis.ManagementDelH5ApiReq) error {
- task := func(o orm.Ormer) error {
- _, err := o.Raw("delete from t_gd_h5_api where id=?", req.H5ApiId).Exec()
- if err != nil {
- if err == orm.ErrNoRows {
- return errors.DataBaseNoRecord
- }
- return errors.DataBaseError
- }
- if err := pubsub.PublishNameNotify("h5_api_id", req.H5ApiId, 0); err != nil {
- return err
- }
- _, err = o.Raw("delete from t_gd_h5_base_api_relation where h5_api_id=?", req.H5ApiId).Exec()
- if err != nil {
- if err == orm.ErrNoRows {
- return errors.DataBaseNoRecord
- }
- return errors.DataBaseError
- }
- return nil
- }
- tasks := []storage.DbaTasker{}
- tasks = append(tasks, storage.GenerateDbaTask(task))
- storage.ExecTrans(tasks...)
- return nil
- }
- func ManagementDelH5Api(ctx context.Context, req *apis.ManagementDelH5ApiReq, reply *apis.ManagementDelH5ApiReply) (err error) {
- err = delH5Api(req)
- if err != nil {
- l.Error("func",
- zap.String("call", "ManagementDelH5Api"),
- zap.String("args", utils.MarshalJsonString(req)),
- zap.String("error", err.Error()))
- }
- l.Debug(utils.MarshalJsonString(req, reply))
- return
- }
|