From 7ea0b07b7c0ccc45461e5c62fd8f7f79f62f4260 Mon Sep 17 00:00:00 2001 From: Qyf Date: Tue, 19 Nov 2024 21:34:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9vm=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E8=A7=A3=E5=86=B3localdate=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E7=BC=BA=E5=B0=91=E5=AF=BC=E5=85=A5=E5=8C=85=E5=8F=8A?= =?UTF-8?q?=E6=97=A0=E9=BB=98=E8=AE=A4=E6=A0=BC=E5=BC=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E6=88=96=E8=80=85=E7=89=B9=E6=80=A7=E3=80=82=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9localdate=E7=9A=84=E6=94=AF=E6=8C=81?= =?UTF-8?q?,=E5=8C=85=E6=8B=AC=E5=AF=BC=E5=85=A5=E5=8C=85=E5=92=8C?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E3=80=82=20=E8=AF=A6=E8=A7=81PR?= =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codegen/java/controller/vo/listReqVO.vm | 24 +++++++++++++++-- .../codegen/java/controller/vo/pageReqVO.vm | 26 ++++++++++++++++--- .../codegen/java/controller/vo/respVO.vm | 20 ++++++++++++-- .../codegen/java/controller/vo/saveReqVO.vm | 19 ++++++++++++-- 4 files changed, 80 insertions(+), 9 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm index 46b6a259d1..ea3325d95a 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/listReqVO.vm @@ -10,16 +10,30 @@ import java.math.BigDecimal; #break #end #end +##只引入一次DateTimeFormat +#foreach ($column in $columns) +#if (${column.listOperation} && (${column.javaType} == "LocalDateTime" || ${column.javaType} == "LocalDate")) +import org.springframework.format.annotation.DateTimeFormat; +#break +#end +#end ## 处理 LocalDateTime 字段的引入 #foreach ($column in $columns) #if (${column.listOperation} && ${column.javaType} == "LocalDateTime") import java.time.LocalDateTime; -import org.springframework.format.annotation.DateTimeFormat; - import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; #break #end #end +## 处理 LocalDate 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperation} && ${column.javaType} == "LocalDate") +import java.time.LocalDate; +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY; +#break +#end +#end + ## 字段模板 #macro(columnTpl $prefix $prefixStr) @Schema(description = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) @@ -33,9 +47,15 @@ public class ${sceneEnum.prefixClass}${table.className}ListReqVO { #foreach ($column in $columns) #if (${column.listOperation})##查询操作 #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 + #if (${column.listOperation} && ${column.javaType} == "LocalDate") + @Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + private ${column.javaType}[] ${column.javaField}; + #else## 如果不满足上述任何条件,做其他处理 @Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private ${column.javaType}[] ${column.javaField}; + #end #else##情况二,非 Between 的时间 #columnTpl('', '') #end diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm index 003bac902f..8198e8a20c 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm @@ -10,16 +10,30 @@ import java.math.BigDecimal; #break #end #end -## 处理 LocalDateTime 字段的引入 +##只引入一次DateTimeFormat #foreach ($column in $columns) -#if (${column.listOperationCondition} && ${column.javaType} == "LocalDateTime") +#if (${column.listOperation} && (${column.javaType} == "LocalDateTime" || ${column.javaType} == "LocalDate")) import org.springframework.format.annotation.DateTimeFormat; +#break +#end +#end +## 处理 LocalDateTime 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperation} && ${column.javaType} == "LocalDateTime") import java.time.LocalDateTime; - import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; #break #end #end +## 处理 LocalDate 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperation} && ${column.javaType} == "LocalDate") +import java.time.LocalDate; +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY; +#break +#end +#end + ## 字段模板 #macro(columnTpl $prefix $prefixStr) @Schema(description = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) @@ -35,9 +49,15 @@ public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PagePar #foreach ($column in $columns) #if (${column.listOperation})##查询操作 #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 + #if (${column.listOperation} && ${column.javaType} == "LocalDate") + @Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + private ${column.javaType}[] ${column.javaField}; + #else## 如果不满足上述任何条件,做其他处理 @Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private ${column.javaType}[] ${column.javaField}; + #end #else##情况二,非 Between 的时间 #columnTpl('', '') #end diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm index 24c3519451..0a5f5ba119 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm @@ -10,14 +10,30 @@ import java.math.BigDecimal; #break #end #end -## 处理 LocalDateTime 字段的引入 +##只引入一次DateTimeFormat #foreach ($column in $columns) -#if (${column.listOperationResult} && ${column.javaType} == "LocalDateTime") +#if (${column.listOperation} && (${column.javaType} == "LocalDateTime" || ${column.javaType} == "LocalDate")) import org.springframework.format.annotation.DateTimeFormat; +#break +#end +#end +## 处理 LocalDateTime 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperation} && ${column.javaType} == "LocalDateTime") import java.time.LocalDateTime; +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; #break #end #end +## 处理 LocalDate 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperation} && ${column.javaType} == "LocalDate") +import java.time.LocalDate; +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY; +#break +#end +#end + ## 处理 Excel 导出 import com.alibaba.excel.annotation.*; #foreach ($column in $columns) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm index b432c75276..1c0f937eef 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm @@ -11,11 +11,26 @@ import java.math.BigDecimal; #break #end #end -## 处理 LocalDateTime 字段的引入 +##只引入一次DateTimeFormat #foreach ($column in $columns) -#if ((${column.createOperation} || ${column.updateOperation}) && ${column.javaType} == "LocalDateTime") +#if (${column.listOperation} && (${column.javaType} == "LocalDateTime" || ${column.javaType} == "LocalDate")) import org.springframework.format.annotation.DateTimeFormat; +#break +#end +#end +## 处理 LocalDateTime 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperation} && ${column.javaType} == "LocalDateTime") import java.time.LocalDateTime; +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +#break +#end +#end +## 处理 LocalDate 字段的引入 +#foreach ($column in $columns) +#if (${column.listOperation} && ${column.javaType} == "LocalDate") +import java.time.LocalDate; +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY; #break #end #end -- Gitee From 8626ca59fbafc67bf87183828e61d914ba99c333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=B1=E5=B4=A9=E5=B2=A9=E9=98=BB?= <8522461+HappyComputer@user.noreply.gitee.com> Date: Thu, 21 Nov 2024 09:56:00 +0000 Subject: [PATCH 2/2] =?UTF-8?q?update=20yudao-module-infra/yudao-module-in?= =?UTF-8?q?fra-biz/src/main/resources/codegen/java/dal/do.vm.=20DO?= =?UTF-8?q?=E6=94=AF=E6=8C=81LocalDate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 山崩岩阻 <8522461+HappyComputer@user.noreply.gitee.com> --- .../src/main/resources/codegen/java/dal/do.vm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm index b019d6e12f..dc56c0b72a 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/dal/do.vm @@ -9,6 +9,9 @@ import java.math.BigDecimal; #if (${column.javaType} == "LocalDateTime") import java.time.LocalDateTime; #end +#if (${column.javaType} == "LocalDate") +import java.time.LocalDate; +#end #end import com.baomidou.mybatisplus.annotation.*; import ${BaseDOClassName}; -- Gitee