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

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.vo.message.MessageJobVO;
import com.prolog.rdc.tms.service.message.SendMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 javax.validation.Valid;

/**
 * @author hongbo.pan
 * @date 2022/11/15
 */
@RestController
@Api(tags = "消息任务控制层")
@RequestMapping("/messageJob")
public class MessageJobController {

	@Autowired
	private SendMessageService sendMessageService;

	@UserLog("未及时提货")
	@ApiOperation(httpMethod = "POST", value = "未及时提货")
	@PostMapping(value = "/sendPickUpMessage")
	public RestMessage<Object> sendPickUpMessage(@RequestBody @Valid MessageJobVO vo) {
		sendMessageService.sendPickUpMessage(vo);
		return RestMessage.newInstance(true, "操作成功", null);
	}

	@UserLog("未及时送达")
	@ApiOperation(httpMethod = "POST", value = "未及时送达")
	@PostMapping(value = "/sendDeliveryMessage")
	public RestMessage<Object> sendDeliveryMessage(@RequestBody @Valid MessageJobVO vo) {
		sendMessageService.sendDeliveryMessage(vo);
		return RestMessage.newInstance(true, "操作成功", null);
	}

	@UserLog("未及时纸质回单")
	@ApiOperation(httpMethod = "POST", value = "未及时纸质回单")
	@PostMapping(value = "/sendReceiptMessage")
	public RestMessage<Object> sendReceiptMessage(@RequestBody @Valid MessageJobVO vo) {
		sendMessageService.sendReceiptMessage(vo);
		return RestMessage.newInstance(true, "操作成功", null);
	}

	@UserLog("温度预警")
	@ApiOperation(httpMethod = "POST", value = "温度预警")
	@PostMapping(value = "/sendTemperatureMessage")
	public RestMessage<Object> sendTemperatureMessage(@RequestBody @Valid MessageJobVO vo) {
		sendMessageService.sendTemperatureMessage(vo);
		return RestMessage.newInstance(true, "操作成功", null);
	}
}
