package com.prolog.rdc.tms.controller;

import java.util.List;

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.ShipbillOperateLogDTO;
import com.prolog.rdc.tms.model.vo.ShipbillOperateLogListVO;
import com.prolog.rdc.tms.model.vo.ShipbillOperateLogSaveNewVO;
import com.prolog.rdc.tms.model.vo.ShipbillOperateLogSaveVO;
import com.prolog.rdc.tms.service.ShipbillOperateLogService;

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

/**
 * 运单日志控制层
 *
 * Company: 湖北普罗格科技股份有限公司
 *
 * @author zhangsj
 * @since 2022/3/31 14:43
 */
@RestController
@Api(tags = "运单日志控制层")
@RequestMapping("/operateLog")
public class ShipbillOperateLogController {

	@Autowired
	private ShipbillOperateLogService service;

	@UserLog("运单操作日志查看")
	@ApiOperation(value = "运单操作日志查看", notes = "运单操作日志查看")
	@PostMapping("/list")
	public RestMessage<List<ShipbillOperateLogDTO>> listShipbillOperateLogExecute(@RequestBody ShipbillOperateLogListVO shipbillOperateLogListVO) {
		try {
			List<ShipbillOperateLogDTO> list = service.listShipbillOperateLogData(shipbillOperateLogListVO);
			return RestMessage.newInstance(true, "查询成功！", list);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("运单操作日志新增")
	@ApiOperation(value = "运单操作日志新增", notes = "运单操作日志新增")
	@PostMapping("/add")
	public RestMessage<Object> addShipbillOperateLogExecute(@RequestBody ShipbillOperateLogSaveVO vo) {
		try {
			service.addShipbillOperateLogData(vo);
			return RestMessage.newInstance(true, "新增成功！", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("运单操作日志新增(新)")
	@ApiOperation(value = "运单操作日志新增(新)", notes = "运单操作日志新增(新)")
	@PostMapping("/add_new")
	public RestMessage<Object> addShipbillOperateLogNewExecute(@RequestBody ShipbillOperateLogSaveNewVO vo) {
		try {
			service.addShipbillOperateLogNewData(vo);
			return RestMessage.newInstance(true, "新增成功！", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}
}
