package card_info_jd

import (
	"context"
	"kami/internal/consts"
	"kami/internal/errHandler"
	"kami/internal/service"

	"github.com/gogf/gf/v2/errors/gcode"

	"kami/api/card_info_jd/v1"
)

func (c *ControllerV1) JDAccountDelete(ctx context.Context, req *v1.JDAccountDeleteReq) (res *v1.JDAccountDeleteRes, err error) {
	_, err = service.SysAuth().LoginOnlyIFrame(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
		return
	}
	accountService := service.CardRedeemAccount()
	err = accountService.Delete(ctx, req.ID, consts.CardRedeemAccountCategoryJD, nil)
	return
}
