|
|
@@ -52,13 +52,11 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
* 项目启动时,缓存机构数据
|
|
|
*/
|
|
|
@PostConstruct
|
|
|
- public void init()
|
|
|
- {
|
|
|
+ public void init() {
|
|
|
loadingOrgCache();
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public TableDataInfo<SysOrg> selectPage(SysOrg org) {
|
|
|
//未删除
|
|
|
@@ -70,18 +68,21 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
} else {
|
|
|
page = new Page<>();
|
|
|
}
|
|
|
+ Long parentId = org.getParentId();
|
|
|
+ if(parentId == null){
|
|
|
+ parentId = SecurityUtils.getLoginUser().getSysUser().getOrgId();
|
|
|
+ }
|
|
|
+ SysOrg sysOrg = sysOrgMapper.selectById(parentId);
|
|
|
+
|
|
|
+ org.setParentId(null);
|
|
|
//查询条件
|
|
|
QueryWrapper<SysOrg> query = new QueryWrapper<>(org);
|
|
|
//下穿
|
|
|
if (org.getCheckSub()) {
|
|
|
- List<Long> ids = this.selectCheckSubOrgIdList(org.getParentId());
|
|
|
- //清空前端传递的org_id
|
|
|
- org.setParentId(null);
|
|
|
- //添加in条件
|
|
|
- query.in("id", ids);
|
|
|
-
|
|
|
+ query.lambda().likeRight(SysOrg::getPath, sysOrg.getPath());
|
|
|
+ } else {
|
|
|
+ query.lambda().eq(SysOrg::getPath,sysOrg.getPath());
|
|
|
}
|
|
|
-
|
|
|
//模糊查询
|
|
|
if (StringUtils.isNotNull(org.getName())) {
|
|
|
query.like("name", org.getName());
|
|
|
@@ -248,7 +249,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
@Override
|
|
|
public void loadingOrgCache() {
|
|
|
QueryWrapper<SysOrg> qw = new QueryWrapper<>();
|
|
|
- qw.lambda().ge(SysOrg::getDeleted,0);
|
|
|
+ qw.lambda().ge(SysOrg::getDeleted, 0);
|
|
|
List<SysOrg> list = baseMapper.selectList(qw);
|
|
|
clearOrgCache();
|
|
|
redisService.setCacheList(CacheConstants.ORG_CACHE_LIST_KEY, list);
|
|
|
@@ -264,9 +265,9 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
public boolean saveOrUpdateOrg(SysOrg org) {
|
|
|
|
|
|
boolean isOk = false;
|
|
|
- if(org.getId() != null){
|
|
|
+ if (org.getId() != null) {
|
|
|
isOk = this.updateById(org);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
isOk = this.save(org);
|
|
|
}
|
|
|
|