|
@@ -4,6 +4,7 @@ import com.ym.mec.auth.api.dto.MenuQueryInfo;
|
|
|
import com.ym.mec.auth.api.entity.SysMenu;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.auth.api.enums.SysUserType;
|
|
|
+import com.ym.mec.auth.api.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.auth.dal.dao.SysMenuDao;
|
|
|
import com.ym.mec.auth.dal.dao.SysUserDao;
|
|
|
import com.ym.mec.auth.service.SysMenuService;
|
|
@@ -18,6 +19,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class SysMenuServiceImpl extends BaseServiceImpl<Integer, SysMenu> implements SysMenuService {
|
|
@@ -38,37 +40,19 @@ public class SysMenuServiceImpl extends BaseServiceImpl<Integer, SysMenu> imple
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo<SysMenu> findByUser(MenuQueryInfo menuQueryInfo) {
|
|
|
+ public List<SysMenu> findByUser(MenuQueryInfo menuQueryInfo) {
|
|
|
SysUser sysUser = sysUserDao.get(menuQueryInfo.getUserId());
|
|
|
- PageInfo<SysMenu> pageInfo = null;
|
|
|
+ List<SysMenu> sysMenus = null;
|
|
|
if(sysUser.getUserType() == SysUserType.SYSTEM){
|
|
|
- pageInfo = findBySys(menuQueryInfo);
|
|
|
+ menuQueryInfo.setUserId(null);
|
|
|
+ sysMenus = sysMenuDao.findList(menuQueryInfo.getParentId(),menuQueryInfo.getDelFlag());
|
|
|
}else {
|
|
|
- pageInfo = queryPage(menuQueryInfo);
|
|
|
+ sysMenus = sysMenuDao.findByParentId(menuQueryInfo.getParentId(),menuQueryInfo.getDelFlag(),menuQueryInfo.getUserId());
|
|
|
}
|
|
|
- for (SysMenu menu:pageInfo.getRows()) {
|
|
|
+ for (SysMenu menu:sysMenus) {
|
|
|
menu = getTree(menu,menuQueryInfo.getDelFlag(),menuQueryInfo.getUserId());
|
|
|
}
|
|
|
- return pageInfo;
|
|
|
- }
|
|
|
-
|
|
|
- private PageInfo<SysMenu> findBySys(MenuQueryInfo menuQueryInfo){
|
|
|
- PageInfo<SysMenu> pageInfo = new PageInfo<>(menuQueryInfo.getPage(), menuQueryInfo.getRows());
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- MapUtil.populateMap(params, menuQueryInfo);
|
|
|
-
|
|
|
- List<SysMenu> dataList = null;
|
|
|
- int count = sysMenuDao.findCountBySys(params);
|
|
|
- if (count > 0) {
|
|
|
- pageInfo.setTotal(count);
|
|
|
- params.put("offset", pageInfo.getOffset());
|
|
|
- dataList = sysMenuDao.findList(menuQueryInfo.getParentId(),menuQueryInfo.getDelFlag());
|
|
|
- }
|
|
|
- if (count == 0) {
|
|
|
- dataList = new ArrayList<>();
|
|
|
- }
|
|
|
- pageInfo.setRows(dataList);
|
|
|
- return pageInfo;
|
|
|
+ return sysMenus;
|
|
|
}
|
|
|
|
|
|
private SysMenu getTree(SysMenu menu, String delFlag,Integer userId){
|
|
@@ -96,4 +80,19 @@ public class SysMenuServiceImpl extends BaseServiceImpl<Integer, SysMenu> imple
|
|
|
public SysMenu findMenuByPermission(String permission){
|
|
|
return sysMenuDao.findMenuByPermission(permission);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void recursiveDel(Integer parentId) {
|
|
|
+ List<SysMenu> sysMenus = sysMenuDao.findList(parentId, "0");
|
|
|
+ for (SysMenu menu:sysMenus) {
|
|
|
+ menu = getTree(menu,"0",null);
|
|
|
+ }
|
|
|
+ List<Integer> collect = sysMenus.stream().map(sysMenu -> sysMenu.getId()).collect(Collectors.toList());
|
|
|
+ if(collect == null || collect.size() <= 0){
|
|
|
+ sysMenuDao.delete(parentId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ collect.add(parentId);
|
|
|
+ sysMenuDao.batchDel(collect);
|
|
|
+ }
|
|
|
}
|