package cn.com.ctop.callback.controller;

import com.xxl.mq.client.message.XxlMqMessage;
import com.xxl.mq.client.producer.XxlMqProducer;
import org.jeecg.common.api.vo.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/")
public class CallbackController {
    @RequestMapping("/{group}/{topic}")
    @ResponseBody
    public Result<String> callbackMethod(HttpServletRequest request,
                                         HttpServletResponse response,
                                         @PathVariable(name = "group") String group,
                                         @PathVariable(name = "topic") String topic){
        Result<String> result = new Result<>();
        XxlMqProducer.produce(new XxlMqMessage(group+"_"+topic, request.getQueryString()));
        result.success("success");
        return result;
    }
}
