package com.nantian.cloud.jljc.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nantian.cloud.jljc.entity.DataCustomComparison;
import com.nantian.cloud.jljc.service.DataCustomComparisonService;
import com.nantian.sc.cloud.common.core.util.R;
import com.nantian.sc.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 数据自定义比对
 *
 * @author
 * @date 2018-09-27 15:20:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dataCustomComparison")
@CrossOrigin
@Api(value = "dataCustomComparison",tags = "数据自定义比对")
public class DataCustomComparisonController {
	private final DataCustomComparisonService dataCustomComparisonService;


	/**
	 * 分页查询
	 *
	 * @param page      分页对象
	 * @param dataCustomComparison
	 * @return
	 */
	@GetMapping("/page")
	@SysLog("分页获取数据自定义比对")
	@ApiOperation(value = "分页获取数据自定义比对", notes = "分页获取数据自定义比对")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "分页对象", required = false, dataType = "json", paramType = "path"),
			@ApiImplicitParam(name = "dataCustomComparison", value = "数据自定义比对对象", required = false, dataType = "json", paramType = "path")
	})
	public R getDataCustomComparisonPage(Page page, DataCustomComparison dataCustomComparison) {
		return R.ok(dataCustomComparisonService.page(page, Wrappers.query(dataCustomComparison)));
	}


	/**
	 * 信息
	 *
	 * @param dataCustomComparisonId
	 * @return R
	 */
	@GetMapping("/{dataCustomComparisonId}")
	@SysLog("根据id获取数据自定义比对")
	@ApiOperation(value = "根据id获取数据自定义比对", notes = "根据id获取数据自定义比对")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R getById(@PathVariable("dataCustomComparisonId") Integer dataCustomComparisonId) {
		return R.ok(dataCustomComparisonService.getById(dataCustomComparisonId));
	}

	/**
	 * 保存
	 *
	 * @param dataCustomComparison
	 * @return R
	 */
	@PostMapping
	@SysLog("新增数据自定义比对")
	@ApiOperation(value = "新增数据自定义比对", notes = "新增数据自定义比对")
	@ApiImplicitParam(name = "dataCustomComparison", value = "数据自定义比对对象", required = true, dataType = "json", paramType = "path")
	public R save(@RequestBody DataCustomComparison dataCustomComparison) {
		return R.ok(dataCustomComparisonService.save(dataCustomComparison));
	}

	/**
	 * 修改
	 *
	 * @param dataCustomComparison
	 * @return R
	 */
	@PutMapping
	@SysLog("修改数据自定义比对")
	@ApiOperation(value = "修改数据自定义比对", notes = "修改数据自定义比对")
	@ApiImplicitParam(name = "dataCustomComparison", value = "数据自定义比对对象", required = true, dataType = "json", paramType = "path")
	public R updateById(@RequestBody DataCustomComparison dataCustomComparison) {
		return R.ok(dataCustomComparisonService.updateById(dataCustomComparison));
	}

	/**
	 * 删除
	 *
	 * @param dataCustomComparisonId
	 * @return R
	 */
	@DeleteMapping("/{dataCustomComparisonId}")
	@SysLog("删除数据自定义比对")
	@ApiOperation(value = "删除数据自定义比对", notes = "删除数据自定义比对")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R removeById(@PathVariable Integer dataCustomComparisonId) {
		return R.ok(dataCustomComparisonService.removeById(dataCustomComparisonId));
	}

}
