main
tamguo 7 years ago
parent dbe756eadc
commit 3fe4a42b19

@ -9,4 +9,6 @@ public interface SysMenuMapper extends SuperMapper<SysMenuEntity>{
List<SysMenuEntity> listData(SysMenuCondition condition);
List<SysMenuEntity> selectMenuByRoleId(String roleCode);
}

@ -6,6 +6,7 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -36,11 +37,15 @@ public class SysRoleServiceImpl implements ISysRoleService{
@SuppressWarnings("unchecked")
@Override
public Map<String, Object> menuTreeData(String roleCode) {
List<SysMenuEntity> menus = sysMenuMapper.selectList(Condition.EMPTY);
List<SysMenuEntity> menus = sysMenuMapper.selectList(Condition.create().eq("module_codes", "core"));
List<SysMenuEntity> roleMenus = sysMenuMapper.selectMenuByRoleId(roleCode);
JSONObject result = new JSONObject();
JSONObject menuInfo = transformZTree(menus);
result.put("menuMap", menuInfo);
result.put("roleMenuList", roleMenus);
return result;
}
@ -52,7 +57,12 @@ public class SysRoleServiceImpl implements ISysRoleService{
SysMenuEntity menu = menus.get(i);
JSONObject node = new JSONObject();
node.put("name", menu.getMenuName());
node.put("name", menu.getMenuName() + "<font color=#888> &nbsp; &nbsp;   </font>");
if(!StringUtils.isEmpty(menu.getMenuHref())) {
node.put("name", menu.getMenuName() + "<font color=#888> &nbsp; &nbsp; "+menu.getMenuHref()+"  </font>");
}else if(!StringUtils.isEmpty(menu.getPermission())) {
node.put("name", menu.getMenuName() + "<font color=#888> &nbsp; &nbsp; "+menu.getPermission()+"  </font>");
}
node.put("pId", menu.getParentCode());
node.put("id", menu.getMenuCode());
node.put("title", menu.getMenuName());

@ -31,4 +31,35 @@
FROM
sys_menu m
</select>
<select id="selectMenuByRoleId" resultType="SysMenuEntity">
SELECT
m.menu_code,
m.parent_code,
m.parent_codes,
m.tree_sort,
m.tree_sorts,
m.tree_leaf,
m.tree_level,
m.tree_names,
m.menu_name,
m.menu_type,
m.menu_href,
m.menu_target,
m.menu_icon,
m.menu_color,
m.permission,
m.weight,
m.is_show,
m.sys_code,
m.module_codes,
m.`status`,
m.create_by,
m.update_by,
m.update_date,
m.remarks
FROM
sys_menu m,sys_role_menu RM
WHERE RM.role_code = #{roleCode} and RM.menu_code = m.menu_code
</select>
</mapper>
Loading…
Cancel
Save