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.AmountEnergySaving;
import com.nantian.cloud.jljc.service.AmountEnergySavingService;
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.*;

@RestController
@AllArgsConstructor
@RequestMapping("/AmountEnergySaving")
@Api(value = "AmountEnergySaving", tags = "企业报告截止日期")
@CrossOrigin
public class AmountEnergySavingController {

	private final AmountEnergySavingService amountEnergySavingService;

	/**
	 * 分页查询
	 *
	 * @param page      分页对象
	 * @param amountEnergySaving
	 * @return
	 */
	@GetMapping("/page")
	@SysLog("分页获取企业报告截止日期")
	@ApiOperation(value = "分页获取企业报告截止日期", notes = "分页获取企业报告截止日期")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "分页对象", required = false, dataType = "json", paramType = "path"),
			@ApiImplicitParam(name = "amountEnergySaving", value = "企业报告截止日期对象", required = false, dataType = "json", paramType = "path")
	})
	public R getDevInfoPage(Page page, AmountEnergySaving amountEnergySaving) {
		return R.ok(amountEnergySavingService.page(page, Wrappers.query(amountEnergySaving)));
	}

	/**
	 * 保存
	 *
	 * @param amountEnergySaving
	 * @return R
	 */
	@PostMapping
	@SysLog("新增企业报告截止日期")
	@ApiOperation(value = "新增企业报告截止日期", notes = "新增企业报告截止日期")
	@ApiImplicitParam(name = "amountEnergySaving", value = "企业报告截止日期对象", required = true, dataType = "json", paramType = "path")
	public R save(@RequestBody AmountEnergySaving amountEnergySaving) {
		return R.ok(amountEnergySavingService.save(amountEnergySaving));
	}

	/**
	 * 修改
	 *
	 * @param amountEnergySaving
	 * @return R
	 */
	@PutMapping
	@SysLog("修改企业报告截止日期")
	@ApiOperation(value = "修改企业报告截止日期", notes = "修改企业报告截止日期")
	@ApiImplicitParam(name = "amountEnergySaving", value = "修改报告截止日期对象", required = true, dataType = "json", paramType = "path")
	public R updateById(@RequestBody AmountEnergySaving amountEnergySaving) {
		return R.ok(amountEnergySavingService.updateById(amountEnergySaving));
	}

	/**
	 * 删除
	 *
	 * @param amountEnergysavingID
	 * @return R
	 */
	@DeleteMapping("/{amountEnergysavingID}")
	@SysLog("删除企业报告截止日期")
	@ApiOperation(value = "删除企业报告截止日期", notes = "删除企业报告截止日期")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R removeById(@PathVariable Integer amountEnergysavingID) {
		return R.ok(amountEnergySavingService.removeById(amountEnergysavingID));
	}

}
