package org.wfc.payment.pay.ccpay.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wfc.payment.pay.ccpay.mapper.UCreditCardTokenMapper;
import org.wfc.payment.pay.ccpay.model.PaymentRequest;
import org.wfc.payment.pay.ccpay.model.UCreditCardToken;
import org.wfc.payment.pay.ccpay.service.IUCreditCardTokenService;

@Service
public class UCreditCardTokenServiceImpl implements IUCreditCardTokenService {

    private final UCreditCardTokenMapper tokenMapper;

    @Autowired
    public UCreditCardTokenServiceImpl(UCreditCardTokenMapper tokenMapper) {
        this.tokenMapper = tokenMapper;
    }

    @Override
    public void saveToken(UCreditCardToken token) {
        tokenMapper.insertToken(token);
    }

    @Override
    public UCreditCardToken getTokenByUserId(Long userId) {
        return tokenMapper.selectTokenByUserId(userId);
    }

    @Override
    public String getPaymentToken(PaymentRequest paymentRequest) {
        return paymentRequest.getToken();
    }
}