三星权限设计

权限设计
核心思路:

  1. 登录:查询数据库的用户名和密码,如果存在就登录进主界面
  2. 获取id: 创建方法并获取角色id(字段roleId),获取权限角色的集合
  3. 查询:同过查询权限获取的集合去获取菜单id
  4. 核心代码:创建类(loginDao)
  5. /** /**
    • 三星权限用户登录
    • @param paramMap
    • @param pageBean
    • @return
    • @throws InstantiationException
    • @throws IllegalAccessException
    • @throws SQLException
      */
      public List<Map<String, Object>> userLoginThree(Map<String, String[]> paramMap,PageBean pageBean) throws InstantiationException, IllegalAccessException, SQLException{
      String uid = JsonUtils.getParmeMap(paramMap, “uid”);
      String upwd = JsonUtils.getParmeMap(paramMap, “upwd”);
      String sql =“select * from t_easyui_user_version2 where 1=1”;
      if(StringUtils.isNotBlank(uid)) {
      sql +=" and uid = “+uid;
      }
      if(StringUtils.isNotBlank(upwd)) {
      sql +=” and upwd = "+upwd;
      }
      return super.executeQuery(sql, pageBean);
      }

/**
* 角色权限表的roleID
* @param paramMap
* @param pageBean
* @return
* @throws InstantiationException
* @throws IllegalAccessException
* @throws SQLException
*/
public List<Map<String, Object>> getListFromUserThree(Map<String, String[]> paramMap,PageBean pageBean) throws InstantiationException, IllegalAccessException, SQLException{
String roleId = JsonUtils.getParmeMap(paramMap, “roleId”);
String sql =“select * from t_easyui_menu_role where 1=1”;
if(StringUtils.isNotBlank(roleId)) {
sql +=" and roleId = "+roleId;
}
return super.executeQuery(sql, pageBean);
}`
创建LoginAction类配置xml文件中

/**
			 * 调用loginDao查询方法
			 */
			List<Map<String, Object>> userLoginThree = this.loginDao.userLoginThree(req.getParameterMap() , null);
	         Map<String, Object> mapUserThree = userLoginThree.get(0);
	         if(mapUserThree != null) {
	        	  Map<String, String[]> paramMap = new HashMap<>();
	        	  paramMap.put("roleId", new String[] {(String) mapUserThree.get("roleId").toString()});
	        	  /**
	        	   * 获取角色权限用户的信息
	        	   * 查询角色id
	        	   */
				 List<Map<String, Object>> listFromUserTwo = this.loginDao.getListFromUserThree(paramMap , null);
					 StringBuffer sb = new StringBuffer();
				 for (Map<String, Object> map : listFromUserTwo) {
						 sb.append(",").append(map.get("menuId"));
						 System.out.println("角色表的权限"+sb.append(",").append(map.get("menuId")));
					}
				 /**
				  * 放入session集合中反馈到界面
				  */
				 req.getSession().setAttribute("menuId", sb.toString().substring(1));
	         }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值