update_app_logic.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 UpdateAppLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewUpdateAppLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateAppLogic {
  17. return &UpdateAppLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx}
  21. }
  22. func (l *UpdateAppLogic) UpdateApp(req *types.UpdateAppsReq) (resp *types.BaseMsgResp, err error) {
  23. intro := ""
  24. if req.Intro != nil {
  25. intro = *req.Intro
  26. }
  27. apps_info := &apps.Apps{
  28. ID: mustParseObjectID(req.Id),
  29. Name: req.Name,
  30. Intro: intro,
  31. }
  32. _, err = l.svcCtx.MongoModel.AppsModel.UpdateInfo(context.TODO(), apps_info)
  33. if err != nil {
  34. return nil, errorx.NewInvalidArgumentError("fastgpt create failed " + err.Error())
  35. }
  36. return &types.BaseMsgResp{Msg: errormsg.Success}, nil
  37. }