package sys_payment

import (
	"context"

	"kami/internal/errHandler"
	"kami/internal/model"
	"kami/internal/service"

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

	"kami/api/sys_payment/v1"
)

func (c *ControllerV1) SysPaymentGetOne(ctx context.Context, req *v1.SysPaymentGetOneReq) (res *v1.SysPaymentGetOneRes, err error) {
	_, err = service.SysAuth().LoginWithIFrameAndLogin(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeNotAuthorized, err, "权限不足")
		return
	}
	sysUserPayment := service.SysUserPayment()
	resData, err := sysUserPayment.GetDetailById(ctx, &model.SysUserPaymentGetOneInput{
		UserId:    req.UserId,
		PaymentId: req.PaymentId,
	})
	res = &v1.SysPaymentGetOneRes{
		V1SysUserPayment: resData,
	}
	return
}
