Commit c011684e by guojuxing

删除接口

parent 194dd2d9
......@@ -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.entity.TabSysMenu;
import com.gic.auth.qo.MenuListQO;
import com.gic.auth.qo.MenuOperationItemListQO;
......@@ -114,4 +115,23 @@ 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);
}
\ 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,24 @@ 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);
}
......@@ -2,6 +2,7 @@ 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;
......@@ -25,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;
......@@ -105,6 +106,20 @@ 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;
}
private void updateSort(Integer sort, Integer id) {
TabSysMenu record = new TabSysMenu();
record.setMenuId(id);
......
......@@ -5,6 +5,7 @@ import java.util.*;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.auth.constant.*;
import com.gic.auth.dto.AuthItemListDTO;
import com.gic.auth.dto.MenuItemDTO;
import com.gic.auth.qo.AuthItemSaveQO;
import com.gic.auth.qo.MenuOperationItemListQO;
......@@ -105,6 +106,16 @@ public class MenuApiServiceImpl implements MenuApiService {
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "主键参数有误,查无数据");
}
if (record.getMenuType().intValue() == MenuTypeEnum.PAGE.getCode()) {
//如果是页面,判断下面是否有子页面
if (menuService.isHasChild(menuId)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "页面下有项目,不允许删除词页面");
}
} else if (record.getMenuType().intValue() == MenuTypeEnum.ROLE.getCode()) {
//权限项,需要同时删除关联表
menuItemService.deleteByMenuId(menuId);
}
MenuDTO menuDTO = new MenuDTO();
menuDTO.setMenuId(menuId);
menuDTO.setStatus(0);
......@@ -313,6 +324,16 @@ public class MenuApiServiceImpl implements MenuApiService {
return ServiceResponse.success();
}
@Override
public ServiceResponse<List<AuthItemListDTO>> listAuthItemByMenuId(Integer menuId) {
TabSysMenu record = menuService.getMenuById(menuId);
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "参数有误,没有页面");
}
List<AuthItemListDTO> authItemList = menuService.listAuthItemByMenuId(menuId);
return ServiceResponse.success(authItemList);
}
private ServiceResponse<Void> savePage(MenuDTO menuDTO, Class clazz) {
ServiceResponse paramsValid = ValidParamsUtils.allCheckValidate(menuDTO, clazz);
if (!paramsValid.isSuccess()) {
......
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" />
......
......@@ -129,4 +129,12 @@
</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
......@@ -342,4 +342,22 @@
</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
</select>
<select id="countChildByParentId" resultType="int">
select
count(1)
from tab_sys_menu
where status = 1
and parent_id = #{menuId}
</select>
</mapper>
\ No newline at end of file
......@@ -5,8 +5,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.gic.auth.constant.SignConstants;
import com.gic.auth.constant.*;
import com.gic.auth.dto.MenuItemDTO;
import com.gic.auth.qo.AuthItemSaveQO;
import com.gic.auth.service.MenuItemApiService;
import com.gic.auth.web.vo.MenuOperationItemVO;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.logging.log4j.LogManager;
......@@ -17,9 +19,6 @@ 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;
......@@ -36,6 +35,8 @@ 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) {
......@@ -190,9 +191,20 @@ public class MenuController {
if (result.isSuccess()) {
MenuDTO dto = result.getResult();
MenuDetailVO vo = EntityUtil.changeEntityNew(MenuDetailVO.class, dto);
String menuVersion = dto.getMenuVersion().substring(1, dto.getMenuVersion().length() - 1);
vo.setMenuVersion(menuVersion.replaceAll(SignConstants.UNDERLINE, SignConstants.COMMA));
vo.setMap(getMenuVersionMap(result.getResult()));
if (dto.getMenuType().intValue() == MenuTypeEnum.ROLE.getCode()) {
//权限项
List<MenuItemDTO> menuItemDTOList = menuItemApiService.listMenuItemByMenuId(id).getResult();
StringBuilder itemIds = new StringBuilder();
for (MenuItemDTO menuItemDTO : menuItemDTOList) {
itemIds.append(menuItemDTO.getItemId()).append(SignConstants.COMMA);
}
String tempItemIds = itemIds.toString();
vo.setOperationItemIds(tempItemIds.substring(0, tempItemIds.length() - 1));
} else {
String menuVersion = dto.getMenuVersion().substring(1, dto.getMenuVersion().length() - 1);
vo.setMenuVersion(menuVersion.replaceAll(SignConstants.UNDERLINE, SignConstants.COMMA));
vo.setMap(getMenuVersionMap(result.getResult()));
}
return RestResponse.success(vo);
}
return EnterpriseRestResponse.failure(result);
......@@ -218,6 +230,19 @@ public class MenuController {
return ResultControllerUtils.commonResult(menuApiService.updateAuthItem(params));
}
/**
* 查询页面下的权限项列表数据
* @Title: listAuthItem

* @Description:

 * @author guojuxing
* @param menuId

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


 */
@RequestMapping("/list-auth-item")
public RestResponse listAuthItem(Integer menuId) {
return ResultControllerUtils.commonResult(menuApiService.listAuthItemByMenuId(menuId));
}
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) {
......
......@@ -63,6 +63,11 @@ public class MenuDetailVO implements Serializable{
*/
private String menuVersion;
/**
* 操作项ID,如果是权限项,有该值
*/
private String operationItemIds;
private Map<String, String> map;
public Integer getMenuId() {
......@@ -152,4 +157,12 @@ public class MenuDetailVO implements Serializable{
public void setMap(Map<String, String> map) {
this.map = map;
}
public String getOperationItemIds() {
return operationItemIds;
}
public void setOperationItemIds(String operationItemIds) {
this.operationItemIds = operationItemIds;
}
}
......@@ -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