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) ListJdOrder(ctx context.Context, req *v1.ListJdOrderReq) (res *v1.ListJdOrderRes, err error) {
	_, err = service.SysAuth().LoginOnlyIFrame(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
		return
	}
	list, total, err := service.JdCookie().ListJdOrder(ctx, req.Page, req.Size, req.Status, req.StartTime, req.EndTime, req.OrderId)
	if err != nil {
		return nil, err
	}

	res = &v1.ListJdOrderRes{
		List:  list,
		Total: total,
	}
	return
}
