惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Latest news
Latest news
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
L
Lohrmann on Cybersecurity
aimingoo的专栏
aimingoo的专栏
B
Blog
T
Threat Research - Cisco Blogs
罗磊的独立博客
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
P
Palo Alto Networks Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
T
Tor Project blog
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
Recorded Future
Recorded Future
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
B
Blog RSS Feed
Scott Helme
Scott Helme
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
A
Arctic Wolf
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Schneier on Security
Hacker News: Ask HN
Hacker News: Ask HN
N
Netflix TechBlog - Medium
L
LangChain Blog
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
M
MIT News - Artificial intelligence
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
W
WeLiveSecurity

博客园 - sun@live

两段代码 <收藏>提高Web性能的14条法则(详细版) MOSS与业务系统的集成 之 单点登录 MOSS与业务系统的集成 之 自定义Membership实现Forms方式验证 手机归属地数据—采集 .Net数据源自定义参数 JavaScript和CSS速查手册 序列化一个字符串到CDATA元素(.NET 1.1) Sandcastle工具SandcastleBuilder 清除字符串数组中,重复元素 - sun@live - 博客园 Windows Live Writer 写的一个双向选择器(JS) (原创)一个改自java的代码统计工具 Web2.0用户注册,激活,密码找回模块 [学习日志]EyasBlog控件部分已基本完成-2005-12-03 学习日志(blog日历控件)-2005年11月12日 学习日志(Blog架构)-2005年11月09日 学习日志-2005年11月09日 学习计划-2005年11月07日
论坛中,用户权限解决方法
sun@live · 2006-03-21 · via 博客园 - sun@live

一个论坛系统中,有N个版块,版块中,不同角色应给予不同权限。
看了应用系统权限表示的算法技巧 里面讲了两种方法,第一种方法,只能解决单权限问题,第二种方法,用的是位权方法,存在一种这样的问题,如果新增了一种权限,所用的权限位就必须新增一位,造成系统可扩展性差。
    大家知道,C++里面,窗体的样式,不是多一种样式,就在后面|(or)一位,这样一来,权限问题就好解决了,扩展性就强了。
    先定义权限值:

public class rights
{
    
public static int view  = 1;
    
public static int post  = 2;
    
public static int edit  = 4;
    
public static int delete = 8;
    
//
}

假如我们要给Group1赋予可查看、可发表权限,那么他的权限值就为:

//
group1Rights = rights.view | rights.post;
//group1Rights = 3;
//

反过来,如果Group2的权限值为6,我们要确定他的权限:

//
int g2rights = 6;
bool isView = ((g2rights & rights.view)==rights.view);
//false
bool isPost = ((g2rights & rights.post)==rights.post);
//true
bool isEdit = ((g2rights & rights.edit)==rights.edit);
//true
bool isDelete = ((g2rights & rights.delete)==rights.delete);
//false
//

当然,这些可以封装在一个类里。这里只是演示下。。。。。