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.SystemSetting;
import com.nantian.cloud.jljc.service.SystemSettingService;
import com.nantian.sc.cloud.common.core.util.R;
import com.nantian.sc.cloud.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 节能波动等参数设置
 *
 * @author
 * @date 2018-09-27 15:20:44
 */
@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/systemSetting")
@Api(value = "systemSetting",tags = "节能波动等参数设置")
public class SystemSettingController {
	private final SystemSettingService systemSettingService;


	/**
	 * 分页查询
	 *
	 * @param page      分页对象
	 * @param systemSetting
	 * @return
	 */
	@GetMapping("/page")
	@SysLog("分页获取节能波动等参数设置")
	@ApiOperation(value = "分页获取节能波动等参数设置", notes = "分页获取节能波动等参数设置")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "分页对象", required = false, dataType = "json", paramType = "path"),
			@ApiImplicitParam(name = "systemSetting", value = "节能波动等参数设置对象", required = false, dataType = "json", paramType = "path")
	})
	public R getSystemSettingPage(Page page, SystemSetting systemSetting) {
		return R.ok(systemSettingService.page(page, Wrappers.query(systemSetting)));
	}


	/**
	 * 信息
	 *
	 * @param systemSettingId
	 * @return R
	 */
	@GetMapping("/{systemSettingId}")
	@SysLog("根据id获取节能波动等参数设置")
	@ApiOperation(value = "根据id获取节能波动等参数设置", notes = "根据id获取节能波动等参数设置")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R getById(@PathVariable("systemSettingId") Integer systemSettingId) {
		return R.ok(systemSettingService.getById(systemSettingId));
	}

	/**
	 * 保存
	 *
	 * @param systemSetting
	 * @return R
	 */
	@PostMapping
	@SysLog("新增节能波动等参数设置")
	@ApiOperation(value = "新增节能波动等参数设置", notes = "新增节能波动等参数设置")
	@ApiImplicitParam(name = "systemSetting", value = "节能波动等参数设置对象", required = true, dataType = "json", paramType = "path")
	public R save(@RequestBody SystemSetting systemSetting) {
		return R.ok(systemSettingService.save(systemSetting));
	}

	/**
	 * 修改
	 *
	 * @param systemSetting
	 * @return R
	 */
	@PutMapping
	@SysLog("修改节能波动等参数设置")
	@ApiOperation(value = "修改节能波动等参数设置", notes = "修改节能波动等参数设置")
	@ApiImplicitParam(name = "systemSetting", value = "节能波动等参数设置对象", required = true, dataType = "json", paramType = "path")
	public R updateById(@RequestBody SystemSetting systemSetting) {
		return R.ok(systemSettingService.updateById(systemSetting));
	}

	/**
	 * 删除
	 *
	 * @param systemSettingId
	 * @return R
	 */
	@DeleteMapping("/{systemSettingId}")
	@SysLog("删除节能波动等参数设置")
	@ApiOperation(value = "删除节能波动等参数设置", notes = "删除节能波动等参数设置")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R removeById(@PathVariable Integer systemSettingId) {
		return R.ok(systemSettingService.removeById(systemSettingId));
	}

}
