|
|
|
|
@ -55,9 +55,10 @@ import java.util.stream.Collectors; |
|
|
|
|
public class DeviceTypeController extends BladeController { |
|
|
|
|
|
|
|
|
|
private final IDeviceTypeService typeService; |
|
|
|
|
private final IDeviceService deviceService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设备表 详情 |
|
|
|
|
* 详情 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/detail") |
|
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
|
@ -83,7 +84,7 @@ public class DeviceTypeController extends BladeController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设备表 新增或修改 |
|
|
|
|
* 新增或修改 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/submit") |
|
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
|
@ -94,14 +95,42 @@ public class DeviceTypeController extends BladeController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设备表 删除 |
|
|
|
|
* 删除 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/remove") |
|
|
|
|
@ApiOperationSupport(order = 7) |
|
|
|
|
public R remove(@RequestParam String ids) { |
|
|
|
|
for (Long id : Func.toLongList(ids)) { |
|
|
|
|
// 是否存在关联子项
|
|
|
|
|
LambdaQueryWrapper<DeviceType> wrapper = Wrappers.lambdaQuery(DeviceType.class); |
|
|
|
|
wrapper.eq(DeviceType::getParentId,id); |
|
|
|
|
List<DeviceType> list = typeService.list(wrapper); |
|
|
|
|
if (list.size() > 0) { |
|
|
|
|
DeviceType type = typeService.getById(id); |
|
|
|
|
return R.fail(type.getTypeName() + "存在子项,请先解除设备类型关联再进行删除!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 是否存在设备已选择此类型
|
|
|
|
|
LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery(Device.class); |
|
|
|
|
queryWrapper.like(Device::getType,id); |
|
|
|
|
List<Device> deviceList = deviceService.list(queryWrapper); |
|
|
|
|
if (deviceList.size() > 0) { |
|
|
|
|
return R.fail("已有设备选择此类型,请勿删除"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return R.status(typeService.deleteLogic(Func.toLongList(ids))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取部门树形结构 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/tree") |
|
|
|
|
@ApiOperationSupport(order = 4) |
|
|
|
|
@Operation(summary = "树形结构", description = "树形结构") |
|
|
|
|
public R<List<DeviceTypeVO>> tree(String tenantId) { |
|
|
|
|
List<DeviceTypeVO> tree = typeService.tree(tenantId); |
|
|
|
|
return R.data(tree); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|