package org.gyk.modules.sz.jdlbjpz.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.gyk.common.api.Result;
import org.gyk.modules.sz.jdlbjpz.entity.CxcSssjJldBjShezhi;
import org.gyk.modules.sz.jdlbjpz.service.ICxcSssjJldBjShezhiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

 /**
 * @Description: 计量点报警设置
 * @Author: jeecg-boot
 * @Date:   2023-09-21
 * @Version: V1.0
 */
 @CrossOrigin(origins = "*", maxAge = 3600)
@Api(tags="计量点报警设置")
@RestController
@RequestMapping("/cxcsssjjldbjshezhi/cxcSssjJldBjShezhi")
@Slf4j
public class CxcSssjJldBjShezhiController {
	@Autowired(required = false)
	private ICxcSssjJldBjShezhiService cxcSssjJldBjShezhiService;
	
	/**
	 * 分页列表查询
	 *
	 * @param cxcSssjJldBjShezhi
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	@ApiOperation(value="计量点报警设置-分页列表查询", notes="计量点报警设置-分页列表查询")
	@GetMapping(value = "/list")
	public Result<?> queryPageList(CxcSssjJldBjShezhi cxcSssjJldBjShezhi,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<CxcSssjJldBjShezhi> queryWrapper =new QueryWrapper<> ();
		Page<CxcSssjJldBjShezhi> page = new Page<CxcSssjJldBjShezhi>(pageNo, pageSize);
		IPage<CxcSssjJldBjShezhi> pageList = cxcSssjJldBjShezhiService.page(page, queryWrapper);
		return Result.ok(pageList);
	}
	
	/**
	 *   添加
	 *
	 * @param cxcSssjJldBjShezhi
	 * @return
	 */

	@ApiOperation(value="计量点报警设置-添加", notes="计量点报警设置-添加")
	@PostMapping(value = "/add")
	public Result<?> add(@RequestBody CxcSssjJldBjShezhi cxcSssjJldBjShezhi) {
		cxcSssjJldBjShezhiService.save(cxcSssjJldBjShezhi);
		return Result.ok("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param cxcSssjJldBjShezhi
	 * @return
	 */

	@ApiOperation(value="计量点报警设置-编辑", notes="计量点报警设置-编辑")
	@PutMapping(value = "/edit")
	public Result<?> edit(@RequestBody CxcSssjJldBjShezhi cxcSssjJldBjShezhi) {
		cxcSssjJldBjShezhiService.updateById(cxcSssjJldBjShezhi);
		return Result.ok("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */

	@ApiOperation(value="计量点报警设置-通过id删除", notes="计量点报警设置-通过id删除")
	@DeleteMapping(value = "/delete")
	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
		cxcSssjJldBjShezhiService.removeById(id);
		return Result.ok("删除成功!");
	}

}
