|
|
@@ -1,8 +1,11 @@
|
|
|
package com.zksy.web.controller.gasbasic;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.zksy.base.domain.ManholeBase;
|
|
|
+import com.zksy.base.domain.ManholeDeviceRel;
|
|
|
import com.zksy.base.dto.ManholePageInDTO;
|
|
|
+import com.zksy.base.mapper.ManholeDeviceRelMapper;
|
|
|
import com.zksy.base.service.ManholeBaseService;
|
|
|
import com.zksy.common.annotation.Anonymous;
|
|
|
import com.zksy.common.annotation.Log;
|
|
|
@@ -14,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/api/manhole")
|
|
|
@@ -23,6 +28,9 @@ public class GasManholeController {
|
|
|
@Autowired
|
|
|
private ManholeBaseService service;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ManholeDeviceRelMapper deviceRelMapper;
|
|
|
+
|
|
|
@GetMapping("/findByPage")
|
|
|
@ApiOperation("窨井分页查询")
|
|
|
@Anonymous
|
|
|
@@ -76,4 +84,46 @@ public class GasManholeController {
|
|
|
boolean deleted = service.removeById(id);
|
|
|
return deleted ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
|
|
|
}
|
|
|
+
|
|
|
+ // ============ 窨井-设备关联 ============
|
|
|
+
|
|
|
+ @GetMapping("/device/list/{manholeId}")
|
|
|
+ @ApiOperation("获取窨井关联的设备列表")
|
|
|
+ @Anonymous
|
|
|
+ public AjaxResult listDevices(@PathVariable String manholeId) {
|
|
|
+ LambdaQueryWrapper<ManholeDeviceRel> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(ManholeDeviceRel::getManholeId, manholeId);
|
|
|
+ wrapper.orderByDesc(ManholeDeviceRel::getCreateTime);
|
|
|
+ List<ManholeDeviceRel> list = deviceRelMapper.selectList(wrapper);
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/device/save")
|
|
|
+ @ApiOperation("关联设备到窨井")
|
|
|
+ @Anonymous
|
|
|
+ public AjaxResult saveDeviceRel(@RequestBody ManholeDeviceRel rel) {
|
|
|
+ boolean saved = deviceRelMapper.insert(rel) > 0;
|
|
|
+ return saved ? AjaxResult.success("关联成功") : AjaxResult.error("关联失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/device/save-batch")
|
|
|
+ @ApiOperation("批量关联设备到窨井")
|
|
|
+ @Anonymous
|
|
|
+ public AjaxResult saveDeviceRelBatch(@RequestBody List<ManholeDeviceRel> relList) {
|
|
|
+ if (relList == null || relList.isEmpty()) {
|
|
|
+ return AjaxResult.error("关联列表不能为空");
|
|
|
+ }
|
|
|
+ for (ManholeDeviceRel rel : relList) {
|
|
|
+ deviceRelMapper.insert(rel);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("批量关联成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/device/delete")
|
|
|
+ @ApiOperation("删除窨井设备关联")
|
|
|
+ @Anonymous
|
|
|
+ public AjaxResult deleteDeviceRel(@RequestParam Long relId) {
|
|
|
+ boolean deleted = deviceRelMapper.deleteById(relId) > 0;
|
|
|
+ return deleted ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
|
|
|
+ }
|
|
|
}
|