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.ChoozeEnterprise;
import com.nantian.cloud.jljc.service.ChoozeEnterpriseService;
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
 */
@CrossOrigin
@RestController
@AllArgsConstructor
@RequestMapping("/choozeEnterprise")
@Api(value="choozeEnterprise",tags = "万家企业节能目标设定")
public class ChoozeEnterpriseController {
	private final ChoozeEnterpriseService choozeEnterpriseService;


	/**
	 * 分页查询
	 *
	 * @param page      分页对象
	 * @param choozeEnterprise
	 * @return
	 */
	@GetMapping("/page")
	@SysLog("分页获取万家企业节能目标设定")
	@ApiOperation(value = "分页获取万家企业节能目标设定", notes = "分页获取万家企业节能目标设定")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "分页对象", required = false, dataType = "json", paramType = "path"),
			@ApiImplicitParam(name = "choozeEnterprise", value = "万家企业节能目标设定对象", required = false, dataType = "json", paramType = "path")
	})
	public R getChoozeEnterprisePage(Page page, ChoozeEnterprise choozeEnterprise) {
		return R.ok(choozeEnterpriseService.page(page, Wrappers.query(choozeEnterprise)));
	}

	/**
	 * 信息
	 *
	 * @param choozeEnterpriseId
	 * @return R
	 */
	@GetMapping("/{choozeEnterpriseId}")
	@SysLog("根据id获取万家企业节能目标设定")
	@ApiOperation(value = "根据id获取万家企业节能目标设定", notes = "根据id获取万家企业节能目标设定")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R getById(@PathVariable("choozeEnterpriseId") Integer choozeEnterpriseId) {
		return R.ok(choozeEnterpriseService.getById(choozeEnterpriseId));
	}

	/**
	 * 保存
	 *
	 * @param choozeEnterprise
	 * @return R
	 */
	@PostMapping
	@SysLog("新增万家企业节能目标设定")
	@ApiOperation(value = "新增万家企业节能目标设定", notes = "新增万家企业节能目标设定")
	@ApiImplicitParam(name = "choozeEnterprise", value = "万家企业节能目标设定对象", required = true, dataType = "json", paramType = "path")
	public R save(@RequestBody ChoozeEnterprise choozeEnterprise) {
		return R.ok(choozeEnterpriseService.save(choozeEnterprise));
	}

	/**
	 * 修改
	 *
	 * @param choozeEnterprise
	 * @return R
	 */
	@PutMapping
	@SysLog("修改万家企业节能目标设定")
	@ApiOperation(value = "修改万家企业节能目标设定", notes = "修改万家企业节能目标设定")
	@ApiImplicitParam(name = "choozeEnterprise", value = "万家企业节能目标设定对象", required = true, dataType = "json", paramType = "path")
	public R updateById(@RequestBody ChoozeEnterprise choozeEnterprise) {
		return R.ok(choozeEnterpriseService.updateById(choozeEnterprise));
	}

	/**
	 * 删除
	 *
	 * @param choozeEnterpriseId
	 * @return R
	 */
	@DeleteMapping("/{choozeEnterpriseId}")
	@SysLog("删除万家企业节能目标设定")
	@ApiOperation(value = "删除万家企业节能目标设定", notes = "删除万家企业节能目标设定")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R removeById(@PathVariable Integer choozeEnterpriseId) {
		return R.ok(choozeEnterpriseService.removeById(choozeEnterpriseId));
	}

}
