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:
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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());
|
||||||
|
|||||||
Reference in New Issue
Block a user