!35 【轻量级PR】业务数据保存时 自动塞入用户当前组织id

Merge pull request !35 from 叶星/dev-7.2.5
pull/36/MERGE
stylefeng 2022-09-01 02:20:46 +00:00 committed by Gitee
commit b4d12d6bc8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 24 additions and 0 deletions

View File

@ -73,4 +73,8 @@ public interface DbFieldConstants {
*/
String VERSION_FLAG = "versionFlag";
/**
* id
*/
String ORG_ID = "orgId";
}

View File

@ -65,6 +65,9 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
// 设置乐观锁字段从0开始
setValue(metaObject, VERSION_FLAG, 0L);
// 设置组织id
setValue(metaObject, ORG_ID, this.getUserOrgId());
} catch (ReflectionException e) {
log.warn("CustomMetaObjectHandler处理过程中无相关字段不做处理");
}
@ -116,4 +119,21 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
}
}
/**
* id
*
* @author yxx
* @date 2022/09/01 10:14
*/
private Long getUserOrgId() {
try {
return LoginContext.me().getLoginUser().getOrganizationId();
} catch (Exception e) {
//如果获取不到就返回-1
return -1L;
}
}
}