From 4c30ca6f40b0b84a8f812001771d3a962335ccb0 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Tue, 18 Jun 2024 15:39:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=A0=E6=A1=A9=E5=8F=B7?= =?UTF-8?q?=E9=A2=84=E8=AD=A6CRUD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcNoStakeWarningTableController.java | 117 +++++++++++++++++ .../mapper/DcNoStakeWarningTableMapper.java | 14 ++ .../IDcNoStakeWarningTableService.java | 63 +++++++++ .../DcNoStakeWarningTableServiceImpl.java | 123 ++++++++++++++++++ 4 files changed, 317 insertions(+) create mode 100644 zc-business/src/main/java/com/zc/business/controller/DcNoStakeWarningTableController.java create mode 100644 zc-business/src/main/java/com/zc/business/mapper/DcNoStakeWarningTableMapper.java create mode 100644 zc-business/src/main/java/com/zc/business/service/IDcNoStakeWarningTableService.java create mode 100644 zc-business/src/main/java/com/zc/business/service/impl/DcNoStakeWarningTableServiceImpl.java diff --git a/zc-business/src/main/java/com/zc/business/controller/DcNoStakeWarningTableController.java b/zc-business/src/main/java/com/zc/business/controller/DcNoStakeWarningTableController.java new file mode 100644 index 00000000..278b1b08 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/DcNoStakeWarningTableController.java @@ -0,0 +1,117 @@ +package com.zc.business.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.zc.business.domain.DcFacility; +import com.zc.business.domain.DcNoStakeWarningTable; +import com.zc.business.service.IDcFacilityService; +import com.zc.business.service.IDcNoStakeWarningTableService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.List; + +/** + * 无桩号预警Controller + * + * @author zhaoxianglong + */ +@Api(tags = {"无桩号预警"}) +@RestController +@RequestMapping("/business/facility") +public class DcNoStakeWarningTableController extends BaseController { + @Resource + private IDcNoStakeWarningTableService dcNoStakeWarningTableService; + + //*********************************路网设施增删改查****************************************** + + /** + * 分页查询无桩号预警列表 + * + * @param dcNoStakeWarningTable 请求参数 + * @return 分页查询结果 + */ + @ApiOperation("分页查询路网设施列表") + @PreAuthorize("@ss.hasPermi('iot:facility:list')") + @GetMapping("list") + public TableDataInfo listFacility(DcNoStakeWarningTable dcNoStakeWarningTable) { + return getDataTable(dcNoStakeWarningTableService.pageDcNoStakeWarningTable(dcNoStakeWarningTable)); + } + + /** + * 无分页查询无桩号预警列表 + * + * @param dcNoStakeWarningTable 请求参数 + * @return 查询结果 + */ + @ApiOperation("无分页查询路网设施列表") + @PreAuthorize("@ss.hasPermi('iot:facility:query')") + @GetMapping("query") + public AjaxResult queryFacility(DcNoStakeWarningTable dcNoStakeWarningTable) { + return AjaxResult.success(dcNoStakeWarningTableService.listDcNoStakeWarningTable(dcNoStakeWarningTable)); + } + + /** + * 根据id查询无桩号预警信息 + * + * @param id id + * @return 查询结果 + */ + @ApiOperation("根据id查询路网设施信息") + @PreAuthorize("@ss.hasPermi('iot:facility:query')") + @GetMapping("{id}") + public AjaxResult getFacility(@PathVariable String id) { + return AjaxResult.success(dcNoStakeWarningTableService.getDcNoStakeWarningTable(id)); + } + + + /** + * 新增 + * + * @param dcNoStakeWarningTable 新增参数 + * @return 新增操作结果 + */ + @ApiOperation("新增") + @PreAuthorize("@ss.hasPermi('iot:facility:add')") + @Log(title = "新增路网设施", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult addFacility(@Valid @RequestBody DcNoStakeWarningTable dcNoStakeWarningTable) { + return toAjax(dcNoStakeWarningTableService.addDcNoStakeWarningTable(dcNoStakeWarningTable)); + } + + /** + * 修改 + * + * @param dcNoStakeWarningTable 修改参数 + * @return 修改操作结果 + */ + @ApiOperation("修改") + @PreAuthorize("@ss.hasPermi('iot:facility:edit')") + @Log(title = "修改路网设施", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult editFacility(@Valid @RequestBody DcNoStakeWarningTable dcNoStakeWarningTable) { + return toAjax(dcNoStakeWarningTableService.editDcNoStakeWarningTable(dcNoStakeWarningTable)); + } + + /** + * 删除 + * + * @param ids id集 + * @return 删除操作结果 + */ + @ApiOperation("删除") + @PreAuthorize("@ss.hasPermi('iot:facility:remove')") + @Log(title = "删除", businessType = BusinessType.DELETE) + @DeleteMapping("{ids}") + public AjaxResult removeFacility(@PathVariable List ids) { + return toAjax(dcNoStakeWarningTableService.removeDcNoStakeWarningTable(ids)); + } + +} diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcNoStakeWarningTableMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcNoStakeWarningTableMapper.java new file mode 100644 index 00000000..a892dd5b --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/mapper/DcNoStakeWarningTableMapper.java @@ -0,0 +1,14 @@ +package com.zc.business.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zc.business.domain.DcNoStakeWarningTable; +import org.apache.ibatis.annotations.Mapper; + +/** + * 无桩号预警Mapper接口 + * + * @author zhaoxianglong + */ +@Mapper +public interface DcNoStakeWarningTableMapper extends BaseMapper { +} diff --git a/zc-business/src/main/java/com/zc/business/service/IDcNoStakeWarningTableService.java b/zc-business/src/main/java/com/zc/business/service/IDcNoStakeWarningTableService.java new file mode 100644 index 00000000..cfe197f2 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/service/IDcNoStakeWarningTableService.java @@ -0,0 +1,63 @@ +package com.zc.business.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.zc.business.domain.DcNoStakeWarningTable; + +import java.util.List; + +/** + * 无桩号预警Service接口 + * + * @author zhaoxianglong + */ +public interface IDcNoStakeWarningTableService extends IService { + /** + * 添加无桩号预警 + * + * @param dcNoStakeWarningTable 设备信息 + * @return 操作结果 + */ + boolean addDcNoStakeWarningTable(DcNoStakeWarningTable dcNoStakeWarningTable); + + /** + * 修改无桩号预警 + * + * @param dcNoStakeWarningTable 设备信息 + * @return 操作结果 + */ + boolean editDcNoStakeWarningTable(DcNoStakeWarningTable dcNoStakeWarningTable); + + /** + * 删除无桩号预警 + * + * @param ids 设备ID + * @return 操作结果 + */ + boolean removeDcNoStakeWarningTable(List ids); + + /** + * 获取无桩号预警列表 + * + * @param dcNoStakeWarningTable 参数 + * @return 结果 + */ + List pageDcNoStakeWarningTable(DcNoStakeWarningTable dcNoStakeWarningTable); + + /** + * 获取无桩号预警列表 + * + * @param dcNoStakeWarningTable 参数 + * @return 结果 + */ + List listDcNoStakeWarningTable(DcNoStakeWarningTable dcNoStakeWarningTable); + + + /** + * 根据id查询设备信息 + * + * @param id 设备ID + * @return 设备信息 + */ + DcNoStakeWarningTable getDcNoStakeWarningTable(String id); +} diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcNoStakeWarningTableServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcNoStakeWarningTableServiceImpl.java new file mode 100644 index 00000000..71032c97 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcNoStakeWarningTableServiceImpl.java @@ -0,0 +1,123 @@ +package com.zc.business.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.PageUtils; +import com.zc.business.domain.DcFacility; +import com.zc.business.domain.DcNoStakeWarningTable; +import com.zc.business.mapper.DcFacilityMapper; +import com.zc.business.mapper.DcNoStakeWarningTableMapper; +import com.zc.business.service.IDcFacilityService; +import com.zc.business.service.IDcNoStakeWarningTableService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.Date; +import java.util.List; +import java.util.Objects; + +/** + * 无桩号预警Service业务层处理 + * + * @author zhaoxianglong + */ +@Service +public class DcNoStakeWarningTableServiceImpl extends ServiceImpl implements IDcNoStakeWarningTableService { + + public LambdaQueryWrapper noStakeWarningTableQueryWrapper(DcNoStakeWarningTable dcNoStakeWarningTable) { + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + // 设备ID + if (Objects.nonNull(dcNoStakeWarningTable.getId())) { + queryWrapper.eq(DcNoStakeWarningTable::getId, dcNoStakeWarningTable.getId()); + } + + // 设备ID + if (Objects.nonNull(dcNoStakeWarningTable.getWarningDescription())) { + queryWrapper.eq(DcNoStakeWarningTable::getWarningDescription, dcNoStakeWarningTable.getWarningDescription()); + } + + // 设备ID + if (Objects.nonNull(dcNoStakeWarningTable.getWarningTime())) { + queryWrapper.eq(DcNoStakeWarningTable::getWarningTime, dcNoStakeWarningTable.getWarningTime()); + } + + // 设备ID + if (Objects.nonNull(dcNoStakeWarningTable.getWarningType())) { + queryWrapper.eq(DcNoStakeWarningTable::getWarningType, dcNoStakeWarningTable.getWarningType()); + } + + // 设备ID + if (Objects.nonNull(dcNoStakeWarningTable.getCreateTime())) { + queryWrapper.eq(DcNoStakeWarningTable::getCreateTime, dcNoStakeWarningTable.getCreateTime()); + } + + // 木桩 + return queryWrapper; + } + + @Override + public boolean addDcNoStakeWarningTable(DcNoStakeWarningTable dcNoStakeWarningTable) { + + Long id = dcNoStakeWarningTable.getId(); + if (Objects.nonNull(id)) { + DcNoStakeWarningTable noStakeWarningTable = getById(id); + if (noStakeWarningTable != null) { + throw new ServiceException("预警ID[" + id + "]已存在", HttpStatus.BAD_REQUEST); + } + } + + dcNoStakeWarningTable.setCreateTime(new Date()); + return save(dcNoStakeWarningTable); + } + + @Override + public boolean editDcNoStakeWarningTable(DcNoStakeWarningTable dcNoStakeWarningTable) { + + Long id = dcNoStakeWarningTable.getId(); + + // 检查设备id是否重复 + DcNoStakeWarningTable noStakeWarningTable = getById(id); + + if (Objects.isNull(noStakeWarningTable)) { + throw new ServiceException("预警ID[" + id + "]不存在", HttpStatus.BAD_REQUEST); + } + + return updateById(dcNoStakeWarningTable); + } + + @Override + public boolean removeDcNoStakeWarningTable(List ids) { + return removeByIds(ids); + } + + @Override + public List pageDcNoStakeWarningTable(DcNoStakeWarningTable dcNoStakeWarningTable) { + // 分页 + PageUtils.startPage(); + return list(noStakeWarningTableQueryWrapper(dcNoStakeWarningTable)); + } + + @Override + public List listDcNoStakeWarningTable(DcNoStakeWarningTable dcNoStakeWarningTable) { + return list(noStakeWarningTableQueryWrapper(dcNoStakeWarningTable)); + } + + @Override + public DcNoStakeWarningTable getDcNoStakeWarningTable(String id) { + // 检查设备id是否重复 + DcNoStakeWarningTable dcNoStakeWarningTable = getById(id); + + if (Objects.isNull(dcNoStakeWarningTable)) { + throw new ServiceException("预警ID[" + id + "]不存在", HttpStatus.BAD_REQUEST); + } + + return getById(id); + } + +} +