package logic

import (
	"context"
	"net/http"

	"dag-jupyter/internal/api"
	"dag-jupyter/internal/svc"
	"dag-jupyter/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type StatusOpLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewStatusOpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StatusOpLogic {
	return &StatusOpLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *StatusOpLogic) StatusOp(req *types.ReleaseInfo) (resp *types.Response, err error) {
	data, err := api.Status(req)
	if err != nil {
		return &types.Response{
			Data: []*types.ReleaseStatus{},
			Code: http.StatusBadRequest,
		}, err
	}

	return &types.Response{
		Data: data,
		Code: http.StatusOK,
	}, nil
}
