feat:添加OA系统对接相关代码

This commit is contained in:
aguanleishen
2026-07-22 17:04:56 +08:00
parent b259f94d4b
commit 9894ac7a34
8 changed files with 122 additions and 0 deletions
@@ -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;
}
}
@@ -27,6 +27,7 @@ package org.springblade.core.mp.config;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties.CoreConfiguration;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusPropertiesCustomizer;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
@@ -73,6 +74,12 @@ import java.util.List;
@BladePropertySource(value = "classpath:/blade-mybatis.yml")
public class MybatisPlusConfiguration implements WebMvcConfigurer {
@Bean
@ConditionalOnMissingBean
public MetaObjectHandler metaObjectHandler() {
return new MyMetaObjectHandler();
}
/**
* 分页拦截器
*/