package sys_payment

import (
	"context"

	"kami/api/commonApi"
	"kami/api/sys_payment/v1"
	"kami/internal/model"
	"kami/internal/model/entity"
	"kami/internal/service"
	"kami/utility/token"

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

func (c *ControllerV1) SysPaymentGet(ctx context.Context, req *v1.SysPaymentGetReq) (res *v1.SysPaymentGetRes, err error) {
	if !token.IsFromIframe(ctx) {
		return nil, gerror.NewCode(gcode.CodeNotSupported, "权限不足")
	}
	userPaymentService := service.SysUserPayment()
	total, list, err := userPaymentService.List(ctx, model.SysUserPaymentListInput{
		SysPaymentGetReq: *req,
	})
	res = &v1.SysPaymentGetRes{
		CommonPageRes: commonApi.CommonPageRes[*entity.V1SysUserPayment]{
			CommonDataRes: commonApi.CommonDataRes[*entity.V1SysUserPayment]{
				List: list,
			},
			Total: total,
		},
	}
	return
}
