package cn.axzo.msg.center.message.controller;

import cn.axzo.framework.rocketmq.Event;
import cn.axzo.msg.center.event.outer.PushYouMengMessageHandler;
import cn.axzo.msg.center.message.xxl.UpdateOuIdJob;
import com.alibaba.fastjson.JSONObject;
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.RestController;

import javax.validation.Valid;

@RestController
public class PrivateJobController {

    @Autowired
    private UpdateOuIdJob updateOuIdJob;
    @Autowired
    private PushYouMengMessageHandler pushYouMengMessageHandler;

    @PostMapping("private/ou/update")
    public Object updateOuIdJob(@RequestBody @Valid UpdateOuIdJob.UpdateOuIdParam req) throws Exception {
        return updateOuIdJob.execute(JSONObject.toJSONString(req));
    }

    @PostMapping("private/you-meng/push")
    public Object pushYouMeng(@RequestBody @Valid Event event) throws Exception {

        pushYouMengMessageHandler.onEvent(event,null);
        return null;
    }
}
