package com.tashow.cloud.pay.api.transfer;

import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.common.util.object.BeanUtils;
import com.tashow.cloud.pay.dal.dataobject.transfer.PayTransferDO;
import com.tashow.cloud.pay.service.transfer.PayTransferService;
import com.tashow.cloud.payapi.api.transfer.PayTransferApi;
import com.tashow.cloud.payapi.api.transfer.dto.PayTransferCreateReqDTO;
import com.tashow.cloud.sdk.payment.dto.transfer.PayTransferRespDTO;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static com.tashow.cloud.common.pojo.CommonResult.success;


/**
 * 转账单 API 实现类
 *
 * @author jason
 */
@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class PayTransferApiImpl implements PayTransferApi {

    @Resource
    private PayTransferService payTransferService;

    @Override
    public CommonResult<Long> createTransfer(PayTransferCreateReqDTO reqDTO) {
        return success(payTransferService.createTransfer(reqDTO));
    }

    @Override
    public CommonResult<PayTransferRespDTO> getTransfer(Long id) {
        PayTransferDO transfer = payTransferService.getTransfer(id);
        return success(BeanUtils.toBean(transfer, PayTransferRespDTO.class));
    }

}
