공통 수정
This commit is contained in:
@@ -16,6 +16,7 @@ public class AdminConstants {
|
|||||||
public static final String MONGO_DB_COLLECTION_DATA_INIT_HISTORY = "dataInitHistory";
|
public static final String MONGO_DB_COLLECTION_DATA_INIT_HISTORY = "dataInitHistory";
|
||||||
public static final String MONGO_DB_COLLECTION_API_LOG = "apiLog";
|
public static final String MONGO_DB_COLLECTION_API_LOG = "apiLog";
|
||||||
public static final String MONGO_DB_COLLECTION_HISTORY_LOG = "historyLog";
|
public static final String MONGO_DB_COLLECTION_HISTORY_LOG = "historyLog";
|
||||||
|
public static final String MONGO_DB_COLLECTION_CURRENCY = "currency";
|
||||||
|
|
||||||
public static final String MONGO_DB_KEY_LOGTIME = "logTime";
|
public static final String MONGO_DB_KEY_LOGTIME = "logTime";
|
||||||
public static final String MONGO_DB_KEY_LOGMONTH = "logMonth";
|
public static final String MONGO_DB_KEY_LOGMONTH = "logMonth";
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.caliverse.admin.global.common.utils;
|
package com.caliverse.admin.global.common.utils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.*;
|
import java.time.*;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@@ -7,14 +9,15 @@ import java.util.*;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.*;
|
import java.util.regex.*;
|
||||||
|
|
||||||
import com.caliverse.admin.domain.entity.AI.AIRole;
|
|
||||||
import com.caliverse.admin.domain.entity.DiffStatus;
|
import com.caliverse.admin.domain.entity.DiffStatus;
|
||||||
import com.caliverse.admin.global.common.code.CommonCode;
|
import com.caliverse.admin.global.common.code.CommonCode;
|
||||||
import com.caliverse.admin.global.common.constants.CommonConstants;
|
import com.caliverse.admin.global.common.constants.CommonConstants;
|
||||||
import com.caliverse.admin.global.common.exception.RestApiException;
|
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.apache.commons.math3.dfp.DfpField;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
@@ -323,6 +326,20 @@ public class CommonUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JsonNode stringByJsonNode(String data) {
|
||||||
|
try {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
return objectMapper.readTree(data);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.JSON_PARSE_ERROR.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T nodeByValue(JsonNode node, Class<T> valueType) {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
return objectMapper.convertValue(node, valueType);
|
||||||
|
}
|
||||||
|
|
||||||
public static Integer stringToInt(String string) {
|
public static Integer stringToInt(String string) {
|
||||||
try{
|
try{
|
||||||
return Integer.parseInt(string);
|
return Integer.parseInt(string);
|
||||||
@@ -393,7 +410,9 @@ public class CommonUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> getAIMessage(AIRole role, String message){
|
public static double mathRoundDouble(double value){
|
||||||
return Map.of("role", role.toString(), "content", message);
|
return BigDecimal.valueOf(value)
|
||||||
|
.setScale(2, RoundingMode.HALF_UP)
|
||||||
|
.doubleValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user