feat(device): 添加设备类型管理功能

- 在Device实体中添加了deviceType字段,并使用@TableField注解标记为非数据库字段
- 新增DeviceType实体类,用于表示设备类型信息
- 创建DeviceTypeController控制器,提供获取所有设备类型的接口
- 新增DeviceTypeService接口及其实现类DeviceTypeServiceImpl,实现设备类型相关业务逻辑
- 添加DriveTypeMapper接口,继承BaseMapper以支持对DeviceType的数据库操作
- 在ErrorCode常量类中增加了设备相关的错误码:DEVICE_NOT_FOUND和DEVICE_TYPE_NOT_FOUND
- 更新DeviceController,引入DeviceTypeResponse并优化代码结构
- 在DeviceMapper中新增selectOneWithTypeById方法,通过MyBatis注解实现关联查询设备及其类型信息
This commit is contained in:
Chaos
2025-11-21 06:54:12 +08:00
parent e23434ab48
commit 72a1e4d309
12 changed files with 190 additions and 2 deletions

View File

@@ -32,4 +32,14 @@ public class DeviceController {
public ApiResult<DeviceResponse> createDevice(@RequestBody CreateDriveRequest createDriveRequest){
return ApiResult.success(deviceService.createDevice(createDriveRequest));
}
/**
* 查询指定设备信息
* @return 指定设备信息
*/
@RequestMapping("/get")
public ApiResult<DeviceResponse> getDeviceById(Long id){
return ApiResult.success(deviceService.getDeviceById(id));
}
}

View File

@@ -0,0 +1,35 @@
package cn.nopj.chaos_api.controller;
import cn.nopj.chaos_api.dto.response.DeviceTypeResponse;
import cn.nopj.chaos_api.model.ApiResult;
import cn.nopj.chaos_api.service.DeviceTypeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 设备类型管理
*
* @author nopj
*/
@RestController
@RequestMapping("/api/deviceType")
public class DeviceTypeController {
private final DeviceTypeService deviceTypeService;
public DeviceTypeController(DeviceTypeService deviceTypeService) {
this.deviceTypeService = deviceTypeService;
}
/**
* 获取所有设备类型
*
* @return 所有设备类型
*/
@RequestMapping("/all")
public ApiResult<List<DeviceTypeResponse>> getAllDeviceTypes() {
return ApiResult.success(deviceTypeService.getAllDeviceTypes());
}
}