首页 > 代码库 > 权限的简单想法
权限的简单想法
1.权限每个人进来看到不同的内容,有着不同的功能.比如boss可以设置下面人的权限,权限放大,权限缩小.开辟新权限,分配角色,角色分配人员,权限分配这些等等.
2.具体的shiro还是喜欢自己做权限的还是自己决定吧,用了shiro,退出之后,起作用啦.自己做权限ajax即使的做刷新,用着是方便,就是太费时间.
3.举个例子,boss给一个部门经理一些权限,部门经理可以把自己的权限发放给其他人,比如手下的高管..等等.这个比较的细致.(我自己的权限可以分派给其他的人员)
4.sql语句.如下:
2017.6.16查询人员全部的角色:
当前人员的所有角色,count(1) 大于0 的是自己,否则是其他
select *,(select COUNT(1) from t_users_roles t where " + "t.role_id = r.id and t.user_id = " + id
+ ") " + "verifynum from t_role r
2017.6.16查询功能全部的角色:count(1) 大于0 的是自己,否则是其他
String sql = "select *,(select COUNT(1) from t_roles_permissions "
+ "t where t.role_id = r.id and t.permission_id = "+id+")"
+ " verifynum from t_role r";
增加角色人員表:String sql = "insert into t_users_roles values("+userid+","+roleid+")";
删除角色人员表: String sql = " insert into t_roles_permissions values("+roleid+","+permissionid+")";
修改角色表 :String sql = "update t_role set name = ‘"+name+"‘,code = ‘"+code+"‘ where id = " + id;
根据用户id查询角色权限主菜单.
String sql = "select min(id),module from dbo.t_permission where id in"
+"(select permission_id from dbo.t_roles_permissions where role_id in"
+"(select role_id from dbo.t_users_roles where user_id = "+id+"))"
+"and module is not null group by module order by module desc";
根据主菜单功能查询所属子菜单
String sql = "select info,code from dbo.t_permission"
+ " where module = ‘"+module+"‘ and nosecone = 0"
+ " and info is not null order by id asc";
查询角色所有功能:
String sql = "select *,(select COUNT(1) from t_roles_permissions t where "
+ "t.permission_id = p.id and t.role_id = "+id+" ) verifynum"
+ " from t_permission p order by module desc";
删除角色功能表 :
String sql = "delete from t_roles_permissions where permission_id = "+id+"";
增加角色功能表:
String sql = "insert into t_roles_permissions values ("+id+","+permissionid+")";
查找当前角色的人员:
String sql = "select *,(select COUNT(1) from t_users_roles r where r.user_id = u.id "
+ "and r.role_id = "+id+" ) verifynum from"
+ " t_user u;";
权限的简单想法