优化机构逻辑

This commit is contained in:
阿沐 2023-10-06 15:44:12 +08:00
parent ef21f030b8
commit 7c01b8b0db
2 changed files with 69 additions and 69 deletions

View File

@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import net.maku.framework.common.constant.Constant;
import net.maku.framework.common.utils.Result; import net.maku.framework.common.utils.Result;
import net.maku.framework.operatelog.annotations.OperateLog; import net.maku.framework.operatelog.annotations.OperateLog;
import net.maku.framework.operatelog.enums.OperateTypeEnum; import net.maku.framework.operatelog.enums.OperateTypeEnum;
@ -47,7 +46,7 @@ public class SysOrgController {
SysOrgVO vo = SysOrgConvert.INSTANCE.convert(entity); SysOrgVO vo = SysOrgConvert.INSTANCE.convert(entity);
// 获取上级机构名称 // 获取上级机构名称
if (!Constant.ROOT.equals(entity.getPid())) { if (entity.getPid() != null) {
SysOrgEntity parentEntity = sysOrgService.getById(entity.getPid()); SysOrgEntity parentEntity = sysOrgService.getById(entity.getPid());
vo.setParentName(parentEntity.getName()); vo.setParentName(parentEntity.getName());
} }

View File

@ -1,11 +1,12 @@
package net.maku.system.service.impl; package net.maku.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import net.maku.framework.common.constant.Constant; import net.maku.framework.common.constant.Constant;
import net.maku.framework.common.exception.ServerException; import net.maku.framework.common.exception.ServerException;
import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
import net.maku.framework.common.utils.TreeUtils; import net.maku.framework.common.utils.TreeUtils;
import net.maku.framework.mybatis.service.impl.BaseServiceImpl;
import net.maku.system.convert.SysOrgConvert; import net.maku.system.convert.SysOrgConvert;
import net.maku.system.dao.SysOrgDao; import net.maku.system.dao.SysOrgDao;
import net.maku.system.dao.SysUserDao; import net.maku.system.dao.SysUserDao;
@ -108,7 +109,7 @@ public class SysOrgServiceImpl extends BaseServiceImpl<SysOrgDao, SysOrgEntity>
private void getTree(Long id, List<SysOrgEntity> orgList, List<Long> subIdList) { private void getTree(Long id, List<SysOrgEntity> orgList, List<Long> subIdList) {
for (SysOrgEntity org : orgList) { for (SysOrgEntity org : orgList) {
if (org.getPid().equals(id)){ if (ObjectUtil.equals(org.getPid(), id)) {
getTree(org.getId(), orgList, subIdList); getTree(org.getId(), orgList, subIdList);
subIdList.add(org.getId()); subIdList.add(org.getId());