package com.seer.teach.pay.api.order;

import com.seer.teach.pay.api.convert.PayOrderConvert;
import com.seer.teach.pay.api.order.dto.PayOrderCreateReqDTO;
import com.seer.teach.pay.entity.PayOrderEntity;
import com.seer.teach.pay.service.IPayOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Validated
@Slf4j
@RequiredArgsConstructor
public class PayOrderApiImpl implements PayOrderApi{

    private final IPayOrderService payOrderService;

    @Override
    public Integer createOrder(PayOrderCreateReqDTO reqDTO) {
        PayOrderEntity payOrderEntity = PayOrderConvert.INSTANCE.convertOne(reqDTO);
        Integer orderId = payOrderService.createOrder(payOrderEntity);
        log.info("创建的订单Id：{}", orderId);
        return orderId;
    }
}