feat:添加OA系统对接相关代码
This commit is contained in:
+16
@@ -40,6 +40,12 @@ import org.springframework.lang.Nullable;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.springblade.core.tool.support.NoErrorFallback;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springblade.core.tool.utils.StringUtil;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blade fallBack 代理处理
|
* blade fallBack 代理处理
|
||||||
*
|
*
|
||||||
@@ -69,6 +75,16 @@ public class BladeFeignFallback<T> implements MethodInterceptor {
|
|||||||
if (Map.class == returnType) {
|
if (Map.class == returnType) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
if (cause instanceof FeignException feignException) {
|
||||||
|
if (feignException.status() == HttpStatus.INTERNAL_SERVER_ERROR.value() && NoErrorFallback.class.isAssignableFrom(returnType)) {
|
||||||
|
// 500 错误并且 继承了 NoErrorFallback,不拦截
|
||||||
|
String body = feignException.contentUTF8();
|
||||||
|
if (StringUtil.isBlank(body)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return JSON.parseObject(body, returnType);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 暂时不支持 flux,rx,异步等,返回值不是 R,直接返回 null。
|
// 暂时不支持 flux,rx,异步等,返回值不是 R,直接返回 null。
|
||||||
if (R.class != returnType) {
|
if (R.class != returnType) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -82,6 +82,12 @@
|
|||||||
<artifactId>blade-core-auto</artifactId>
|
<artifactId>blade-core-auto</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package org.springblade.core.tool.support;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不拦截标识接口
|
||||||
|
* @author bfhuange
|
||||||
|
* @date 2024/9/20
|
||||||
|
*/
|
||||||
|
public interface NoErrorFallback {
|
||||||
|
}
|
||||||
@@ -25,6 +25,9 @@ public class DateUtil {
|
|||||||
public static final String PATTERN_DATETIME_MINI = "yyyyMMddHHmmss";
|
public static final String PATTERN_DATETIME_MINI = "yyyyMMddHHmmss";
|
||||||
public static final String PATTERN_DATE = "yyyy-MM-dd";
|
public static final String PATTERN_DATE = "yyyy-MM-dd";
|
||||||
public static final String PATTERN_TIME = "HH:mm:ss";
|
public static final String PATTERN_TIME = "HH:mm:ss";
|
||||||
|
|
||||||
|
public static final String PATTERN_TIME_MINI = "yyyy-MM-dd HH:mm";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 老 date 格式化
|
* 老 date 格式化
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -59,4 +59,7 @@ public class LogTraceUtil {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getTraceIdFromMDC() {
|
||||||
|
return MDC.get(UNIQUE_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
package org.springblade.core.mp.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
|
import org.apache.ibatis.reflection.MetaObject;
|
||||||
|
import org.springblade.core.secure.utils.AuthUtil;
|
||||||
|
import org.springblade.core.tool.constant.BladeConstant;
|
||||||
|
import org.springblade.core.tool.utils.StringUtil;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动填充字段处理器
|
||||||
|
* @author bfhuange
|
||||||
|
* @date 2024/8/29
|
||||||
|
**/
|
||||||
|
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||||
|
/**
|
||||||
|
* 插入操作,自动填充
|
||||||
|
*
|
||||||
|
* @param metaObject
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void insertFill(MetaObject metaObject) {
|
||||||
|
Long userId = AuthUtil.getUserId();
|
||||||
|
String tenantId = AuthUtil.getTenantId();
|
||||||
|
if (StringUtil.isBlank(tenantId)) {
|
||||||
|
tenantId = BladeConstant.ADMIN_TENANT_ID;
|
||||||
|
}
|
||||||
|
String userName = AuthUtil.getNickName();
|
||||||
|
|
||||||
|
this.strictInsertFill(metaObject, "tenantId", String.class, tenantId);
|
||||||
|
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
||||||
|
this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
|
||||||
|
this.strictInsertFill(metaObject, "createUser", Long.class, userId);
|
||||||
|
this.strictInsertFill(metaObject, "updateUser", Long.class, userId);
|
||||||
|
this.strictInsertFill(metaObject, "status", Integer.class, BladeConstant.DB_STATUS_NORMAL);
|
||||||
|
this.strictInsertFill(metaObject, "isDeleted", Integer.class, BladeConstant.DB_NOT_DELETED);
|
||||||
|
this.strictInsertFill(metaObject, "createUserName", String.class, userName);
|
||||||
|
this.strictInsertFill(metaObject, "updateUserName", String.class, userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新操作,自动填充
|
||||||
|
*
|
||||||
|
* @param metaObject
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateFill(MetaObject metaObject) {
|
||||||
|
Long userId = AuthUtil.getUserId();
|
||||||
|
String userName = AuthUtil.getNickName();
|
||||||
|
this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
|
||||||
|
this.strictUpdateFill(metaObject, "updateUser", Long.class, userId);
|
||||||
|
this.strictUpdateFill(metaObject, "updateUserName", String.class, userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取创建人部门id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Long getCreateDeptId() {
|
||||||
|
String deptIdStr = AuthUtil.getDeptId();
|
||||||
|
if (deptIdStr != null && !deptIdStr.isEmpty()) {
|
||||||
|
try {
|
||||||
|
return Long.parseLong(deptIdStr);
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
@@ -27,6 +27,7 @@ package org.springblade.core.mp.config;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties.CoreConfiguration;
|
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties.CoreConfiguration;
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer;
|
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer;
|
||||||
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||||
@@ -73,6 +74,12 @@ import java.util.List;
|
|||||||
@BladePropertySource(value = "classpath:/blade-mybatis.yml")
|
@BladePropertySource(value = "classpath:/blade-mybatis.yml")
|
||||||
public class MybatisPlusConfiguration implements WebMvcConfigurer {
|
public class MybatisPlusConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public MetaObjectHandler metaObjectHandler() {
|
||||||
|
return new MyMetaObjectHandler();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页拦截器
|
* 分页拦截器
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -935,6 +935,13 @@
|
|||||||
<artifactId>bcprov-jdk18on</artifactId>
|
<artifactId>bcprov-jdk18on</artifactId>
|
||||||
<version>1.82</version>
|
<version>1.82</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.8.27</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user