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

@@ -1,6 +1,7 @@
package cn.nopj.chaos_api.domain.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@@ -22,4 +23,8 @@ public class Device {
private LocalDate purchaseDate;
private int status;
private String remark;
@TableField(exist = false)
private DeviceType deviceType;
}

View File

@@ -0,0 +1,18 @@
package cn.nopj.chaos_api.domain.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDate;
@Data
@TableName("t_device_type")
public class DeviceType {
private Long id;
private String name;
private String code;
private Long parentId;
private String remark;
private LocalDate createTime;
private LocalDate updateTime;
}

View File

@@ -0,0 +1,25 @@
package cn.nopj.chaos_api.dto.response;
import cn.nopj.chaos_api.domain.entity.DeviceType;
import lombok.Data;
import java.time.LocalDate;
@Data
public class DeviceTypeResponse {
private Long id;
private String name;
private String code;
private Long parentId;
private String remark;
private LocalDate createTime;
public DeviceTypeResponse(DeviceType type){
this.id = type.getId();
this.name = type.getName();
this.code = type.getCode();
this.parentId = type.getParentId();
this.remark = type.getRemark();
this.createTime = type.getCreateTime();
}
}