mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 01:48:47 +08:00
feature: 增加了雪花id配置文件,还没有测试
This commit is contained in:
parent
9d7b912879
commit
1bae0ca3ca
@ -4,19 +4,26 @@ 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)
|
||||
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder)
|
||||
@ConditionalOnProperty(value = "mybatis-plus.global-config.dbConfig.idType",havingValue = "ASSIGN_ID")
|
||||
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder)
|
||||
{
|
||||
|
||||
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
||||
|
||||
// 全局配置序列化返回 JSON 处理
|
||||
|
||||
Loading…
Reference in New Issue
Block a user