mirror of https://gitee.com/stylefeng/roses
【8.0】【auth】【tenant】更新自动填充逻辑,填充租户id
parent
d2627ee50d
commit
14d789ea0a
|
@ -77,4 +77,10 @@ public interface DbFieldConstants {
|
||||||
* 组织id
|
* 组织id
|
||||||
*/
|
*/
|
||||||
String ORG_ID = "orgId";
|
String ORG_ID = "orgId";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户id
|
||||||
|
*/
|
||||||
|
String TENANT_ID = "tenantId";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,9 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
|
||||||
// 设置组织id
|
// 设置组织id
|
||||||
setValue(metaObject, DbFieldConstants.ORG_ID, this.getUserOrgId());
|
setValue(metaObject, DbFieldConstants.ORG_ID, this.getUserOrgId());
|
||||||
|
|
||||||
|
// 设置租户id
|
||||||
|
setValue(metaObject, DbFieldConstants.TENANT_ID, this.getTenantId());
|
||||||
|
|
||||||
} catch (ReflectionException e) {
|
} catch (ReflectionException e) {
|
||||||
log.warn("CustomMetaObjectHandler处理过程中无相关字段,不做处理");
|
log.warn("CustomMetaObjectHandler处理过程中无相关字段,不做处理");
|
||||||
}
|
}
|
||||||
|
@ -139,6 +142,21 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户的租户id
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/9/5 16:19
|
||||||
|
*/
|
||||||
|
private Long getTenantId() {
|
||||||
|
try {
|
||||||
|
return LoginContext.me().getLoginUser().getTenantId();
|
||||||
|
} catch (Exception e) {
|
||||||
|
//如果获取不到就返回-1
|
||||||
|
return -1L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置属性,针对逻辑删除字段
|
* 设置属性,针对逻辑删除字段
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue