package com.zm.order.tool.server.controller;

import com.zm.order.tool.server.request.OrderDataReviseRequest;
import com.zm.order.tool.server.service.ExceptionConstants;
import com.zm.order.tool.server.service.RefundService;
import com.zm.util.dto.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @packageName: com.zm.order.tool.server.controller
 * @className: RefundController
 * @author zhuxiaofeng
 * @date 2022/11/22 10:39
 */
@Api(value = "退款数据", tags = "退款数据")
@RestController
@SuppressWarnings("all")
@RequestMapping("/qapi/refund/")
public class RefundController {

    private static final Logger logger = LoggerFactory.getLogger(RefundController.class);

    @Autowired
    private RefundService service;

    @ApiOperation("历史退款数据同步ES")
    @RequestMapping(value = "/sync/es", method = RequestMethod.POST)
    public Result refundSyncEs(@RequestBody OrderDataReviseRequest request) {
        logger.info("refundSyncEs start!");
        Result result = new Result<>();
        try {
            service.syncEs();
        } catch (Exception e) {
            logger.error("RefundController[refundSyncEs]failed,request:{},cause by: {}", request, e);
            result.setException(ExceptionConstants.SYSTEM_ERROR);
        }
        return result;
    }
}
