upgradeoplogic.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package logic
  2. import (
  3. "context"
  4. "net/http"
  5. "dag-jupyter/internal/api"
  6. "dag-jupyter/internal/svc"
  7. "dag-jupyter/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type UpgradeOpLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewUpgradeOpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpgradeOpLogic {
  16. return &UpgradeOpLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *UpgradeOpLogic) UpgradeOp(req *types.CreateJupyterInfo) (resp *types.Response, err error) {
  23. req.Password = formatPassword(req.Password)
  24. err = api.Upgrade(req)
  25. data := map[string]interface{}{
  26. "namespace": req.Namespace,
  27. "release_name": req.ReleaseName,
  28. "base_url": req.BaseUrl,
  29. "image": req.Image,
  30. "host": req.Host,
  31. "tag": req.Tag,
  32. "path": req.Path,
  33. "workspace": req.Workspace,
  34. }
  35. if err != nil {
  36. return &types.Response{
  37. Data: err.Error(),
  38. Code: http.StatusBadRequest,
  39. }, nil
  40. }
  41. return &types.Response{
  42. Data: data,
  43. Code: http.StatusOK,
  44. }, nil
  45. return
  46. }