|
@@ -1,6 +1,7 @@
|
|
package com.judong.chuanyiserver.service.impl;
|
|
package com.judong.chuanyiserver.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.judong.chuanyiserver.dao.MenuDao;
|
|
import com.judong.chuanyiserver.dao.RoleDao;
|
|
import com.judong.chuanyiserver.dao.RoleDao;
|
|
import com.judong.chuanyiserver.entity.Menu;
|
|
import com.judong.chuanyiserver.entity.Menu;
|
|
import com.judong.chuanyiserver.entity.Role;
|
|
import com.judong.chuanyiserver.entity.Role;
|
|
@@ -27,6 +28,9 @@ public class RoleServiceImpl implements RoleService {
|
|
@Resource
|
|
@Resource
|
|
private UserUtil userUtil;
|
|
private UserUtil userUtil;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private MenuDao menuDao;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public synchronized Result addRole(Role role) {
|
|
public synchronized Result addRole(Role role) {
|
|
if (Blank.isNotEmpty(roleDao.getRoleByName(role.getRoleName()))) {
|
|
if (Blank.isNotEmpty(roleDao.getRoleByName(role.getRoleName()))) {
|
|
@@ -211,10 +215,38 @@ public class RoleServiceImpl implements RoleService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result queryRoleAndMenuId(Integer roleId) {
|
|
|
|
- return Result.ok(roleDao.queryRoleAndMenuId(roleId));
|
|
|
|
|
|
+ public Result queryRoleAndMenuId(Integer roleId,Integer page,Integer num) {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ Integer count = roleDao.queryRoleAndMenuIdNum(roleId);
|
|
|
|
+ Integer stattPage=(page-1)*num;
|
|
|
|
+ List<Menu> menuList = roleDao.queryRoleAndMenuIdPage(roleId, stattPage, num);
|
|
|
|
+ jsonObject.put("count",count);
|
|
|
|
+ jsonObject.put("menuList",menuList);
|
|
|
|
+ return Result.ok(jsonObject);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Result queryNotRoleAndMenu(Integer roleId, Integer page, Integer num) {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ Integer count = roleDao.queryNotRoleAndMenuNum(roleId);
|
|
|
|
+ Integer stattPage=(page-1)*num;
|
|
|
|
+ List<Menu> menuList = roleDao.queryNotRoleAndMenu(roleId, stattPage, num);
|
|
|
|
+ jsonObject.put("count",count);
|
|
|
|
+ jsonObject.put("menuList",menuList);
|
|
|
|
+ return Result.ok(jsonObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<Menu> menuChildren(Integer parentId){
|
|
|
|
+ List<Menu> menus = new ArrayList<>();
|
|
|
|
+ List<Menu> menuList = menuDao.queryAllMenuTree(parentId);
|
|
|
|
+ for (Menu menu:menuList){
|
|
|
|
+ menu.setChildren(menuChildren(menu.getId()));
|
|
|
|
+ menus.add(menu);
|
|
|
|
+ }
|
|
|
|
+ return menus;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
public List<JSONObject> gennerMenuTree(List<Menu> menuList, Integer parentId) {
|
|
public List<JSONObject> gennerMenuTree(List<Menu> menuList, Integer parentId) {
|
|
List<JSONObject> jsonObjectList = new ArrayList<>();
|
|
List<JSONObject> jsonObjectList = new ArrayList<>();
|
|
if (Blank.isEmpty(menuList)) {
|
|
if (Blank.isEmpty(menuList)) {
|