Commit 1f757947 by guojuxing

权限集:菜单树接口:页面&权限项

parent e0d76db7
package com.gic.auth.dao.mapper;
import com.gic.auth.dto.AuthItemListDTO;
import com.gic.auth.dto.MenuDTO;
import com.gic.auth.entity.TabSysMenu;
import com.gic.auth.qo.MenuListQO;
import com.gic.auth.qo.MenuOperationItemListQO;
......@@ -134,4 +135,13 @@ public interface TabSysMenuMapper {
* @return int


 */
int countChildByParentId(@Param("menuId") Integer menuId);
/**
* 查询菜单树(页面&权限项)
* @Title: listMenuTree

* @Description:

 * @author guojuxing
* @param project

* @return java.util.List<com.gic.auth.entity.TabSysMenu>


 */
List<TabSysMenu> listMenuTree(@Param("project") String project);
}
\ No newline at end of file
......@@ -104,4 +104,14 @@ public interface MenuService {
* @return boolean


 */
boolean isHasChild(Integer menuId);
/**
* 查询菜单树(页面&权限项)
* @Title: listMenuTree

* @Description:

 * @author guojuxing
* @param project

* @return java.util.List<com.gic.auth.dto.MenuDTO>


 */
List<TabSysMenu> listMenuTree(String project);
}
......@@ -120,6 +120,11 @@ public class MenuServiceImpl implements MenuService {
return false;
}
@Override
public List<TabSysMenu> listMenuTree(String project) {
return tabSysMenuMapper.listMenuTree(project);
}
private void updateSort(Integer sort, Integer id) {
TabSysMenu record = new TabSysMenu();
record.setMenuId(id);
......
......@@ -14,6 +14,7 @@ import com.gic.commons.util.PageHelperUtils;
import com.gic.open.api.dto.ApplicationDTO;
import com.gic.open.api.dto.ServePropDTO;
import com.gic.open.api.service.ApplicationApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -81,6 +82,15 @@ public class MenuApiServiceImpl implements MenuApiService {
}
@Override
public ServiceResponse<List<MenuDTO>> listMenuTreeForRole(String project) {
List<TabSysMenu> list = menuService.listMenuTree(project);
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(EntityUtil.changeEntityListNew(MenuDTO.class, list));
}
return ServiceResponse.success(new ArrayList<>());
}
@Override
public ServiceResponse<List<MenuDTO>> listMenuItemByParentId(Integer parentId) {
TabSysMenu record = menuService.getMenuById(parentId);
if (record == null) {
......
......@@ -362,4 +362,17 @@
where status = 1
and parent_id = #{menuId}
</select>
<select id="listMenuTree" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_menu
where status=1
<if test="project != null">
and project = #{project}
</if>
<include refid="tree_filter"></include>
order by level,sort
</select>
</mapper>
\ No newline at end of file
package com.gic.auth.web.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.gic.auth.constant.MenuLevelConstants;
import com.gic.auth.constant.MenuProjectConstants;
import com.gic.auth.qo.MenuListQO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -83,4 +90,46 @@ public class RoleController {
return EnterpriseRestResponse.failure(userResponse);
}
}
/**
* 查询列表数据
* @Title: updateAppPage

* @Description:

 * @author guojuxing
* @return com.gic.commons.webapi.reponse.RestResponse


 */
@RequestMapping("/list-gic-menu-tree")
public RestResponse listMenuTree() {
ServiceResponse<List<MenuDTO>> result = menuApiService.listMenuTreeForRole(MenuProjectConstants.DEFAULT_PROJECT);
if (result.isSuccess()) {
return RestResponse.success(changeListToTree(MenuLevelConstants.FIRST_LEVEL_PARENT_ID, result.getResult()));
}
return EnterpriseRestResponse.failure(result);
}
public static List<Map<String, Object>> changeListToTree(int storeGroupId, List<MenuDTO> list) {
List<Map<String, Object>> result = new ArrayList<>();
if (list != null) {
for (MenuDTO menuDTO : list) {
if (storeGroupId == menuDTO.getParentId() && menuDTO.getIsShow().intValue() == 1) {
Map<String, Object> data = new HashMap<>(16);
data.put("menuId", menuDTO.getMenuId());
data.put("menuName", menuDTO.getMenuName());
data.put("project", menuDTO.getProject());
data.put("sort", menuDTO.getSort());
data.put("menuCode", menuDTO.getMenuCode());
data.put("parentCode", menuDTO.getParentCode());
data.put("menuVersionName", menuDTO.getMenuVersionName());
List<Map<String, Object>> children = changeListToTree(menuDTO.getMenuId(), list);
if (children == null || children.size() < 1) {
data.put("children", null);
} else {
data.put("children", children);
}
result.add(data);
}
}
}
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment