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

import javax.validation.Valid;

import com.prolog.rdc.tms.model.vo.ImportLogUpdateVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.product.core.framework.controller.BaseController;
import com.prolog.rdc.tms.model.dto.basicConfigure.ImportLogPageDTO;
import com.prolog.rdc.tms.model.vo.basicConfigure.ImportDataCheckPageVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.ImportLogAddVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.ImportLogPageVO;
import com.prolog.rdc.tms.service.basicConfigure.ImportLogService;

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

/**
 *
 * 日志管理-导入日志控制层
 *
 *
 * @className: ImportLogController
 * @author: kh
 * @creationTime: 2022-01-12 10:12:37
 * @description:
 * @modifier:
 * @modifyTime:
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@RestController
@Api(tags = "日志管理-导入日志控制层")
@RequestMapping("/import_log")
public class ImportLogController extends BaseController {

	@Autowired
	private ImportLogService importLogService;

	@UserLog("导入日志分页查询")
	@ApiOperation(httpMethod = "POST", value = "导入日志分页查询")
	@PostMapping(value = "/page")
	public RestMessage<Page<ImportLogPageDTO>> pageImportLogExecute(@RequestBody ImportLogPageVO importLogPageVO) {
		Page<ImportLogPageDTO> importLogPageDTOs = importLogService.pageImportLogData(importLogPageVO);
		return RestMessage.newInstance(true, "查询成功", importLogPageDTOs);
	}

	@UserLog("导入日志保存")
	@ApiOperation(httpMethod = "POST", value = "导入日志保存")
	@PostMapping(value = "/add")
	public RestMessage<String> addImportLogExecute(@RequestBody ImportLogAddVO importLogAddVO) {
		importLogService.addImportLogData(importLogAddVO);
		return RestMessage.newInstance(true, "保存成功", null);
	}

	@UserLog("导入日志更新")
	@ApiOperation(httpMethod = "POST", value = "导入日志更新")
	@PostMapping(value = "/update")
	public RestMessage<String> updateImportLogData(@RequestBody ImportLogUpdateVO updateVO) {
		importLogService.updateImportLogData(updateVO);
		return RestMessage.newInstance(true, "更新成功", null);
	}

	@UserLog("撤销导入")
	@ApiOperation(value = "撤销导入", notes = "撤销导入")
	@GetMapping(value = "/revoke/{id}")
	public RestMessage<String> revokeExecute(@PathVariable("id") String id) throws Exception {
		importLogService.revokeData(id);
		return RestMessage.newInstance(true, "操作成功", null);
	}

	@UserLog("导入数据查看")
	@ApiOperation(httpMethod = "", value = "导入数据查看", notes = "导入数据查看")
	@PostMapping(value = "/check")
	public RestMessage<Object> pageImportdCheckExecute(@RequestBody @Valid ImportDataCheckPageVO ImportDataCheckPageVO) {
		return importLogService.pageImportdCheckData(ImportDataCheckPageVO);
	}
}
