jiangping
2023-12-14 e2f8fb1fbe26ba6d92f3e5dfcaeb0c69abe76b25
server/dmvisit_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1,8 +1,13 @@
package com.doumee.core.utils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
@@ -35,6 +40,12 @@
    public static final String MDJ_LW_REQUIRED = "MDJ_LW_REQUIRED";
    public static final String MDJ_VISIT_REQUIRED = "MDJ_VISIT_REQUIRED";
    public static final String EDS_PWD ="!@#$%^&QWERTY" ;
    public static final String ROOT_PATH = "";
    public static final String FILE_DIR = "";
    // 访客来访配置
    public static final String VISIT_CONFIG = "VISIT_CONFIG";
    // 劳务来访配置
    public static final String LABOR_CONFIG = "LABOR_CONFIG";
    public static  Date  getBirthdyByCardNo(String idCard){
@@ -253,7 +264,27 @@
        }
    }
    /**
     * 对象驼峰属性转下划线
     * @param object
     * @return
     * @throws JsonProcessingException
     */
    public static String toUnderlineJSONString(Object object) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        String reqJson = mapper.writeValueAsString(object);
        return reqJson;
    }
    public static <T> T toSnakeObject(String json, Class<T> clazz) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
        T reqJson =  mapper.readValue(json, clazz);
        return reqJson;
    }
}