Просмотр исходного кода

:tada: 修复dict、role不选择父节点报错

smallchill 6 лет назад
Родитель
Сommit
da07245493

+ 5 - 0
src/main/java/org/springblade/common/constant/CommonConstant.java

@@ -70,6 +70,11 @@ public interface CommonConstant {
 	 */
 	String DEFAULT_PASSWORD = "123456";
 
+	/**
+	 * 默认排序字段
+	 */
+	String SORT_FIELD = "sort";
+
 	/**
 	 * 动态获取sentinel地址
 	 *

+ 3 - 0
src/main/java/org/springblade/modules/system/service/impl/DictServiceImpl.java

@@ -72,6 +72,9 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements ID
 		if (cnt > 0) {
 			throw new ApiException("当前字典键值已存在!");
 		}
+		if (Func.isEmpty(dict.getParentId())) {
+			dict.setParentId(BladeConstant.TOP_PARENT_ID);
+		}
 		dict.setIsDeleted(BladeConstant.DB_NOT_DELETED);
 		return saveOrUpdate(dict);
 	}

+ 4 - 1
src/main/java/org/springblade/modules/system/service/impl/RoleServiceImpl.java

@@ -134,12 +134,15 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
 
 	@Override
 	public boolean submit(Role role) {
-		role.setIsDeleted(BladeConstant.DB_NOT_DELETED);
 		if (!SecureUtil.isAdministrator()) {
 			if (Func.toStr(role.getRoleAlias()).equals(RoleConstant.ADMINISTRATOR)) {
 				throw new ServiceException("无权限创建超管角色!");
 			}
 		}
+		if (Func.isEmpty(role.getParentId())) {
+			role.setParentId(BladeConstant.TOP_PARENT_ID);
+		}
+		role.setIsDeleted(BladeConstant.DB_NOT_DELETED);
 		return saveOrUpdate(role);
 	}