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.PrinterTemplateDTO;
import com.prolog.rdc.tms.model.vo.print.DeleteSysPrinterVO;
import com.prolog.rdc.tms.model.vo.print.PrinterTemplateVO;
import com.prolog.rdc.tms.model.vo.print.QuerySysPrinterTemplateVO;
import com.prolog.rdc.tms.service.print.PrinterTemplateService;

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

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

	@Autowired
	private PrinterTemplateService printerTemplateService;

	@UserLog("新增-打印机模版")
	@ApiOperation(value = "新增-打印机模版", notes = "新增-打印机模版")
	@PostMapping("/save")
	public RestMessage<Object> save(@RequestBody @Valid PrinterTemplateVO vo) {
		printerTemplateService.save(vo);
		return RestMessage.newInstance(true, "操作成功", null);
	}

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

	@UserLog("查询-打印机模版")
	@ApiOperation(value = "修改-打印机模版", notes = "修改-打印机模版")
	@PostMapping("/findList")
	public RestMessage<Page<PrinterTemplateDTO>> findList(@RequestBody @Valid QuerySysPrinterTemplateVO vo) throws Exception {
		Page<PrinterTemplateDTO> list = printerTemplateService.findList(vo);
		return RestMessage.newInstance(true, "操作成功", list);
	}

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

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