package jd_cookie

import (
	"context"
	"kami/api/jd_cookie/v1"
	"kami/internal/errHandler"
	"kami/internal/service"

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

func (c *ControllerV1) GetJdOrder(ctx context.Context, req *v1.GetJdOrderReq) (res *v1.GetJdOrderRes, err error) {
	_, err = service.SysAuth().LoginOnlyIFrame(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
		return
	}
	order, err := service.JdCookie().GetJdOrder(ctx, req.JdOrderId)
	if err != nil {
		return nil, err
	}

	res = &v1.GetJdOrderRes{
		Order: order,
	}

	return res, nil
}
