From 35a36f60cdbd9ef3bf2ab7be9f418f988c93c5eb Mon Sep 17 00:00:00 2001 From: yuxc <653031404@qq.com> Date: 星期五, 21 四月 2023 17:05:02 +0800 Subject: [PATCH] 1、主题库定义相关代码。 2、枚举定义相关代码移植修改。 --- Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java | 75 +++++++++++++++++++++++++++++++++++++ 1 files changed, 75 insertions(+), 0 deletions(-) diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java index 792d1cd..58336f4 100644 --- a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java +++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.vci.ubcs.com.vci.starter.exception.VciBaseException; import com.vci.ubcs.com.vci.starter.web.pagemodel.SessionInfo; +import com.vci.ubcs.com.vci.starter.web.toolmodel.DateConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; @@ -34,6 +35,7 @@ import java.util.stream.Collectors; public class VciBaseUtil { + private static Logger log = LoggerFactory.getLogger(VciBaseUtil.class); public static final String NOTIN = "not in"; private static String localIp = null; @@ -43,6 +45,15 @@ public static String getPk() { return UUID.randomUUID().toString(); + } + + public static SessionInfo getCurrentUserSessionInfo() throws VciBaseException { + SessionInfo si = getCurrentUserSessionInfoNotException(); + if (si == null) { + throw new VciBaseException("noLogin", new String[]{"娌℃湁褰撳墠鐢ㄦ埛淇℃伅"}); + } else { + return si; + } } public static int getIntForBoolean(boolean b) { @@ -1132,5 +1143,69 @@ return listHasList; } } + public static short getShort(String s) { +// short i = false; + if (s == null) { + return 0; + } else { + try { + short i = Short.parseShort(s); + return i; + } catch (Exception var3) { + return 0; + } + } + } + + public static void setValueForField(Field field, Object obj, String value) { + try { + if (field != null && StringUtils.isNotBlank(value)) { + field.setAccessible(true); + Method setMethod = getSetmethod(field.getDeclaringClass(), field.getName()); + Class type = field.getType(); + Object valueObj = null; + if (!type.equals(Integer.TYPE) && !type.equals(Integer.class)) { + if (!type.equals(Float.TYPE) && !type.equals(Float.class)) { + if (!type.equals(Long.TYPE) && !type.equals(Long.class)) { + if (!type.equals(Double.class) && !type.equals(Double.TYPE)) { + if (type.equals(Date.class)) { + DateConverter dateConverter = new DateConverter(); + dateConverter.setAsText(value); + valueObj = dateConverter.getValue(); + } else if (type.equals(String.class)) { + valueObj = value; + } else { + valueObj = value; + if (log.isErrorEnabled()) { + log.error("涓嶆敮鎸佺殑绫诲瀷" + type.toString()); + } + } + } else { + valueObj = getDouble(value); + } + } else { + valueObj = getLong(value); + } + } else { + valueObj = getFloat(value); + } + } else { + valueObj = getInt(value); + } + + if (setMethod != null) { + setMethod.invoke(obj, valueObj); + } else { + field.set(obj, valueObj); + } + } + } catch (Throwable var7) { + if (log.isErrorEnabled()) { + log.error("璁剧疆灞炴�х殑鍊煎嚭閿欎簡閿欒", var7); + } + } + + } + } -- Gitblit v1.9.3