package thyyxxk.webserver.controller.outpatient.wxapi;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.outpatient.wxapi.QueryWxOrderParam;
import thyyxxk.webserver.entity.outpatient.wxapi.RefundParam;
import thyyxxk.webserver.service.outpatient.wxapi.WxApiService;
import thyyxxk.webserver.utils.ResultVoUtil;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author dj
 */
@RestController
@RequestMapping("/wxRefund")
public class WxApiController {
    private final WxApiService service;

    public WxApiController(WxApiService service) {
        this.service = service;
    }

    @PassToken
    @PostMapping("/selectOrdersByConditions")
    public ResultVo<Map<String, Object>> selectOrdersByConditions(@RequestBody @Validated QueryWxOrderParam param) {
        return service.selectOrdersByConditions(param);
    }

    @PassToken
    @PostMapping("/refundOrder")
    public ResultVo<String> refundOrder(@RequestBody @Validated RefundParam param) throws Exception {
        return ResultVoUtil.success(service.refundOrder(param));
    }

    @PostMapping("/exportExcel")
    public void exportExcel(HttpServletResponse response, @RequestBody @Validated QueryWxOrderParam param) {
        service.exportExcel(response, param);
    }
}
