代码生成Date字段添加默认格式

duhanyu
RuoYi 5 years ago
parent d452ddf5f0
commit 526c3867b4

@ -196,6 +196,7 @@ public class VelocityUtils
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
{ {
importList.add("java.util.Date"); importList.add("java.util.Date");
importList.add("com.fasterxml.jackson.annotation.JsonFormat");
} }
else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType()))
{ {

@ -1,5 +1,8 @@
package ${packageName}.domain; package ${packageName}.domain;
#foreach ($import in $importList)
import ${import};
#end
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.framework.aspectj.lang.annotation.Excel; import com.ruoyi.framework.aspectj.lang.annotation.Excel;
@ -8,9 +11,6 @@ import com.ruoyi.framework.web.domain.BaseEntity;
#elseif($table.tree) #elseif($table.tree)
import com.ruoyi.framework.web.domain.TreeEntity; import com.ruoyi.framework.web.domain.TreeEntity;
#end #end
#foreach ($import in $importList)
import ${import};
#end
/** /**
* ${functionName}对象 ${tableName} * ${functionName}对象 ${tableName}
@ -40,6 +40,7 @@ public class ${ClassName} extends ${Entity}
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date') #elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else #else
@Excel(name = "${comment}") @Excel(name = "${comment}")

@ -88,7 +88,7 @@
#elseif($column.list && $column.htmlType == "datetime") #elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> <el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.${javaField}) }}</span> <span>{{ parseTime(scope.row.${javaField}), '{y}-{m}-{d}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && "" != $column.dictType) #elseif($column.list && "" != $column.dictType)

@ -112,7 +112,7 @@
#elseif($column.list && $column.htmlType == "datetime") #elseif($column.list && $column.htmlType == "datetime")
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> <el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.${javaField}) }}</span> <span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
#elseif($column.list && "" != $column.dictType) #elseif($column.list && "" != $column.dictType)

Loading…
Cancel
Save