中国算力平台算力登记系统2.0
yanzhaofeige
5 days ago 37f8463032c06236bfd098133c31cda51217b00f
数据中心编号处理
1 files modified
1 files added
46 ■■■■■ changed files
cpzidc-bis/src/main/resources/mapper/bis/IdcNoIndexMapper.xml 4 ●●●● patch | view | raw | blame | history
cpzidc-framework/src/main/java/com/odcc/cpzidc/framework/config/JacksonConfig.java 42 ●●●●● patch | view | raw | blame | history
cpzidc-bis/src/main/resources/mapper/bis/IdcNoIndexMapper.xml
@@ -12,7 +12,7 @@
    </resultMap>
    <sql id="selectIdcNoIndexVo">
        select id, tel_no, production_year, index from idc_no_index
        select id, tel_no, production_year, 'index' from idc_no_index
    </sql>
    <select id="selectIdcNoIndexList" parameterType="IdcNoIndex" resultMap="IdcNoIndexResult">
@@ -20,7 +20,7 @@
        <where>  
            <if test="telNo != null  and telNo != ''"> and tel_no = #{telNo}</if>
            <if test="productionYear != null  and productionYear != ''"> and production_year = #{productionYear}</if>
            <if test="index != null  and index != ''"> and index = #{index}</if>
            <if test="index != null  and index != ''"> and 'index' = #{index}</if>
        </where>
    </select>
    
cpzidc-framework/src/main/java/com/odcc/cpzidc/framework/config/JacksonConfig.java
New file
@@ -0,0 +1,42 @@
package com.odcc.cpzidc.framework.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
/**
 * Jackson配置
 *
 * @author ruoyi
 *
 */
@Configuration
public class JacksonConfig
{
    @Bean
    public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter()
    {
        final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
        builder.serializationInclusion(JsonInclude.Include.NON_NULL);
        final ObjectMapper objectMapper = builder.build();
        SimpleModule simpleModule = new SimpleModule();
        // Long 转为 String 防止 js 丢失精度
        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
        objectMapper.registerModule(simpleModule);
        // 忽略 transient 关键词属性
        objectMapper.configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER, true);
        // 时区设置
        objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
        return new MappingJackson2HttpMessageConverter(objectMapper);
    }
}