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

import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.pay.convert.refund.PayRefundConvert;
import com.tashow.cloud.pay.service.refund.PayRefundService;
import com.tashow.cloud.payapi.api.refund.PayRefundApi;
import com.tashow.cloud.payapi.api.refund.dto.PayRefundCreateReqDTO;
import com.tashow.cloud.payapi.api.refund.dto.PayRefundRespDTO;
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;


@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class PayRefundApiImpl implements PayRefundApi {

    @Resource
    private PayRefundService payRefundService;

    @Override
    public CommonResult<Long> createRefund(PayRefundCreateReqDTO reqDTO) {
        return success(payRefundService.createPayRefund(reqDTO));
    }

    @Override
    public CommonResult<PayRefundRespDTO> getRefund(Long id) {
        return success(PayRefundConvert.INSTANCE.convert02(payRefundService.getRefund(id)));
    }

}
