feat(device): 添加设备管理功能模块

- 新增设备实体类 Device 及其对应的数据传输对象 CreateDriveRequest 和 DeviceResponse
- 创建设备相关的控制器 DeviceController 并实现新建设备接口
- 实现设备服务接口 DeviceService 及其具体实现类 DeviceServiceImpl
- 添加设备数据访问层接口 DeviceMapper
- 在数据库初始化脚本中增加设备相关表结构定义,包括设备类型表、设备表和网络接口表
- 更新应用配置文件以激活开发环境配置
- 修复图片上传时获取原始文件名的问题
- 修改用户角色分配相关接口方法命名以提高语义清晰度
This commit is contained in:
Chaos
2025-11-21 06:29:50 +08:00
parent 8dd0efa09e
commit e23434ab48
15 changed files with 300 additions and 115 deletions

View File

@@ -0,0 +1,25 @@
package cn.nopj.chaos_api.domain.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDate;
@Data
@TableName("t_device")
public class Device {
@TableId(value = "id",type = IdType.AUTO)
private Long id;
private String name;
private String model;
private Long typeId;
private Long locationId;
private String snmpCommunity;
private String manufacturer;
private LocalDate purchaseDate;
private int status;
private String remark;
}

View File

@@ -0,0 +1,28 @@
package cn.nopj.chaos_api.dto.request;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import java.time.LocalDate;
@Data
public class CreateDriveRequest {
//限制必填 不限制特殊字符
@NotBlank(message = "设备名称不能为空")
private String name;
@NotBlank(message = "设备型号不能为空")
private String model;
@NotBlank(message = "设备类型不能为空")
private Long typeId;
private Long locationId;
private String snmpCommunity;
@NotBlank(message = "设备厂商不能为空")
private String manufacturer;
@Pattern(regexp = "^[0-9]{4}-[0-9]{2}-[0-9]{2}$", message = "设备购买日期格式不正确")
private LocalDate purchaseDate;
private int status;
private String remark;
}

View File

@@ -0,0 +1,33 @@
package cn.nopj.chaos_api.dto.response;
import cn.nopj.chaos_api.domain.entity.Device;
import lombok.Data;
import java.time.LocalDate;
@Data
public class DeviceResponse {
private Long id;
private String name;
private String model;
private Long typeId;
private Long locationId;
private String snmpCommunity;
private String manufacturer;
private LocalDate purchaseDate;
private int status;
private String remark;
public DeviceResponse(Device device) {
this.id = device.getId();
this.name = device.getName();
this.model = device.getModel();
this.typeId = device.getTypeId();
this.locationId = device.getLocationId();
this.snmpCommunity = device.getSnmpCommunity();
this.manufacturer = device.getManufacturer();
this.purchaseDate = device.getPurchaseDate();
this.status = device.getStatus();
this.remark = device.getRemark();
}
}