Use "bits" to modify user rights
I used to use a record method, such as the A user has 3 module permissions, then A has three records.
I have this method in the program, I feel good, give you some advantages.
User rights is indicated by an int field, you can put 32 bits,
If there is the permissions of the first, 3rd, 4 modules, the value is 1 4 8 = 13
___________________ userid _____ userqx ___ a ??????????????? | ???? 13 ______________
Add permission specific implementation
If the permissions of the fourth module are added, the binary value of 4 is 8
Update QXUSER SET Userqx = Userqx | 8 Where userid = 'a'
Delete the permissions of the fourth module
Update qxuser set userqx = userqx & ~ 8 where userid = 'a'
If you delete the fourth module, you will not add the condition.
Update QXUSER SET USERQX = UserQX & ~ 8
The above is passed in the SQLServer 2000 Enterprise Edition.
Welcome everyone, have a better way to share it ~~~
In Java
34 & 2! = 0 is OK.