feat(device): add device type options endpoint

- Added new GET /options endpoint to retrieve device type options
- Implemented getDeviceTypeOptions method in DeviceTypeController
- Updated DeviceTypeServiceImpl to map device types to OptionResponse
- Removed unused LambdaQueryWrapper and todo comment
- Added Java documentation for the new endpoint
This commit is contained in:
Chaos
2025-11-28 14:06:12 +08:00
parent af8959220a
commit f0d6279949
2 changed files with 8 additions and 5 deletions

View File

@@ -28,12 +28,11 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DriveTypeMapper, DeviceTy
@Override @Override
public List<OptionResponse> getDeviceTypeOptions() { public List<OptionResponse> getDeviceTypeOptions() {
LambdaQueryWrapper<DeviceType> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DeviceType> wrapper = new LambdaQueryWrapper<>();
return this.lambdaQuery() return this.lambdaQuery()
.select(DeviceType::getId, DeviceType::getName) .select(DeviceType::getId, DeviceType::getName)
//todo .list()
.stream()
; .map(deviceType -> new OptionResponse(deviceType.getName(), deviceType.getId().toString()))
.toList();
} }
} }

View File

@@ -34,6 +34,10 @@ public class DeviceTypeController {
return ApiResult.success(deviceTypeService.getAllDeviceTypes()); return ApiResult.success(deviceTypeService.getAllDeviceTypes());
} }
/**
* 获取所有设备类型选项
* @return 所有设备类型选项
*/
@GetMapping("/options") @GetMapping("/options")
public ApiResult<List<OptionResponse>> getDeviceTypeOptions() { public ApiResult<List<OptionResponse>> getDeviceTypeOptions() {
return ApiResult.success(deviceTypeService.getDeviceTypeOptions()); return ApiResult.success(deviceTypeService.getDeviceTypeOptions());