package camel_oil

import (
	"context"

	"github.com/gogf/gf/v2/errors/gcode"
	v1 "kami/api/camel_oil/v1"
	"kami/internal/errHandler"
	"kami/internal/model"
	"kami/internal/service"
)

func (c *ControllerV1) DeleteToken(ctx context.Context, req *v1.DeleteTokenReq) (res *v1.DeleteTokenRes, err error) {
	_, err = service.SysAuth().LoginOnlyLogin(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "登录校验失败")
		return
	}
	err = service.CamelOil().DeleteToken(ctx, &model.CamelOilTokenDeleteInput{
		TokenId: req.TokenId,
	})
	if err != nil {
		return nil, err
	}
	return &v1.DeleteTokenRes{
		Message: "Token deleted successfully",
	}, nil
}
