權限角色初始化安裝(超級管理員)

-- 清理
delete   from  FunctionGroup
delete   from  FunctionGroupModule
delete   from  KeyTable
delete   from  Module
delete   from   [ Role ]
delete   from  RolePerm
delete   from  UserRole
delete   from  User2
delete   from  BaseData2s
delete   from  SequenceTable

-- 超級管理員
insert   into  User2(ID,LoginName,Pass)
select   7 , ' admin ' , ' 0192023a7bbd73250516f069df18b500 '

-- 角色
insert   into   [ Role ] (ID,RoleName)
select   13 ,N ' 超級管理員 '

-- 分配角色
insert   into  UserRole(ID,Role_ID, [ User_ID ] )
select   19 , 13 , 7

-- 功能分組
insert   into  Module(ID,ModuleName,URL,Code)
select   1 ,N ' 分組管理 ' , ' /Security/FunctionGroupList.aspx ' , ' FunctionGroupList '
union   all
select   2 ,N ' 系統功能管理 ' , ' /Security/ModuleList.aspx ' , ' ModuleList '
union   all
select   3 ,N ' 角色權限管理 ' , ' /Security/RoleList.aspx ' , ' RoleList '
union   all
select   4 ,N ' 用戶管理 ' , ' /Security/UserList.aspx ' , ' UserList '
union   all
select   5 ,N ' 基礎資料 ' , ' /Security/BaseDataList.aspx ' , ' BaseDataList '
union   all
select   20 ,N ' 個人信息 ' , ' /Security/PopupControl/UserChangeInfo.aspx ' , ' UserChangeInfo '
union   all
select   21 ,N ' 修改密碼 ' , ' /Security/PopupControl/UserChangePWD.aspx ' , ' UserChangePWD '
union   all
select   22 ,N ' 任務列表 ' , ' /OfficeMS/TaskList.aspx ' , ' TaskList '

-- 為角色分配權限
insert   into  RolePerm(ID,Role_ID,Module_ID,AllowOpen,AllowAdd,AllowEdit,AllowDelete)
select   14 , 13 , 1 , 1 , 1 , 1 , 1
union   all
select   15 , 13 , 2 , 1 , 1 , 1 , 1
union   all
select   16 , 13 , 3 , 1 , 1 , 1 , 1
union   all
select   17 , 13 , 4 , 1 , 1 , 1 , 1
union   all
select   18 , 13 , 5 , 1 , 1 , 1 , 1
union   all
select   28 , 13 , 20 , 1 , 1 , 1 , 1
union   all
select   29 , 13 , 21 , 1 , 1 , 1 , 1
union   all
select   30 , 13 , 22 , 1 , 1 , 1 , 1

-- 分組
insert   into  FunctionGroup(ID, [ name ] ,GroupType)
select   6 ,N ' 系統管理 ' , 1

insert   into  FunctionGroupModule(ID,FunctionGroup_ID,Module_ID)
select   8 , 6 , 1
union   all
select   9 , 6 , 2
union   all
select   10 , 6 , 3
union   all
select   11 , 6 , 4
union   all
select   12 , 6 , 5

insert   into  FunctionGroup(ID, [ name ] ,GroupType)
select   23 ,N ' 個人信息 ' , 1

insert   into  FunctionGroupModule(ID,FunctionGroup_ID,Module_ID)
select   24 , 23 , 20
union   all
select   25 , 23 , 21

insert   into  FunctionGroup(ID, [ name ] ,GroupType)
select   26 ,N ' 工作管理 ' , 1

insert   into  FunctionGroupModule(ID,FunctionGroup_ID,Module_ID)
select   27 , 26 , 22

-- 設置KEYTABLE
if  ( select   count ( * from  KeyTable) = 0
begin
    
insert   into  KeyTable(NextId)
    
values ( 20 )
end
else   if ( select  NextId  from  KeyTable) < 31
begin
    
update  KeyTable  set  NextId = 31
end

转载于:https://www.cnblogs.com/luoyaoquan/archive/2011/04/21/2023244.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值