package agent_base

import (
	"context"
	"github.com/suyuan32/simple-admin-common/msg/errormsg"
	"github.com/zeromicro/go-zero/core/errorx"
	"wechat-api/hook/fastgpt"

	"wechat-api/internal/svc"
	"wechat-api/internal/types"

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

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

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

func (l *DeleteAgentBaseLogic) DeleteAgentBase(req *types.DeleteDataReq) (*types.BaseDataInfo, error) {
	resp, err := fastgpt.DeleteData(*req.ID)
	if err != nil {
		return nil, errorx.NewInvalidArgumentError("fastgpt create data failed " + err.Error())
	}

	if resp.Code == 200 {
		return &types.BaseDataInfo{
			Code: 0,
			Msg:  errormsg.Success,
			Data: "",
		}, nil
	}

	return nil, errorx.NewInvalidArgumentError(resp.StatusText)
}
