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

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.print.PrinterRouteDTO;
import com.prolog.rdc.tms.model.vo.print.DeleteSysPrinterVO;
import com.prolog.rdc.tms.model.vo.print.PrinterRouteVO;
import com.prolog.rdc.tms.model.vo.print.QuerySysPrinterRouteVO;
import com.prolog.rdc.tms.service.print.PrinterRouteService;

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

/**
 * 
 *
 * 打印路由控制层
 *
 * @className :PrinterRouteController
 * @author :fanzw
 * @creationTime :2022/11/21
 * @description :
 *
 * @modifier :fanzw
 * @modifyTime :2022/11/21
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Api(tags = "打印服务-打印路由控制层")
@RestController
@RequestMapping("/route")
public class PrinterRouteController {

	@Autowired
	private PrinterRouteService printerRouteService;

	@UserLog("新增-打印机路由")
	@ApiOperation(value = "新增-打印机路由", notes = "新增-打印机路由")
	@PostMapping("/save")
	public RestMessage<Object> save(@RequestBody @Valid PrinterRouteVO vo) {
		Long routeId = printerRouteService.save(vo);
		return RestMessage.newInstance(true, "操作成功", routeId);
	}

	@UserLog("修改-打印机路由")
	@ApiOperation(value = "修改-打印机路由", notes = "修改-打印机路由")
	@PostMapping("/update")
	public RestMessage<Object> update(@RequestBody @Valid PrinterRouteVO vo) {
		printerRouteService.update(vo);
		return RestMessage.newInstance(true, "操作成功", null);
	}

	@UserLog("查询-打印机配置")
	@ApiOperation(value = "修改-打印机配置", notes = "修改-打印机配置")
	@PostMapping("/findList")
	public RestMessage<Page<PrinterRouteDTO>> findList(@RequestBody QuerySysPrinterRouteVO vo) throws Exception {
		Page<PrinterRouteDTO> list = printerRouteService.findList(vo);
		return RestMessage.newInstance(true, "操作成功", list);
	}

	@UserLog("删除-打印机配置")
	@ApiOperation(value = "删除-打印机配置", notes = "删除-打印机配置")
	@PostMapping("/delete")
	public RestMessage<Object> delete(@RequestBody DeleteSysPrinterVO vo) {
		printerRouteService.delete(vo);
		return RestMessage.newInstance(true, "操作成功", null);
	}

	@UserLog("查询详情-打印机配置")
	@ApiOperation(value = "删除-打印机配置", notes = "删除-打印机配置")
	@GetMapping("/detail")
	public RestMessage<PrinterRouteDTO> detail(@RequestParam("id") Long id) throws Exception {
		PrinterRouteDTO model = printerRouteService.detail(id);
		return RestMessage.newInstance(true, "操作成功", model);
	}
}