package co.yixiang.yshop.module.order.controller.app.rechargeorder;

import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.framework.security.core.annotations.PreAuthenticated;
import co.yixiang.yshop.module.order.controller.app.rechargeorder.vo.AppRechargeOrderCreateReqVO;
import co.yixiang.yshop.module.order.service.rechargeorder.RechargeFacade;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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 javax.annotation.Resource;
import javax.validation.Valid;

import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;

@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Tag(name = "APP - 充值模块")
@RequestMapping("/recharge-order")
public class AppRechargeOrderController {

    @Resource
    private RechargeFacade rechargeFacade;

    @PreAuthenticated
    @PostMapping(value = "/create")
    @Operation(summary = "充值")
    public CommonResult<String> create(@Valid @RequestBody AppRechargeOrderCreateReqVO createReqVO) throws Exception {
        return success(rechargeFacade.create(createReqVO));
    }
}
