package com.newfiber.api.pc.controller.zhz; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; import com.newfiber.api.core.annotation.SysLog; import com.newfiber.api.core.commons.PageRequestObject; import com.newfiber.api.core.commons.PageResultObject; import com.newfiber.api.core.commons.ResultCode; import com.newfiber.api.core.commons.ResultObj; import com.newfiber.api.pc.model.entity.WarnLevelInfo; import com.newfiber.api.pc.service.WarnLevelInfoService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import java.util.List; /** * @ClassName WarnLevelInfoController * @Description TODO * @Author 张鸿志 * @Date sj 15:23 * Version 1.0 **/ @RestController @RequestMapping("/warnLevelInfo") @Api(value = "WarnLevelInfoController",tags = "预警启动级别基础信息控制层") public class WarnLevelInfoController { @Autowired private WarnLevelInfoService warnLevelInfoService; @PostMapping("/saveOrUpdate") @ApiOperation("新增或修改级别信息数据") @SysLog(actionType = "3",value = "新增或修改级别信息数据") public ResultObj saveWarnLevelInfo(@RequestBody WarnLevelInfo warnLevelInfo){ if(StringUtils.isEmpty(warnLevelInfo)){ return ResultObj.error("参数不能为空"); } warnLevelInfo.setIsDelete(0); if(warnLevelInfoService.insertOrUpdate(warnLevelInfo)){ return ResultObj.ok(); } return ResultObj.error("操作失败!"); } @PostMapping("/selectList") @ApiOperation("查询所有的信息数据,主要用于下拉列表中内容展示") @SysLog(actionType = "4",value = "查询所有的信息数据,主要用于下拉列表中内容展示") public ResultObj<List<WarnLevelInfo>> selectList(){ EntityWrapper<WarnLevelInfo> entityWrapper = new EntityWrapper<>(); entityWrapper.eq("is_delete",0); return new ResultObj<>(ResultCode.OK,warnLevelInfoService.selectList(entityWrapper)); } @PostMapping("/selectPageList") @ApiOperation("分页条件查询信息数据") @SysLog(actionType = "4",value = "分页条件查询信息数据") public ResultObj<PageResultObject<WarnLevelInfo>> selectPageList(@RequestBody PageRequestObject<String> pageRequestObject){ String levelName = pageRequestObject.getObject(); Integer current = pageRequestObject.getCurrent(); Integer size = pageRequestObject.getSize(); EntityWrapper<WarnLevelInfo> entityWrapper = new EntityWrapper<>(); if(!StringUtils.isEmpty(levelName)){ entityWrapper.like("level_name",levelName); } entityWrapper.eq("is_delete",0); Page<WarnLevelInfo> warnLevelInfoPage = warnLevelInfoService.selectPage(new Page<>(current, size), entityWrapper); int count = warnLevelInfoService.selectCount(entityWrapper); return new ResultObj<>(ResultCode.OK,new PageResultObject<>(count,size,(long)count,warnLevelInfoPage.getRecords())); } @PostMapping("/delete") @ApiOperation("删除预警级别数据") @SysLog(actionType = "2",value = "删除预警级别数据") public ResultObj deleteWarnLevel(@RequestParam("id") Integer id){ if(StringUtils.isEmpty(id)){ return ResultObj.error("参数不能为空!"); } WarnLevelInfo warnLevelInfo = warnLevelInfoService.selectById(id); warnLevelInfo.setIsDelete(1); if(warnLevelInfoService.updateById(warnLevelInfo)){ return ResultObj.ok(); } return ResultObj.error("删除失败!"); } }