weidy
2023-06-09 732d631affb839337efc7e99ef58f60fe0d48914
修改getPk为使用雪花算法
已修改2个文件
33 ■■■■■ 文件已修改
Source/UBCS/ubcs-service-api/ubcs-util-api/pom.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/exception/VciBaseException.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-service-api/ubcs-util-api/pom.xml
@@ -49,7 +49,6 @@
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.4.1</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>
Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/exception/VciBaseException.java
@@ -10,6 +10,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.MessageFormat;
public class VciBaseException extends RuntimeException {
@@ -72,6 +74,36 @@
        }
    }
    /**
     * 获取异常信息
     * @param e 异常对象
     * @return 异常对象上的所有内容
     */
    public static String getErrorMsgByE(Throwable e){
        if(e == null){
            return "未知错误";
        }
        if( e.getClass()!= null && e.getClass().getSuperclass()!= null &&
            (e.getClass().getSuperclass().equals(RuntimeException.class)
                || e.getClass().getSuperclass().getName().endsWith(".VciBaseException")
                || e.getClass().getName().endsWith(".VciBaseException"))){
            //说明是我们自定义的异常类
            try {
                Method errorMethod = e.getClass().getMethod("getErrorMsg");
                if(errorMethod != null ){
                    return (String)errorMethod.invoke(e);
                }
            } catch (NoSuchMethodException e1) {
                return e.getMessage();
            } catch (IllegalAccessException e1) {
                return e.getMessage();
            } catch (InvocationTargetException e1) {
                return e.getMessage();
            }
        }
        return e.getMessage();
    }
    @Override
    public String getMessage() {
        return this.getCode() + "," + this.getErrorMsg();