feat(generator):为不同时间类型字段添加特定日期格式化注解

- 为 LocalDateTime 类型字段添加 "yyyy-MM-dd HH:mm:ss" 格式
-为 LocalDate 类型字段添加 "yyyy-MM-dd" 格式- 为 LocalTime 类型字段添加 "HH:mm:ss" 格式
- 为 Date 类型字段保留原有 "yyyy-MM-dd HH:mm:ss" 格式- 优化时间字段格式化逻辑,提高代码可读性
This commit is contained in:
2025-10-16 20:34:41 +08:00
parent e65003ddb3
commit c2df93faeb

View File

@@ -69,7 +69,13 @@ public class ${entity} implements Serializable {
<% } %>
<% /* 为时间类型字段添加日期格式化注解 */ %>
<% if(field.propertyType == 'LocalDateTime' || field.propertyType == 'LocalDate' || field.propertyType == 'LocalTime' || field.propertyType == 'Date') { %>
<% if(field.propertyType == 'LocalDateTime') { %>
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
<% } else if(field.propertyType == 'LocalDate') { %>
@JsonFormat(pattern = "yyyy-MM-dd")
<% } else if(field.propertyType == 'LocalTime') { %>
@JsonFormat(pattern = "HH:mm:ss")
<% } else if(field.propertyType == 'Date') { %>
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
<% } %>