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

import java.util.List;

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.PrinterBatchConfigInfoDTO;
import com.prolog.rdc.tms.model.dto.print.PrinterConfigInfoDTO;
import com.prolog.rdc.tms.model.dto.print.PrinterConfigurationDTO;
import com.prolog.rdc.tms.model.vo.print.DeleteSysPrinterVO;
import com.prolog.rdc.tms.model.vo.print.PrinterBatchConfigInfoVO;
import com.prolog.rdc.tms.model.vo.print.PrinterConfigInfoVO;
import com.prolog.rdc.tms.model.vo.print.PrinterConfigurationVO;
import com.prolog.rdc.tms.model.vo.print.QuerySysPrinterConfigurationVO;
import com.prolog.rdc.tms.service.print.PrinterConfigurationService;

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

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

	@Autowired
	private PrinterConfigurationService printerConfigurationService;

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

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

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

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

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

	@UserLog("下拉-打印机配置")
	@ApiOperation(value = "下拉-打印机配置", notes = "下拉-打印机配置")
	@GetMapping("/dropDown")
	public RestMessage<List<PrinterConfigurationDTO>> dropDownList(@RequestParam("printerName") String printerName) throws Exception {
		List<PrinterConfigurationDTO> list = printerConfigurationService.dropDownList(printerName);
		return RestMessage.newInstance(true, "操作成功", list);
	}

	@UserLog("提供打印接口")
	@ApiOperation(value = "提供打印接口", notes = "提供打印接口")
	@PostMapping("/queryPrinterInfo")
	public RestMessage<PrinterConfigInfoDTO> queryPrinterInfo(@RequestBody PrinterConfigInfoVO printerConfigInfoVO) throws Exception {
		PrinterConfigInfoDTO model = printerConfigurationService.queryPrinterInfo(printerConfigInfoVO);
		return RestMessage.newInstance(true, "操作成功", model);
	}

	@UserLog("提供批量打印接口")
	@ApiOperation(value = "提供批量打印接口", notes = "提供批量打印接口")
	@PostMapping("/queryBatchPrinterInfo")
	public RestMessage<PrinterBatchConfigInfoDTO> queryBatchPrinterInfo(@RequestBody PrinterBatchConfigInfoVO printerConfigInfoVO) throws Exception {
		PrinterBatchConfigInfoDTO model = printerConfigurationService.queryBatchPrinterInfo(printerConfigInfoVO);
		return RestMessage.newInstance(true, "操作成功", model);
	}
}