delete_app_logic.go 990 B

123456789101112131415161718192021222324252627282930313233343536
  1. package fastgpt
  2. import (
  3. "context"
  4. "github.com/suyuan32/simple-admin-common/msg/errormsg"
  5. "github.com/zeromicro/go-zero/core/errorx"
  6. "wechat-api/internal/svc"
  7. "wechat-api/internal/types"
  8. apps "wechat-api/mongo_model/apps"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type DeleteAppLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewDeleteAppLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAppLogic {
  17. return &DeleteAppLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx}
  21. }
  22. func (l *DeleteAppLogic) DeleteApp(req *types.DeleteAppsReq) (resp *types.BaseMsgResp, err error) {
  23. appsModel := apps.NewAppsModel(l.svcCtx.Config.FastgptMongoConf.Url, l.svcCtx.Config.FastgptMongoConf.DBName, "apps")
  24. _, err = appsModel.Delete(context.TODO(), req.Id)
  25. if err != nil {
  26. return nil, errorx.NewInvalidArgumentError("fastgpt create failed " + err.Error())
  27. }
  28. return &types.BaseMsgResp{Msg: errormsg.Success}, nil
  29. }