mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 09:55:16 +08:00
Pre Merge pull request !53 from mingli/fix-snakeflow-id-issue
This commit is contained in:
commit
4c36880f46
@ -8,7 +8,7 @@ spring:
|
|||||||
master:
|
master:
|
||||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
|
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: mm123456
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
# 从数据源开关/默认关闭
|
# 从数据源开关/默认关闭
|
||||||
|
|||||||
@ -158,7 +158,7 @@ mybatis-plus:
|
|||||||
# INPUT 用户输入ID
|
# INPUT 用户输入ID
|
||||||
# ASSIGN_ID 全局唯一ID
|
# ASSIGN_ID 全局唯一ID
|
||||||
# ASSIGN_UUID 全局唯一ID UUID
|
# ASSIGN_UUID 全局唯一ID UUID
|
||||||
idType: AUTO
|
idType: ASSIGN_ID
|
||||||
# 表名前缀
|
# 表名前缀
|
||||||
tablePrefix: null
|
tablePrefix: null
|
||||||
# 字段 format,例: %s,(对主键无效)
|
# 字段 format,例: %s,(对主键无效)
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ming LI
|
||||||
|
* 当Mybatis plus设置为雪花ID时,使用此类,会把所有数字返回变为字符串返回适配前端Long型失真问题
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class JacksonConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
@ConditionalOnMissingBean(ObjectMapper.class)
|
||||||
|
@ConditionalOnProperty(value = "mybatis-plus.global-config.dbConfig.idType",havingValue = "ASSIGN_ID")
|
||||||
|
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder)
|
||||||
|
{
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
||||||
|
|
||||||
|
// 全局配置序列化返回 JSON 处理
|
||||||
|
SimpleModule simpleModule = new SimpleModule();
|
||||||
|
//JSON Long ==> String
|
||||||
|
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
||||||
|
objectMapper.registerModule(simpleModule);
|
||||||
|
return objectMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user