mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 22:57:17 +08:00 
			
		
		
		
	修复:不再查询父 ID 为 0 的记录的父名称
This commit is contained in:
		| @@ -38,6 +38,11 @@ public class SysConsts { | |||||||
|      */ |      */ | ||||||
|     public static final String ALL_PERMISSION = "*"; |     public static final String ALL_PERMISSION = "*"; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 顶级父 ID | ||||||
|  |      */ | ||||||
|  |     public static final Long SUPER_PARENT_ID = 0L; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 默认密码 |      * 默认密码 | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -20,6 +20,8 @@ import lombok.AccessLevel; | |||||||
| import lombok.NoArgsConstructor; | import lombok.NoArgsConstructor; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
|  |  | ||||||
|  | import cn.hutool.core.util.StrUtil; | ||||||
|  |  | ||||||
| import top.charles7c.cnadmin.common.exception.ServiceException; | import top.charles7c.cnadmin.common.exception.ServiceException; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -60,7 +62,8 @@ public class CheckUtils extends Validator { | |||||||
|      *            字段值 |      *            字段值 | ||||||
|      */ |      */ | ||||||
|     public static void throwIfNull(Object obj, String entityName, String fieldName, Object fieldValue) { |     public static void throwIfNull(Object obj, String entityName, String fieldName, Object fieldValue) { | ||||||
|         String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, entityName); |         String message = | ||||||
|  |             String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, StrUtil.replace(entityName, "DO", "")); | ||||||
|         throwIfNull(obj, message, EXCEPTION_TYPE); |         throwIfNull(obj, message, EXCEPTION_TYPE); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ | |||||||
| package top.charles7c.cnadmin.system.service.impl; | package top.charles7c.cnadmin.system.service.impl; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.Objects; | ||||||
|  |  | ||||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||||
|  |  | ||||||
| @@ -26,6 +27,7 @@ import org.springframework.stereotype.Service; | |||||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||||
|  |  | ||||||
| import top.charles7c.cnadmin.common.base.BaseServiceImpl; | import top.charles7c.cnadmin.common.base.BaseServiceImpl; | ||||||
|  | import top.charles7c.cnadmin.common.constant.SysConsts; | ||||||
| import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum; | ||||||
| import top.charles7c.cnadmin.common.util.ExceptionUtils; | import top.charles7c.cnadmin.common.util.ExceptionUtils; | ||||||
| import top.charles7c.cnadmin.common.util.validate.CheckUtils; | import top.charles7c.cnadmin.common.util.validate.CheckUtils; | ||||||
| @@ -86,6 +88,9 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO, | |||||||
|         super.fillDetail(detailObj); |         super.fillDetail(detailObj); | ||||||
|         if (detailObj instanceof DeptDetailVO) { |         if (detailObj instanceof DeptDetailVO) { | ||||||
|             DeptDetailVO detailVO = (DeptDetailVO)detailObj; |             DeptDetailVO detailVO = (DeptDetailVO)detailObj; | ||||||
|  |             if (Objects.equals(SysConsts.SUPER_PARENT_ID, detailVO.getParentId())) { | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|             detailVO.setParentName(ExceptionUtils.exToNull(() -> this.get(detailVO.getParentId()).getDeptName())); |             detailVO.setParentName(ExceptionUtils.exToNull(() -> this.get(detailVO.getParentId()).getDeptName())); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user