Commit 866591c1 by guojuxing

编辑为仅超管可用时候,删除权限项关联

parent c1c0b584
...@@ -2,6 +2,7 @@ package com.gic.auth.dao.mapper; ...@@ -2,6 +2,7 @@ package com.gic.auth.dao.mapper;
import java.util.List; import java.util.List;
import com.gic.auth.dto.AuthItemDTO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.gic.auth.dto.MenuItemDTO; import com.gic.auth.dto.MenuItemDTO;
...@@ -96,4 +97,19 @@ public interface TabSysMenuItemMapper { ...@@ -96,4 +97,19 @@ public interface TabSysMenuItemMapper {
* @return java.util.List<java.lang.Integer>
 * @return java.util.List<java.lang.Integer>


 */ 
 */
List<Integer> getOperationItemIdList(); List<Integer> getOperationItemIdList();
/**
* 根据操作项ID分组查询权限项和权限项内的操作项数量
* @Title: queryAuthItem

* @Description:

 * @author guojuxing
* @param itemId

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


 */
List<AuthItemDTO> queryAuthItem(@Param("itemId") Integer itemId);
void deleteByMenuIdList(@Param("list") List<Integer> menuId);
void deleteByItemId(@Param("itemId") Integer itemId);
} }
\ No newline at end of file
package com.gic.auth.service; package com.gic.auth.service;
import com.gic.auth.dto.AuthItemDTO;
import com.gic.auth.dto.MenuItemDTO; import com.gic.auth.dto.MenuItemDTO;
import com.gic.auth.entity.TabSysMenuItem; import com.gic.auth.entity.TabSysMenuItem;
...@@ -33,6 +34,18 @@ public interface MenuItemService { ...@@ -33,6 +34,18 @@ public interface MenuItemService {

 */ 
 */
void deleteByMenuId(Integer menuId); void deleteByMenuId(Integer menuId);
void deleteByMenuIdList(List<Integer> menuId);
/**
* 根据操作项ID删除关联
* @Title: deleteByItemId

* @Description:

 * @author guojuxing
* @param itemId

* @return void


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

...@@ -54,5 +67,15 @@ public interface MenuItemService { ...@@ -54,5 +67,15 @@ public interface MenuItemService {

 */ 
 */
List<Integer> getOperationItemIdList(); List<Integer> getOperationItemIdList();
/**
* 根据操作项ID分组查询权限项和权限项内的操作项数量
* @Title: listAuthItemGroupByItemId

* @Description:

 * @author guojuxing
* @param itemId

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


 */
List<AuthItemDTO> listAuthItemGroupByItemId(Integer itemId);
} }
package com.gic.auth.service.impl; package com.gic.auth.service.impl;
import com.gic.auth.dao.mapper.TabSysMenuItemMapper; import com.gic.auth.dao.mapper.TabSysMenuItemMapper;
import com.gic.auth.dto.AuthItemDTO;
import com.gic.auth.dto.MenuItemDTO; import com.gic.auth.dto.MenuItemDTO;
import com.gic.auth.entity.TabSysMenuItem; import com.gic.auth.entity.TabSysMenuItem;
import com.gic.auth.service.MenuItemService; import com.gic.auth.service.MenuItemService;
...@@ -30,6 +31,16 @@ public class MenuItemServiceImpl implements MenuItemService{ ...@@ -30,6 +31,16 @@ public class MenuItemServiceImpl implements MenuItemService{
} }
@Override @Override
public void deleteByMenuIdList(List<Integer> menuId) {
tabSysMenuItemMapper.deleteByMenuIdList(menuId);
}
@Override
public void deleteByItemId(Integer itemId) {
tabSysMenuItemMapper.deleteByItemId(itemId);
}
@Override
public List<TabSysMenuItem> listMenuItemByMenuId(Integer menuId) { public List<TabSysMenuItem> listMenuItemByMenuId(Integer menuId) {
return tabSysMenuItemMapper.listMenuItemByMenuId(menuId); return tabSysMenuItemMapper.listMenuItemByMenuId(menuId);
} }
...@@ -46,4 +57,9 @@ public class MenuItemServiceImpl implements MenuItemService{ ...@@ -46,4 +57,9 @@ public class MenuItemServiceImpl implements MenuItemService{
public List<Integer> getOperationItemIdList() { public List<Integer> getOperationItemIdList() {
return tabSysMenuItemMapper.getOperationItemIdList(); return tabSysMenuItemMapper.getOperationItemIdList();
} }
@Override
public List<AuthItemDTO> listAuthItemGroupByItemId(Integer itemId) {
return tabSysMenuItemMapper.queryAuthItem(itemId);
}
} }
...@@ -264,7 +264,8 @@ public class MenuApiServiceImpl implements MenuApiService { ...@@ -264,7 +264,8 @@ public class MenuApiServiceImpl implements MenuApiService {
menuDTO.setMenuType(MenuTypeEnum.OPERATION.getCode()); menuDTO.setMenuType(MenuTypeEnum.OPERATION.getCode());
ServiceResponse<Integer> saveOperationItemResult = saveChildPage(menuDTO, MenuDTO.SaveOperationItemValid.class); ServiceResponse<Integer> saveOperationItemResult = saveChildPage(menuDTO, MenuDTO.SaveOperationItemValid.class);
if (saveOperationItemResult.isSuccess()) { if (saveOperationItemResult.isSuccess()) {
if (menuDTO.getAdminOnlySign() != null && menuDTO.getAdminOnlySign().intValue() == MenuOperationItemConstants.ADMIN_ONLY) { if (menuDTO.getAdminOnlySign() != null
&& menuDTO.getAdminOnlySign().intValue() == MenuOperationItemConstants.ADMIN_ONLY) {
//如果是仅超管可用,则不同步生成权限项 //如果是仅超管可用,则不同步生成权限项
} else if (menuDTO.isNeedCreateAuthItem()) { } else if (menuDTO.isNeedCreateAuthItem()) {
//同步生成权限项 //同步生成权限项
...@@ -530,6 +531,26 @@ public class MenuApiServiceImpl implements MenuApiService { ...@@ -530,6 +531,26 @@ public class MenuApiServiceImpl implements MenuApiService {
//同时更新子集的父级code数据 //同时更新子集的父级code数据
menuService.updateParentCodeByParentId(menuDTO.getMenuId(), menuDTO.getMenuCode()); menuService.updateParentCodeByParentId(menuDTO.getMenuId(), menuDTO.getMenuCode());
//是否是操作项,并且编辑为仅超管可用
//如果有权限项,
boolean isEditToAdminOnly = menuTypeEnum.getCode() == MenuTypeEnum.OPERATION.getCode()
&& menuDTO.getAdminOnlySign() != null
&& menuDTO.getAdminOnlySign().intValue() == MenuOperationItemConstants.ADMIN_ONLY;
if (isEditToAdminOnly) {
//判断是否挂在某个权限项下面
List<AuthItemDTO> authItemDTOList = menuItemService.listAuthItemGroupByItemId(record.getMenuId());
List<Integer> authItemIdList = new ArrayList<>();
for (AuthItemDTO authItemDTO : authItemDTOList) {
if (authItemDTO.getOperationItemCount().intValue() <= 1) {
//判断下面的操作项数量,如果只有一个,则删除该权限项(因为仅超管可用,不再需要权限项)
authItemIdList.add(authItemDTO.getMenuId());
}
}
//删除权限项
menuItemService.deleteByMenuIdList(authItemIdList);
//删除操作项
menuItemService.deleteByItemId(record.getMenuId());
}
return ServiceResponse.success(); return ServiceResponse.success();
} }
...@@ -681,7 +702,6 @@ public class MenuApiServiceImpl implements MenuApiService { ...@@ -681,7 +702,6 @@ public class MenuApiServiceImpl implements MenuApiService {
String[] menuVersionArr = menuDTO.getMenuVersion().split(SignConstants.UNDERLINE); String[] menuVersionArr = menuDTO.getMenuVersion().split(SignConstants.UNDERLINE);
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
Map<String, String> gicDefaultVersion = getGicDefaultVersion().getResult(); Map<String, String> gicDefaultVersion = getGicDefaultVersion().getResult();
for (String str : menuVersionArr) { for (String str : menuVersionArr) {
if (StringUtils.isBlank(str)) { if (StringUtils.isBlank(str)) {
......
...@@ -156,4 +156,33 @@ ...@@ -156,4 +156,33 @@
where status = 1 where status = 1
GROUP by item_id GROUP by item_id
</select> </select>
<select id="queryAuthItem" resultType="com.gic.auth.dto.AuthItemDTO">
select menu_id menuId,
count(1) operationItemCount
from tab_sys_menu_item
where status = 1
and item_id = #{itemId}
group by menu_id
</select>
<update id="deleteByMenuIdList">
<if test="list != null and list.size() > 0">
update tab_sys_menu_item set status = 0
where status = 1
and menu_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</update>
<update id="deleteByItemId">
<if test="itemId != null">
update tab_sys_menu_item set status = 0
where status = 1
and item_id = #{itemId}
</if>
</update>
</mapper> </mapper>
\ No newline at end of file
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