Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
a60661ed
Commit
a60661ed
authored
Dec 12, 2020
by
zhengjie
Browse files
[代码优化](v2.6):bug修复,代码优化,日期格式化后返回
close
https://github.com/elunez/eladmin/issues/514
parent
eb351903
Changes
2
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java
View file @
a60661ed
...
...
@@ -15,8 +15,13 @@
*/
package
me.zhengjie.config
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
import
org.springframework.web.filter.CorsFilter
;
...
...
@@ -24,6 +29,11 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* WebMvcConfigurer
*
...
...
@@ -62,4 +72,29 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
registry
.
addResourceHandler
(
"/file/**"
).
addResourceLocations
(
pathUtl
).
setCachePeriod
(
0
);
registry
.
addResourceHandler
(
"/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
).
setCachePeriod
(
0
);
}
@Override
public
void
configureMessageConverters
(
List
<
HttpMessageConverter
<?>>
converters
)
{
FastJsonHttpMessageConverter
converter
=
new
FastJsonHttpMessageConverter
();
List
<
MediaType
>
supportMediaTypeList
=
new
ArrayList
<>();
supportMediaTypeList
.
add
(
MediaType
.
APPLICATION_JSON_UTF8
);
FastJsonConfig
config
=
new
FastJsonConfig
();
config
.
setDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
config
.
setSerializerFeatures
(
SerializerFeature
.
DisableCircularReferenceDetect
,
//保留空的字段
SerializerFeature
.
WriteMapNullValue
,
//String null -> ""
SerializerFeature
.
WriteNullStringAsEmpty
,
//Number null -> 0
SerializerFeature
.
WriteNullNumberAsZero
,
//List null-> []
SerializerFeature
.
WriteNullListAsEmpty
,
//Boolean null -> false
SerializerFeature
.
WriteNullBooleanAsFalse
);
converter
.
setFastJsonConfig
(
config
);
converter
.
setSupportedMediaTypes
(
supportMediaTypeList
);
converter
.
setDefaultCharset
(
StandardCharsets
.
UTF_8
);
converters
.
add
(
converter
);
}
}
eladmin-system/src/main/resources/template/generator/front/index.ftl
View file @
a60661ed
...
...
@@ -85,14 +85,8 @@
{{
dict
.label
.$
{
column
.dictName
}
[
scope
.row
.$
{
column
.changeColumnName
}
]
}}
</template>
</el-table-column>
<#elseif column.columnType != 'Timestamp'>
<el-table-column prop="$
{
column
.changeColumnName
}
" label="<#if column.remark != ''>$
{
column
.remark
}
<#else>$
{
column
.changeColumnName
}
</#if>" />
<#else>
<el-table-column prop="$
{
column
.changeColumnName
}
" label="<#if column.remark != ''>$
{
column
.remark
}
<#else>$
{
column
.changeColumnName
}
</#if>">
<template slot-scope="scope">
<span>
{{
parseTime
(
scope
.row
.$
{
column
.changeColumnName
})
}}
</span>
</template>
</el-table-column>
<el-table-column prop="$
{
column
.changeColumnName
}
" label="<#if column.remark != ''>$
{
column
.remark
}
<#else>$
{
column
.changeColumnName
}
</#if>" />
</#if>
</#if>
</#list>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment