refactor(device): 优化时间格式处理

- 移除了 DeviceFactory 和 DeviceRepository 中将 LocalDateTime转换为 Date 的代码
- 更新了 DeviceConfigV2DTO 和 DeviceV2DTO,将 createTime 和 updateTime 字段从 LocalDateTime 改为 Date
- 现在使用 @JsonFormat 注解来处理日期格式的序列化和反序列化
This commit is contained in:
2025-09-04 12:36:44 +08:00
parent 8ad999f779
commit 3b8a33c8eb
4 changed files with 11 additions and 12 deletions

View File

@@ -56,12 +56,11 @@ public class DeviceFactory {
entity.setNo(dto.getNo());
entity.setScenicId(dto.getScenicId());
entity.setStatus(dto.getIsActive());
// 转换时间格式:LocalDateTime -> Date
if (dto.getCreateTime() != null) {
entity.setCreateAt(Date.from(dto.getCreateTime().atZone(ZoneId.systemDefault()).toInstant()));
entity.setCreateAt(dto.getCreateTime());
}
if (dto.getUpdateTime() != null) {
entity.setUpdateAt(Date.from(dto.getUpdateTime().atZone(ZoneId.systemDefault()).toInstant()));
entity.setUpdateAt(dto.getUpdateTime());
}
return entity;
}