fix: 塘口绑定设备bug修复。
This commit is contained in:
@@ -442,14 +442,10 @@ public class PondController extends BaseController {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<Void> selectDeviceOrSwitch(
|
||||
@Validated @RequestBody PondSelectDeviceOrSwitchBo request) {
|
||||
|
||||
// 获取当前登录用户ID
|
||||
Long userId = LoginHelper.getUserId();
|
||||
|
||||
// 查询塘口信息并验证权限
|
||||
Pond pond = pondMapper.selectById(request.getPondId());
|
||||
if (pond == null || !pond.getUserId().equals(userId)) {
|
||||
return R.fail("塘口不存在或无权限访问");
|
||||
if (pond == null) {
|
||||
return R.fail("塘口不存在");
|
||||
}
|
||||
|
||||
// 处理空列表
|
||||
@@ -898,19 +894,19 @@ public class PondController extends BaseController {
|
||||
.eq(LinkedCtrl::getDeviceId, request.getId())
|
||||
.select(LinkedCtrl::getId)
|
||||
);
|
||||
|
||||
|
||||
if (!linkedCtrls.isEmpty()) {
|
||||
List<Long> linkedCtrlIds = linkedCtrls.stream()
|
||||
.map(LinkedCtrl::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
// 2. 解除关联的开关绑定
|
||||
deviceSwitchMapper.update(null,
|
||||
new LambdaUpdateWrapper<DeviceSwitch>()
|
||||
.set(DeviceSwitch::getLinkedCtrlId, null)
|
||||
.in(DeviceSwitch::getLinkedCtrlId, linkedCtrlIds)
|
||||
);
|
||||
|
||||
|
||||
// 3. 删除联动控制记录
|
||||
linkedCtrlMapper.delete(
|
||||
new LambdaQueryWrapper<LinkedCtrl>()
|
||||
|
||||
Reference in New Issue
Block a user