Commit d87033c9 by 314581947

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-platform-auth into developer
parents 15a39174 1f757947
package com.gic.auth.dto;
import java.io.Serializable;
/**
* 权限项列表
* @ClassName: AuthItemListDTO

* @Description: 

* @author guojuxing

* @date 2019/9/20 2:08 PM

*/
public class AuthItemListDTO implements Serializable{
private static final long serialVersionUID = 2961425534296159950L;
private String menuId;
/**
* 操作项名称
*/
private String menuName;
/**
* 操作项数量
*/
private Integer operationItemCount;
public String getMenuId() {
return menuId;
}
public void setMenuId(String menuId) {
this.menuId = menuId;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public Integer getOperationItemCount() {
return operationItemCount;
}
public void setOperationItemCount(Integer operationItemCount) {
this.operationItemCount = operationItemCount;
}
}
......@@ -151,10 +151,13 @@ public class MenuDTO implements Serializable {
/**
* 应用版本名称
*/
@NotBlank(message = "应用版本名称不能为空", groups = { EditAppChildPageValid.class, UpdateOperationItemValid.class })
private String menuVersionName;
private List<MenuDTO> children;
/**
* 是否需要同步生成权限项(新增操作项的时候的可选项)
*/
private boolean needCreateAuthItem;
public Integer getMenuId() {
return menuId;
......@@ -291,4 +294,12 @@ public class MenuDTO implements Serializable {
public void setMenuVersionName(String menuVersionName) {
this.menuVersionName = menuVersionName;
}
public boolean isNeedCreateAuthItem() {
return needCreateAuthItem;
}
public void setNeedCreateAuthItem(boolean needCreateAuthItem) {
this.needCreateAuthItem = needCreateAuthItem;
}
}
......@@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull;
* @author guojuxing

* @date 2019/9/18 5:58 PM

*/
public class AuthItemSaveQO extends PageQO{
public class AuthItemSaveQO extends PageQO {
private static final long serialVersionUID = 3155478932998607869L;
/**
......@@ -21,22 +21,33 @@ public class AuthItemSaveQO extends PageQO{
public interface SaveAuthItemValid {
}
/**
* 编辑权限项参数校验分组
*/
public interface EditAuthItemValid {
}
/**
* 权限项名称
*/
@NotBlank(message = "权限项名称不能为空", groups = {SaveAuthItemValid.class})
@NotBlank(message = "权限项名称不能为空", groups = { SaveAuthItemValid.class, EditAuthItemValid.class })
private String menuName;
/**
* 操作项多选,英文逗号隔开
*/
@NotBlank(message = "操作项不能为空", groups = {SaveAuthItemValid.class})
@NotBlank(message = "操作项不能为空", groups = { SaveAuthItemValid.class, EditAuthItemValid.class })
private String operationItemIds;
/**
* 父级ID
*/
@NotNull(message = "上级页面不能为空", groups = {SaveAuthItemValid.class})
@NotNull(message = "上级页面不能为空", groups = { SaveAuthItemValid.class })
private Integer parentId;
@NotNull(message = "主键ID不能为空", groups = { EditAuthItemValid.class })
private Integer menuId;
public String getMenuName() {
return menuName;
}
......@@ -60,4 +71,12 @@ public class AuthItemSaveQO extends PageQO{
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getMenuId() {
return menuId;
}
public void setMenuId(Integer menuId) {
this.menuId = menuId;
}
}
......@@ -29,7 +29,7 @@ public class MenuListQO extends PageQO{
/**
* 是否需要更新应用列表数据
*/
private boolean isNeedUpdateAppMenu;
private boolean needUpdateAppMenu;
public String getSearch() {
return search;
......@@ -64,10 +64,10 @@ public class MenuListQO extends PageQO{
}
public boolean isNeedUpdateAppMenu() {
return isNeedUpdateAppMenu;
return needUpdateAppMenu;
}
public void setNeedUpdateAppMenu(boolean needUpdateAppMenu) {
isNeedUpdateAppMenu = needUpdateAppMenu;
this.needUpdateAppMenu = needUpdateAppMenu;
}
}
......@@ -2,6 +2,7 @@ package com.gic.auth.service;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.AuthItemListDTO;
import com.gic.auth.dto.MenuDTO;
import com.gic.auth.qo.AuthItemSaveQO;
import com.gic.auth.qo.MenuListQO;
......@@ -33,7 +34,7 @@ public interface MenuApiService {
ServiceResponse<List<MenuDTO>> getSuperAdminMenu(Integer userId, Integer enterpriseId);
/**
* 查询gic菜单树数据
* 查询gic菜单页面树数据
* @Title: listMenuTree

* @Description:

 * @author guojuxing 

......@@ -43,6 +44,16 @@ public interface MenuApiService {
ServiceResponse<List<MenuDTO>> listMenuTree(MenuListQO params);
/**
* 查询菜单树(页面&权限项)
* @Title: listMenuTreeForRole

* @Description:

 * @author guojuxing
* @param project

* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.MenuDTO>>


 */
ServiceResponse<List<MenuDTO>> listMenuTreeForRole(String project);
/**
* 查询页面下面的操作项列表数据
* @Title: listMenuItemByParentId

* @Description:
......@@ -86,9 +97,9 @@ public interface MenuApiService {
* @Description:

 * @author guojuxing
* @param menuDTO

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>


 */
ServiceResponse<Void> saveGICChildPage(MenuDTO menuDTO);
ServiceResponse<Integer> saveGICChildPage(MenuDTO menuDTO);
/**
* 编辑gic子页面
......@@ -114,9 +125,9 @@ public interface MenuApiService {
* @Description:

 * @author guojuxing
* @param menuDTO

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>


 */
ServiceResponse<Void> saveAppChildPage(MenuDTO menuDTO);
ServiceResponse<Integer> saveAppChildPage(MenuDTO menuDTO);
/**
* 编辑应用子页面
* @Title: updateAppChildPage

......@@ -144,9 +155,9 @@ public interface MenuApiService {
* @Description:

 * @author guojuxing
* @param menuDTO

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>


 */
ServiceResponse<Void> saveOperationItem(MenuDTO menuDTO);
ServiceResponse<Integer> saveOperationItem(MenuDTO menuDTO);
/**
* 编辑操作项
......@@ -187,4 +198,24 @@ public interface MenuApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


 */
ServiceResponse<Void> saveAuthItem(AuthItemSaveQO params);
/**
* 编辑权限项
* @Title: updateAuthItem

* @Description:

 * @author guojuxing
* @param params

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


 */
ServiceResponse<Void> updateAuthItem(AuthItemSaveQO params);
/**
* 查询页面下的权限项
* @Title: listAuthItemByMenuId

* @Description:

 * @author guojuxing
* @param menuId

* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.AuthItemListDTO>>


 */
ServiceResponse<List<AuthItemListDTO>> listAuthItemByMenuId(Integer menuId);
}
package com.gic.auth.service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.MenuItemDTO;
import java.util.List;
/**
* 权限项、操作项关联
* @ClassName: MenuItemApiService

* @Description: 

* @author guojuxing

* @date 2019/9/20 1:42 PM

*/
public interface MenuItemApiService {
/**
* 根据权限项ID查询操作项
* @Title: listMenuItemByMenuId

* @Description:

 * @author guojuxing
* @param menuId

* @return com.gic.api.base.commons.ServiceResponse<com.gic.auth.dto.MenuItemDTO>


 */
ServiceResponse<List<MenuItemDTO>> listMenuItemByMenuId(Integer menuId);
}
......@@ -75,4 +75,14 @@ public interface TabSysMenuItemMapper {
* @return void


 */
void deleteByMenuId(@Param("menuId") Integer menuId);
/**
* 根据权限项查询操作项数据
* @Title: listMenuItemByMenuId

* @Description:

 * @author guojuxing
* @param menuId

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


 */
List<TabSysMenuItem> listMenuItemByMenuId(@Param("menuId") Integer menuId);
}
\ No newline at end of file
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;
......@@ -114,4 +116,32 @@ public interface TabSysMenuMapper {
* @return java.util.List<com.gic.auth.entity.TabSysMenu>


 */
List<TabSysMenu> selectByIds(@Param("menuIdList") List<Integer> menuIdList);
/**
* 查询页面下的权限项数据
* @Title: listAuthItemByMenuId

* @Description:

 * @author guojuxing
* @param menuId

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


 */
List<AuthItemListDTO> listAuthItemByMenuId(@Param("menuId") Integer menuId);
/**
* 统计页面下的子项目
* @Title: countChildByParentId

* @Description:

 * @author guojuxing
* @param menuId

* @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
package com.gic.auth.service;
import com.gic.auth.dto.MenuItemDTO;
import com.gic.auth.entity.TabSysMenuItem;
import java.util.List;
/**
......@@ -31,4 +32,14 @@ public interface MenuItemService {
* @return void


 */
void deleteByMenuId(Integer menuId);
/**
* 根据权限项查询操作项
* @Title: listMenuItemByMenuId

* @Description:

 * @author guojuxing
* @param menuId

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


 */
List<TabSysMenuItem> listMenuItemByMenuId(Integer menuId);
}
package com.gic.auth.service;
import com.gic.auth.dto.AuthItemListDTO;
import com.gic.auth.dto.MenuDTO;
import com.gic.auth.entity.TabSysMenu;
import com.gic.auth.qo.MenuListQO;
......@@ -83,4 +84,34 @@ public interface MenuService {
* @return java.util.List<com.gic.auth.entity.TabSysMenu>


 */
List<TabSysMenu> selectByIds(List<Integer> menuIdList);
/**
* 查询页面下的权限项数据
* @Title: listAuthItemByMenuId

* @Description:

 * @author guojuxing
* @param menuId

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


 */
List<AuthItemListDTO> listAuthItemByMenuId(Integer menuId);
/**
* 是否有子项目(子页面、权限项等)
* @Title: isHasChild

* @Description:

 * @author guojuxing
* @param menuId

* @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);
}
......@@ -2,7 +2,9 @@ package com.gic.auth.service.impl;
import com.gic.auth.dao.mapper.TabSysMenuItemMapper;
import com.gic.auth.dto.MenuItemDTO;
import com.gic.auth.entity.TabSysMenuItem;
import com.gic.auth.service.MenuItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -10,6 +12,7 @@ import java.util.List;
@Service("menuItemService")
public class MenuItemServiceImpl implements MenuItemService{
@Autowired
private TabSysMenuItemMapper tabSysMenuItemMapper;
@Transactional(rollbackFor = Exception.class)
......@@ -23,4 +26,9 @@ public class MenuItemServiceImpl implements MenuItemService{
public void deleteByMenuId(Integer menuId) {
tabSysMenuItemMapper.deleteByMenuId(menuId);
}
@Override
public List<TabSysMenuItem> listMenuItemByMenuId(Integer menuId) {
return tabSysMenuItemMapper.listMenuItemByMenuId(menuId);
}
}
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.gic.auth.dto.AuthItemListDTO;
import com.gic.auth.qo.MenuOperationItemListQO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
......@@ -49,6 +50,7 @@ public class MenuServiceImpl implements MenuService {
return tabSysMenuMapper.getMaxSortByParentId(parentId, project);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updatePage(MenuDTO menuDTO) {
TabSysMenu record = EntityUtil.changeEntityNew(TabSysMenu.class, menuDTO);
......@@ -104,6 +106,25 @@ public class MenuServiceImpl implements MenuService {
return tabSysMenuMapper.selectByIds(menuIdList);
}
@Override
public List<AuthItemListDTO> listAuthItemByMenuId(Integer menuId) {
return tabSysMenuMapper.listAuthItemByMenuId(menuId);
}
@Override
public boolean isHasChild(Integer menuId) {
int count = tabSysMenuMapper.countChildByParentId(menuId);
if (count > 0) {
return true;
}
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);
......
package com.gic.auth.service.outer.impl;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.MenuItemDTO;
import com.gic.auth.service.MenuItemApiService;
import com.gic.auth.service.MenuItemService;
import com.gic.commons.util.EntityUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service("menuItemApiService")
public class MenuItemApiServiceImpl implements MenuItemApiService {
@Autowired
private MenuItemService menuItemService;
@Override
public ServiceResponse<List<MenuItemDTO>> listMenuItemByMenuId(Integer menuId) {
List<MenuItemDTO> list = EntityUtil.changeEntityListNew(MenuItemDTO.class,
menuItemService.listMenuItemByMenuId(menuId));
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(list);
}
return ServiceResponse.success(new ArrayList<>());
}
}
......@@ -17,6 +17,7 @@
<!--门店域-->
<dubbo:service interface="com.gic.auth.service.UserApiService" ref="userApiService" timeout="6000" />
<dubbo:service interface="com.gic.auth.service.MenuApiService" ref="menuApiService" timeout="6000" />
<dubbo:service interface="com.gic.auth.service.MenuItemApiService" ref="menuItemApiService" timeout="6000" />
<dubbo:reference interface="com.gic.log.api.service.LogApiService" id="logApiService" timeout="6000" />
<!--资源组-->
<dubbo:service interface="com.gic.auth.service.ResourceApiService" ref="resourceApiService" timeout="6000" />
......
......@@ -122,10 +122,19 @@
</insert>
<update id="deleteByMenuId">
update tab_sys_menu_item set status = 0
where status = 1
and menu_id = #{menuId}
<if test="menuId != null">
update tab_sys_menu_item set status = 0
where status = 1
and menu_id = #{menuId}
</if>
</update>
<select id="listMenuItemByMenuId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_menu_item
where menu_id = #{menuId}
and status = 1
</select>
</mapper>
\ No newline at end of file
......@@ -276,7 +276,7 @@
and menu_type != 2
</if>
<if test="level != null">
level = #{level}
and level = #{level}
</if>
order by level,sort
......@@ -342,4 +342,37 @@
</foreach>
</if>
</select>
<select id="listAuthItemByMenuId" resultType="com.gic.auth.dto.AuthItemListDTO">
select
a.menu_id menuId,
a.menu_name menuName,
(select count(DISTINCT b.item_id) from tab_sys_menu_item b where a.menu_id = b.menu_id and b.status = 1 ) operationItemCount
from tab_sys_menu a
where a.status=1
and a.parent_id = #{menuId}
<include refid="role_filter"></include>
</select>
<select id="countChildByParentId" resultType="int">
select
count(1)
from tab_sys_menu
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 org.apache.dubbo.rpc.RpcContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.constant.GicVersionEnum;
import com.gic.auth.constant.MenuLevelConstants;
import com.gic.auth.constant.MenuProjectConstants;
import com.gic.auth.dto.MenuDTO;
import com.gic.auth.qo.MenuListQO;
import com.gic.auth.service.MenuApiService;
import com.gic.auth.web.vo.MenuDetailVO;
import com.gic.commons.util.EntityUtil;
import com.gic.auth.service.MenuItemApiService;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.response.EnterpriseRestResponse;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.gic.enterprise.utils.UserDetailUtils;
@RestController
public class MenuController {
private final static Logger LOGGER = LogManager.getLogger(MenuController.class);
@Autowired
private MenuApiService menuApiService;
@Autowired
private MenuItemApiService menuItemApiService;
@RequestMapping("login-user-menu")
public RestResponse loginUserMenu(Integer currentMenu){
public RestResponse loginUserMenu(Integer currentMenu) {
Integer userId = UserDetailUtils.getUserDetail().getUserId();
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
System.out.println(JSON.toJSONString(RpcContext.getContext().getAttachments()));
ServiceResponse<List<MenuDTO>> userMenu = this.menuApiService.getUserMenu(userId, enterpriseId, currentMenu);
if(userMenu.isSuccess()){
if (userMenu.isSuccess()) {
return RestResponse.success(userMenu.getResult());
}
return EnterpriseRestResponse.failure(userMenu);
}
/**
* 新增GIC页面
* @Title: saveGICPage

* @Description:

 * @author guojuxing
* @param menuDTO

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


 */
@RequestMapping("/save-gic-page")
public RestResponse saveGICPage(MenuDTO menuDTO) {
return ResultControllerUtils.commonResult(menuApiService.saveGICPage(menuDTO));
}
@RequestMapping("/update-gic-page")
public RestResponse updateGICPage(MenuDTO menuDTO) {
return ResultControllerUtils.commonResult(menuApiService.updateGICPage(menuDTO));
}
@RequestMapping("/delete-menu")
public RestResponse deleteMenu(Integer menuId) {
return ResultControllerUtils.commonResult(menuApiService.deleteMenu(menuId));
}
/**
* 新增gic子页面
* @Title: saveGICChildPage

* @Description:

 * @author guojuxing
* @param menuDTO

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


 */
@RequestMapping("/save-gic-child-page")
public RestResponse saveGICChildPage(MenuDTO menuDTO) {
return ResultControllerUtils.commonResult(menuApiService.saveGICChildPage(menuDTO));
}
@RequestMapping("/update-gic-child-page")
public RestResponse updateGICChildPage(MenuDTO menuDTO) {
return ResultControllerUtils.commonResult(menuApiService.updateGICChildPage(menuDTO));
}
/**
* 编辑应用页面
* @Title: updateAppPage

* @Description:

 * @author guojuxing
* @param menuDTO

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


 */
@RequestMapping("/update-app-page")
public RestResponse updateAppPage(MenuDTO menuDTO) {
return ResultControllerUtils.commonResult(menuApiService.updateAppPage(menuDTO));
}
/**
* 查询列表数据
* @Title: updateAppPage

* @Description:

 * @author guojuxing
* @param params

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


 */
@RequestMapping("/list-menu-tree")
public RestResponse listMenuTree(MenuListQO params) {
ServiceResponse<List<MenuDTO>> result = menuApiService.listMenuTree(params);
if (result.isSuccess()) {
return RestResponse.success(changeListToTree(MenuLevelConstants.FIRST_LEVEL_PARENT_ID, result.getResult()));
}
return EnterpriseRestResponse.failure(result);
}
/**
* 查询页面下面的操作项列表数据
* @Title: listMenuRole

* @Description:

 * @author guojuxing
* @param parentId

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


 */
@RequestMapping("/list-menu-item")
public RestResponse listMenuItem(Integer parentId) {
return ResultControllerUtils.commonResult(menuApiService.listMenuItemByParentId(parentId));
}
@RequestMapping("/set-menu-sort")
public RestResponse listMenuRole(Integer id, Integer sort) {
return ResultControllerUtils.commonResult(menuApiService.setSort(id, sort));
}
@RequestMapping("/get-menu-version-by-id")
public RestResponse getMenuVersionById(Integer id) {
ServiceResponse<MenuDTO> result = menuApiService.getDetailById(id);
if (result.isSuccess()) {
return RestResponse.success(getMenuVersionMap(result.getResult()));
}
return EnterpriseRestResponse.failure(result);
}
@RequestMapping("/get-menu-detail-by-id")
public RestResponse getMenuDetailById(Integer id) {
ServiceResponse<MenuDTO> result = menuApiService.getDetailById(id);
if (result.isSuccess()) {
MenuDTO dto = result.getResult();
MenuDetailVO vo = EntityUtil.changeEntityNew(MenuDetailVO.class, dto);
vo.setMap(getMenuVersionMap(result.getResult()));
return RestResponse.success(vo);
}
return EnterpriseRestResponse.failure(result);
}
@RequestMapping("/save-operation-item")
public RestResponse saveOperationItem(MenuDTO menuDTO) {
return ResultControllerUtils.commonResult(menuApiService.saveOperationItem(menuDTO));
}
@RequestMapping("/update-operation-item")
public RestResponse updateOperationItem(MenuDTO menuDTO) {
return ResultControllerUtils.commonResult(menuApiService.updateOperationItem(menuDTO));
}
private static Map<String, String> getMenuVersionMap(MenuDTO dto) {
Map<String, String> map = new HashMap<>(16);
if (dto.getProject().equals(MenuProjectConstants.DEFAULT_PROJECT) && dto.getLevel() == 1) {
for (GicVersionEnum versionEnum : GicVersionEnum.values()) {
map.put(String.valueOf(versionEnum.getCode()), versionEnum.getMessage());
}
} else {
String menuVersion = dto.getMenuVersion();
String menuVersionName = dto.getMenuVersionName();
String[] menuVersionArr = menuVersion.substring(1, menuVersion.length() - 1).split("_");
String[] menuVersionNameArr = menuVersionName.split("/");
for (int i = 0, len = menuVersionArr.length; i < len; i++) {
map.put(menuVersionArr[i], menuVersionNameArr[i]);
}
}
return map;
}
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;
}
}
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;
}
}
package com.gic.auth.web.vo;
import java.io.Serializable;
import java.util.Map;
/**
* 页面、子页面、操作项等详情
* @ClassName: GicMenuDetailVO

* @Description: 

* @author guojuxing

* @date 2019/9/18 4:47 PM

*/
public class MenuDetailVO implements Serializable{
private static final long serialVersionUID = -6360620959633903701L;
/**
*
*/
private Integer menuId;
/**
* 菜单名称
*/
private String menuName;
/**
* 菜单路由
*/
private String menuUrl;
/**
* 上级菜单id
*/
private Integer parentId;
/**
* 0当前页1新开页
*/
private Integer target;
/**
*
*/
private String iconUrl;
/**
* 是否显示在菜单栏的菜单,0否1是
*/
private Integer isShow;
/**
* 页面code
*/
private String menuCode;
/**
* 父级code
*/
private String parentCode;
/**
* 多选,例如_1_2_格式,如果是GIC菜单 1gic标准版 2gic集团版;如果是应用菜单 1:基础班 2:高级版
*/
private String menuVersion;
private Map<String, String> map;
public Integer getMenuId() {
return menuId;
}
public void setMenuId(Integer menuId) {
this.menuId = menuId;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public String getMenuUrl() {
return menuUrl;
}
public void setMenuUrl(String menuUrl) {
this.menuUrl = menuUrl;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getTarget() {
return target;
}
public void setTarget(Integer target) {
this.target = target;
}
public String getIconUrl() {
return iconUrl;
}
public void setIconUrl(String iconUrl) {
this.iconUrl = iconUrl;
}
public Integer getIsShow() {
return isShow;
}
public void setIsShow(Integer isShow) {
this.isShow = isShow;
}
public String getMenuCode() {
return menuCode;
}
public void setMenuCode(String menuCode) {
this.menuCode = menuCode;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getMenuVersion() {
return menuVersion;
}
public void setMenuVersion(String menuVersion) {
this.menuVersion = menuVersion;
}
public Map<String, String> getMap() {
return map;
}
public void setMap(Map<String, String> map) {
this.map = map;
}
}
......@@ -36,6 +36,7 @@
<dubbo:reference interface="com.gic.store.service.StoreStatusSettingApiService" id="storeStatusSettingApiService" timeout="60000" />
<dubbo:reference interface="com.gic.log.api.service.LogApiService" id="logApiService" timeout="60000" />
<dubbo:reference interface="com.gic.auth.service.MenuApiService" id="menuApiService" timeout="6000" />
<dubbo:reference interface="com.gic.auth.service.MenuItemApiService" id="menuItemApiService" timeout="6000" />
<dubbo:reference interface="com.gic.enterprise.service.EnterpriseApiService" id="enterpriseApiService" timeout="6000" />
<dubbo:reference interface="com.gic.auth.service.UserApiService" id="userApiService" timeout="6000" />
......
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