From d94dafb47da82e300b26a1f9b87c51fdbbabd1a9 Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Fri, 23 Apr 2021 17:51:09 +0800
Subject: [PATCH] 通过角色id查询子菜单
---
screen-manage/src/main/java/com/moral/api/pojo/vo/login/AccountInfoVO.java | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/screen-manage/src/main/java/com/moral/api/pojo/vo/login/AccountInfoVO.java b/screen-manage/src/main/java/com/moral/api/pojo/vo/login/AccountInfoVO.java
index 4edf55a..5267d67 100644
--- a/screen-manage/src/main/java/com/moral/api/pojo/vo/login/AccountInfoVO.java
+++ b/screen-manage/src/main/java/com/moral/api/pojo/vo/login/AccountInfoVO.java
@@ -6,6 +6,7 @@
import com.moral.api.entity.ManageRole;
import com.moral.api.pojo.dto.login.AccountInfoDTO;
import lombok.Data;
+import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
@@ -42,32 +43,26 @@
private List<ManageMenu> menus;
/**
- * @Description: DTO������VO
- * @Param: [dto]
- * @return: com.moral.api.pojo.vo.login.AccountInfoVO
- * @Author: ���������
- * @Date: 2021/3/13
- */
- public static AccountInfoVO convert(AccountInfoDTO dto){
+ * @Description: DTO������VO
+ * @Param: [dto]
+ * @return: com.moral.api.pojo.vo.login.AccountInfoVO
+ * @Author: ���������
+ * @Date: 2021/3/13
+ */
+ public static AccountInfoVO convert(AccountInfoDTO dto) {
AccountInfoVO vo = new AccountInfoVO();
ManageAccount account = dto.getAccount();
List<ManageMenu> menus = dto.getMenus();
List<ManageRole> roles = dto.getRoles();
//������roleNames
ArrayList<String> roleNames = new ArrayList<>();
- roles.forEach(role->roleNames.add(role.getName()));
+ if (!ObjectUtils.isEmpty(roles)) {
+ roles.forEach(role -> roleNames.add(role.getName()));
+ }
/*������menu������������*/
- for (ManageMenu menu : menus) {
- menu.setCreateTime(null);
- menu.setIsDelete(null);
- menu.setUpdateTime(null);
- menu.setParentId(null);
- List<ManageMenu> children = menu.getChildren();
- for (ManageMenu child : children) {
- child.setCreateTime(null);
- child.setIsDelete(null);
- child.setUpdateTime(null);
- child.setParentId(null);
+ if (!ObjectUtils.isEmpty(menus)) {
+ for (ManageMenu menu : menus) {
+ removeAttribute(menu);
}
}
vo.setAccountId(account.getId());
@@ -77,4 +72,17 @@
return vo;
}
+ public static void removeAttribute(ManageMenu menu) {
+ menu.setCreateTime(null);
+ menu.setIsDelete(null);
+ menu.setUpdateTime(null);
+ menu.setParentId(null);
+ if (ObjectUtils.isEmpty(menu.getChildren()))
+ return;
+ List<ManageMenu> children = menu.getChildren();
+ for (ManageMenu child : children) {
+ removeAttribute(child);
+ }
+ }
+
}
--
Gitblit v1.8.0