package cn.van.business.controller.jd;

import cn.van.business.mq.MessageProducerService;
import cn.van.business.util.JDUtils;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Leo
 * @version 1.0
 * @create 2024/11/7 13:39
 * @description：
 */
@RestController
@RequestMapping("order")
public class OrderController {

    public static String TOKEN = "cc0313";
    @Resource
    private JDUtils jdUtils;
    @Resource
    private MessageProducerService messageProducerService;

    public boolean checkToken(String token) {
        return TOKEN.equals(token);
    }

    @RequestMapping("/refreshHistory")
    @ResponseBody
    public String refreshHistory(String token) throws Exception {
        if (checkToken(token)) {
            jdUtils.fetchHistoricalOrders3090();
        }
        return "OK";
    }

    @RequestMapping("/mq")
    @ResponseBody
    public String mq() {
        JSONObject jsonObject = new JSONObject();
        messageProducerService.sendMessage(jsonObject);
        return "OK";
    }

}
