Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pig_冷冷
Pig
提交
1ab67c54
Pig
项目概览
pig_冷冷
/
Pig
上一次同步 大约 1 年
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Pig
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1ab67c54
编写于
6月 17, 2020
作者:
G
gokje
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
Introducing new features. closed #I1KVNG GET请求支持时间字符串到JAVA8对象的自动转换
上级
88a612ed
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
80 addition
and
12 deletion
+80
-12
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/JacksonConfiguration.java
...ig4cloud/pig/common/core/config/JacksonConfiguration.java
+4
-4
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/RedisTemplateConfiguration.java
...ud/pig/common/core/config/RedisTemplateConfiguration.java
+1
-1
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/RestTemplateConfiguration.java
...oud/pig/common/core/config/RestTemplateConfiguration.java
+1
-1
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/WebMvcConfiguration.java
...pig4cloud/pig/common/core/config/WebMvcConfiguration.java
+25
-2
pig-common/pig-common-core/src/main/resources/META-INF/spring.factories
...-common-core/src/main/resources/META-INF/spring.factories
+4
-4
pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/JacksonConfig.java
.../java/com/pig4cloud/pig/monitor/config/JacksonConfig.java
+45
-0
未找到文件。
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/JacksonConfig.java
→
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/JacksonConfig
uration
.java
浏览文件 @
1ab67c54
...
...
@@ -35,15 +35,15 @@ import java.util.TimeZone;
/**
* JacksonConfig
*
* @author
:
lengleng
* @author lengleng
* @author L.cm
* @author
:
lishangbu
* @date
: 2018/10/22
* @author lishangbu
* @date
2020-06-17
*/
@Configuration
@ConditionalOnClass
(
ObjectMapper
.
class
)
@AutoConfigureBefore
(
JacksonAutoConfiguration
.
class
)
public
class
JacksonConfig
{
public
class
JacksonConfig
uration
{
@Bean
public
Jackson2ObjectMapperBuilderCustomizer
customizer
()
{
...
...
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/RedisTemplateConfig.java
→
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/RedisTemplateConfig
uration
.java
浏览文件 @
1ab67c54
...
...
@@ -37,7 +37,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
@RequiredArgsConstructor
@AutoConfigureBefore
(
RedisAutoConfiguration
.
class
)
public
class
RedisTemplateConfig
{
public
class
RedisTemplateConfig
uration
{
private
final
RedisConnectionFactory
factory
;
...
...
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/RestTemplateConfig.java
→
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/config/RestTemplateConfig
uration
.java
浏览文件 @
1ab67c54
...
...
@@ -27,7 +27,7 @@ import org.springframework.web.client.RestTemplate;
* @date 2019/2/1 RestTemplate
*/
@Configuration
public
class
RestTemplateConfig
{
public
class
RestTemplateConfig
uration
{
@Bean
public
RestTemplate
restTemplate
()
{
...
...
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/
mybatis/WebMvcConfig
.java
→
pig-common/pig-common-core/src/main/java/com/pig4cloud/pig/common/core/
config/WebMvcConfiguration
.java
浏览文件 @
1ab67c54
...
...
@@ -16,13 +16,18 @@
*
*/
package
com.pig4cloud.pig.common.core.
mybatis
;
package
com.pig4cloud.pig.common.core.
config
;
import
cn.hutool.core.date.DatePattern
;
import
com.pig4cloud.pig.common.core.mybatis.SqlFilterArgumentResolver
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.format.FormatterRegistry
;
import
org.springframework.format.datetime.standard.DateTimeFormatterRegistrar
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.time.format.DateTimeFormatter
;
import
java.util.List
;
import
static
org
.
springframework
.
boot
.
autoconfigure
.
condition
.
ConditionalOnWebApplication
.
Type
.
SERVLET
;
...
...
@@ -35,11 +40,29 @@ import static org.springframework.boot.autoconfigure.condition.ConditionalOnWebA
*/
@Configuration
@ConditionalOnWebApplication
(
type
=
SERVLET
)
public
class
WebMvcConfig
implements
WebMvcConfigurer
{
public
class
WebMvcConfig
uration
implements
WebMvcConfigurer
{
@Override
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
argumentResolvers
.
add
(
new
SqlFilterArgumentResolver
());
}
/**
* 增加GET请求参数中时间类型转换 {@link com.pig4cloud.pig.common.core.jackson.PigJavaTimeModule}
* <ul>
* <li>HH:mm:ss -> LocalTime</li>
* <li>yyyy-MM-dd -> LocalDate</li>
* <li>yyyy-MM-dd HH:mm:ss -> LocalDateTime</li>
* </ul>
* @param registry
*/
@Override
public
void
addFormatters
(
FormatterRegistry
registry
)
{
DateTimeFormatterRegistrar
registrar
=
new
DateTimeFormatterRegistrar
();
registrar
.
setTimeFormatter
(
DateTimeFormatter
.
ofPattern
(
DatePattern
.
NORM_TIME_PATTERN
));
registrar
.
setDateFormatter
(
DateTimeFormatter
.
ofPattern
(
DatePattern
.
NORM_DATE_PATTERN
));
registrar
.
setDateTimeFormatter
(
DateTimeFormatter
.
ofPattern
(
DatePattern
.
NORM_DATETIME_PATTERN
));
registrar
.
registerFormatters
(
registry
);
}
}
pig-common/pig-common-core/src/main/resources/META-INF/spring.factories
浏览文件 @
1ab67c54
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.pig4cloud.pig.common.core.config.JacksonConfig,\
com.pig4cloud.pig.common.core.config.RedisTemplateConfig,\
com.pig4cloud.pig.common.core.config.RestTemplateConfig,\
com.pig4cloud.pig.common.core.config.JacksonConfig
uration
,\
com.pig4cloud.pig.common.core.config.RedisTemplateConfig
uration
,\
com.pig4cloud.pig.common.core.config.RestTemplateConfig
uration
,\
com.pig4cloud.pig.common.core.util.SpringContextHolder,\
com.pig4cloud.pig.common.core.
mybatis.WebMvcConfig
com.pig4cloud.pig.common.core.
config.WebMvcConfiguration
pig-visual/pig-monitor/src/main/java/com/pig4cloud/pig/monitor/config/JacksonConfig.java
0 → 100644
浏览文件 @
1ab67c54
package
com.pig4cloud.pig.monitor.config
;
import
cn.hutool.core.date.DatePattern
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.module.SimpleModule
;
import
com.pig4cloud.pig.common.core.jackson.PigJavaTimeModule
;
import
de.codecentric.boot.admin.server.config.AdminServerWebConfiguration
;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.Locale
;
import
java.util.TimeZone
;
/**
* JacksonConfig 扩展增加 spring boot 默认配置
* <p>
* 自身序列化机制 {@link de.codecentric.boot.admin.server.utils.jackson.AdminServerModule}
*
* @author lengleng
* @date 2020-06-17
*/
@Configuration
@ConditionalOnClass
(
ObjectMapper
.
class
)
@AutoConfigureAfter
(
AdminServerWebConfiguration
.
class
)
public
class
JacksonConfig
{
/**
* 覆盖core 模块提供的序列方式,增加springboot admin 序列化
* @param adminJacksonModule spring boot admin 提供的序列化
* @return Jackson customizer
*/
@Bean
public
Jackson2ObjectMapperBuilderCustomizer
customizer
(
SimpleModule
adminJacksonModule
)
{
return
builder
->
{
builder
.
locale
(
Locale
.
CHINA
);
builder
.
timeZone
(
TimeZone
.
getTimeZone
(
"Asia/Shanghai"
));
builder
.
simpleDateFormat
(
DatePattern
.
NORM_DATETIME_PATTERN
);
builder
.
modules
(
new
PigJavaTimeModule
(),
adminJacksonModule
);
};
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录