package com.prolog.rdc.tms.controller.message;

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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.message.SendMessageDTO;
import com.prolog.rdc.tms.service.message.SendMessageService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author hongbo.pan
 * @date 2022/11/15
 */
@RestController
@Api(tags = "发送消息控制层")
@RequestMapping("/sendMessage")
public class SendMessageController {

	@Autowired
	private SendMessageService sendMessageService;

	@UserLog("发送消息")
	@ApiOperation(httpMethod = "POST", value = "发送消息")
	@PostMapping(value = "/send")
	public RestMessage<Object> send(@RequestBody SendMessageDTO dto) {
		sendMessageService.send(dto);
		return RestMessage.newInstance(true, "操作成功", null);
	}

	@UserLog("发送消息测试用")
	@ApiOperation(httpMethod = "POST", value = "发送消息测试用")
	@PostMapping(value = "/sendLocal")
	public RestMessage<Object> sendLocal(@RequestBody SendMessageDTO dto) {
		sendMessageService.sendLocal(dto);
		return RestMessage.newInstance(true, "操作成功", null);
	}

}
