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.IndustrySetting;
import com.nantian.cloud.jljc.service.IndustrySettingService;
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("/industrySetting")
@Api(value = "industrySetting",tags ="工业增加值率信息")
public class IndustrySettingController {
	private final IndustrySettingService industrySettingService;


	/**
	 * 分页查询
	 *
	 * @param page      分页对象
	 * @param industrySetting
	 * @return
	 */
	@GetMapping("/page")
	@SysLog("分页获取工业增加值率信息")
	@ApiOperation(value = "分页获取工业增加值率信息", notes = "分页获取工业增加值率信息")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "page", value = "分页对象", required = false, dataType = "json", paramType = "path"),
			@ApiImplicitParam(name = "industrySetting", value = "工业增加值率信息对象", required = false, dataType = "json", paramType = "path")
	})
	public R getIndustrySettingPage(Page page, IndustrySetting industrySetting) {
		industrySetting.setDelFlag("1"); //筛选未删除项
		return R.ok(industrySettingService.page(page, Wrappers.query(industrySetting)));
	}


	/**
	 * 信息
	 *
	 * @param industrySettingId
	 * @return R
	 */
	@GetMapping("/{industrySettingId}")
	@SysLog("根据id获取工业增加值率信息")
	@ApiOperation(value = "根据id获取工业增加值率信息", notes = "根据id获取工业增加值率信息")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R getById(@PathVariable("industrySettingId") Integer industrySettingId) {
		return R.ok(industrySettingService.getById(industrySettingId));
	}

	/**
	 * 保存
	 *
	 * @param industrySetting
	 * @return R
	 */
	@PostMapping
	@SysLog("新增工业增加值率信息")
	@ApiOperation(value = "新增工业增加值率信息", notes = "新增工业增加值率信息")
	@ApiImplicitParam(name = "industrySetting", value = "工业增加值率信息对象", required = true, dataType = "json", paramType = "path")
	public R save(@RequestBody IndustrySetting industrySetting) {
		return R.ok(industrySettingService.save(industrySetting));
	}

	/**
	 * 修改
	 *
	 * @param industrySetting
	 * @return R
	 */
	@PutMapping
	@SysLog("修改工业增加值率信息")
	@ApiOperation(value = "修改工业增加值率信息", notes = "修改工业增加值率信息")
	@ApiImplicitParam(name = "industrySetting", value = "工业增加值率信息对象", required = true, dataType = "json", paramType = "path")
	public R updateById(@RequestBody IndustrySetting industrySetting) {
		return R.ok(industrySettingService.updateById(industrySetting));
	}

	/**
	 * 删除
	 *
	 * @param industrySettingId
	 * @return R
	 */
	@DeleteMapping("/{industrySettingId}")
	@SysLog("删除工业增加值率信息")
	@ApiOperation(value = "删除工业增加值率信息", notes = "删除工业增加值率信息")
	@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
	public R removeById(@PathVariable Integer industrySettingId) {
		return R.ok(industrySettingService.removeById(industrySettingId));
	}

}
