package org.springblade.pay.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R;
import org.springblade.pay.entity.OrderDto;
import org.springblade.pay.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/pay")
@Api(tags = "支付模块")
public class PayController {
	@Autowired
	private PayService payService;

	@PostMapping("/initOrder")
	@ApiOperation("下单接口")
	public R initOrder(@RequestBody @Validated OrderDto orderDto){
		Map<String, Object> requestParams = payService.getRequestParams(orderDto);
		payService.payOrder(requestParams);
		return R.data("");
	}
}
