2017-03-13 13:41:16 +08:00
|
|
|
|
USE [BootstrapAdmin]
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
SET ANSI_NULLS ON
|
2016-11-07 12:27:04 +08:00
|
|
|
|
GO
|
|
|
|
|
SET QUOTED_IDENTIFIER ON
|
|
|
|
|
GO
|
|
|
|
|
Drop PROCEDURE Proc_DeleteUsers
|
|
|
|
|
GO
|
|
|
|
|
-- =============================================
|
|
|
|
|
-- Author: Argo Zhang
|
|
|
|
|
-- Create date: 2016-09-06
|
|
|
|
|
-- Description:
|
|
|
|
|
-- =============================================
|
|
|
|
|
Create PROCEDURE Proc_DeleteUsers
|
|
|
|
|
-- Add the parameters for the stored procedure here
|
|
|
|
|
@ids varchar(max)
|
|
|
|
|
WITH ENCRYPTION
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
|
|
|
|
-- interfering with SELECT statements.
|
|
|
|
|
SET NOCOUNT ON;
|
|
|
|
|
SET XACT_ABORT ON;
|
|
|
|
|
-- Insert statements for procedure here
|
|
|
|
|
declare @sql varchar(max)
|
|
|
|
|
set @sql = 'Delete from UserRole where UserID in (' + @ids + ');'
|
|
|
|
|
set @sql += 'delete from UserGroup where UserID in (' + @ids + ');'
|
|
|
|
|
set @sql += 'delete from Users where ID in (' + @ids + ');'
|
|
|
|
|
exec(@sql)
|
|
|
|
|
END
|
|
|
|
|
GO
|
2016-11-07 15:17:10 +08:00
|
|
|
|
|
|
|
|
|
Drop PROCEDURE Proc_DeleteRoles
|
|
|
|
|
GO
|
|
|
|
|
-- =============================================
|
|
|
|
|
-- Author: LiuChun
|
|
|
|
|
-- Create date: 2016-11-07
|
|
|
|
|
-- Description:
|
|
|
|
|
-- =============================================
|
|
|
|
|
Create PROCEDURE Proc_DeleteRoles
|
|
|
|
|
-- Add the parameters for the stored procedure here
|
|
|
|
|
@ids varchar(max)
|
|
|
|
|
WITH ENCRYPTION
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
|
|
|
|
-- interfering with SELECT statements.
|
|
|
|
|
SET NOCOUNT ON;
|
|
|
|
|
SET XACT_ABORT ON;
|
|
|
|
|
-- Insert statements for procedure here
|
|
|
|
|
declare @sql varchar(max)
|
|
|
|
|
set @sql = 'delete from UserRole where RoleID in (' + @ids + ');'
|
|
|
|
|
set @sql += 'delete from RoleGroup where RoleID in (' + @ids + ');'
|
|
|
|
|
set @sql += 'delete from NavigationRole where RoleID in (' + @ids + ');'
|
|
|
|
|
set @sql += 'delete from Roles where ID in (' + @ids + ');'
|
|
|
|
|
exec(@sql)
|
|
|
|
|
END
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Drop PROCEDURE Proc_DeleteGroups
|
|
|
|
|
GO
|
|
|
|
|
-- =============================================
|
|
|
|
|
-- Author: LiuChun
|
|
|
|
|
-- Create date: 2016-11-07
|
|
|
|
|
-- Description:
|
|
|
|
|
-- =============================================
|
|
|
|
|
Create PROCEDURE Proc_DeleteGroups
|
|
|
|
|
-- Add the parameters for the stored procedure here
|
|
|
|
|
@ids varchar(max)
|
|
|
|
|
WITH ENCRYPTION
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
|
|
|
|
-- interfering with SELECT statements.
|
|
|
|
|
SET NOCOUNT ON;
|
|
|
|
|
SET XACT_ABORT ON;
|
|
|
|
|
-- Insert statements for procedure here
|
|
|
|
|
declare @sql varchar(max)
|
|
|
|
|
set @sql = 'delete from UserGroup where GroupID in (' + @ids + ');'
|
|
|
|
|
set @sql += 'delete from RoleGroup where GroupID in (' + @ids + ');'
|
|
|
|
|
set @sql += 'delete from Groups where ID in (' + @ids + ');'
|
|
|
|
|
exec(@sql)
|
|
|
|
|
END
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
Drop PROCEDURE Proc_DeleteMenus
|
|
|
|
|
GO
|
|
|
|
|
-- =============================================
|
|
|
|
|
-- Author: LiuChun
|
|
|
|
|
-- Create date: 2016-11-07
|
|
|
|
|
-- Description:
|
|
|
|
|
-- =============================================
|
|
|
|
|
Create PROCEDURE Proc_DeleteMenus
|
|
|
|
|
-- Add the parameters for the stored procedure here
|
|
|
|
|
@ids varchar(max)
|
|
|
|
|
WITH ENCRYPTION
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
|
|
|
|
-- interfering with SELECT statements.
|
|
|
|
|
SET NOCOUNT ON;
|
|
|
|
|
SET XACT_ABORT ON;
|
|
|
|
|
-- Insert statements for procedure here
|
|
|
|
|
declare @sql varchar(max)
|
|
|
|
|
set @sql = 'delete from NavigationRole where NavigationID in (' + @ids + ');'
|
|
|
|
|
set @sql += 'delete from Navigations where ID in (' + @ids + ');'
|
|
|
|
|
exec(@sql)
|
|
|
|
|
END
|
2016-11-08 20:37:14 +08:00
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
Drop PROCEDURE Proc_RetrieveMenus
|
|
|
|
|
GO
|
|
|
|
|
-- =============================================
|
|
|
|
|
-- Author: Argo Zhang
|
|
|
|
|
-- Create date: 2016-11-08
|
|
|
|
|
-- Description:
|
|
|
|
|
-- =============================================
|
|
|
|
|
Create PROCEDURE Proc_RetrieveMenus
|
|
|
|
|
-- Add the parameters for the stored procedure here
|
|
|
|
|
@userName varchar(50) = null
|
|
|
|
|
WITH ENCRYPTION
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
|
|
|
|
-- interfering with SELECT statements.
|
|
|
|
|
SET NOCOUNT ON;
|
|
|
|
|
SET XACT_ABORT ON;
|
|
|
|
|
-- Insert statements for procedure here
|
2017-03-23 16:21:23 +08:00
|
|
|
|
if @userName = '' or @userName is null or exists(select ur.ID from Users u inner join UserRole ur on u.ID = ur.UserID inner join Roles r on ur.RoleID = r.ID where r.RoleName = 'administrators' and u.UserName = @userName)
|
2017-03-03 13:34:53 +08:00
|
|
|
|
select n.ID, n.ParentId, n.Name, n.[Order], n.Icon, n.Url, n.Category, n.Target, n.IsResource, n.[Application], d.Name as CategoryName, ln.Name as ParentName
|
2016-11-11 13:07:17 +08:00
|
|
|
|
from Navigations n inner join Dicts d on n.Category = d.Code and d.Category = N'菜单' and d.Define = 0
|
2016-11-08 20:37:14 +08:00
|
|
|
|
left join Navigations ln on n.ParentId = ln.ID
|
|
|
|
|
else
|
2017-03-03 13:34:53 +08:00
|
|
|
|
select n.ID, n.ParentId, n.Name, n.[Order], n.Icon, n.Url, n.Category, n.Target, n.IsResource, n.[Application], d.Name as CategoryName, ln.Name as ParentName
|
2016-11-11 13:07:17 +08:00
|
|
|
|
from Navigations n inner join Dicts d on n.Category = d.Code and d.Category = N'菜单' and d.Define = 0
|
2016-11-08 20:37:14 +08:00
|
|
|
|
left join Navigations ln on n.ParentId = ln.ID
|
|
|
|
|
inner join (
|
|
|
|
|
select nr.NavigationID from Users u
|
|
|
|
|
inner join UserRole ur on ur.UserID = u.ID
|
2016-11-10 14:05:12 +08:00
|
|
|
|
inner join NavigationRole nr on nr.RoleID = ur.RoleID
|
2016-11-08 20:37:14 +08:00
|
|
|
|
where u.UserName = @userName
|
|
|
|
|
union
|
|
|
|
|
select nr.NavigationID from Users u
|
|
|
|
|
inner join UserGroup ug on u.ID = ug.UserID
|
|
|
|
|
inner join RoleGroup rg on rg.GroupID = ug.GroupID
|
|
|
|
|
inner join NavigationRole nr on nr.RoleID = rg.RoleID
|
|
|
|
|
where u.UserName = @userName
|
2016-11-10 14:05:12 +08:00
|
|
|
|
union
|
|
|
|
|
select n.ID from Navigations n
|
|
|
|
|
where EXISTS (select UserName from Users u
|
|
|
|
|
inner join UserRole ur on u.ID = ur.UserID
|
|
|
|
|
inner join Roles r on ur.RoleID = r.ID
|
|
|
|
|
where u.UserName = @userName and r.RoleName = N'Administrators'
|
|
|
|
|
)
|
2016-11-08 20:37:14 +08:00
|
|
|
|
) nav on n.ID = nav.NavigationID
|
|
|
|
|
END
|
|
|
|
|
GO
|
2016-11-11 09:09:41 +08:00
|
|
|
|
|
|
|
|
|
/****** Object: StoredProcedure [dbo].[Proc_SaveUsers] Script Date: 11/11/2016 08:51:44 ******/
|
|
|
|
|
SET ANSI_NULLS ON
|
|
|
|
|
GO
|
|
|
|
|
|
|
|
|
|
SET QUOTED_IDENTIFIER ON
|
|
|
|
|
GO
|
|
|
|
|
|
2016-11-11 09:27:21 +08:00
|
|
|
|
Drop PROCEDURE Proc_SaveUsers
|
|
|
|
|
GO
|
2016-11-11 09:09:41 +08:00
|
|
|
|
-- =============================================
|
|
|
|
|
-- Author: LiuChun
|
|
|
|
|
-- Create date: 2016-11-10
|
|
|
|
|
-- Description:
|
|
|
|
|
-- =============================================
|
|
|
|
|
CREATE PROCEDURE [dbo].[Proc_SaveUsers]
|
|
|
|
|
-- Add the parameters for the stored procedure here
|
2016-11-11 14:32:52 +08:00
|
|
|
|
@userName varchar(50),
|
|
|
|
|
@password varchar(50),
|
|
|
|
|
@passSalt varchar(50),
|
2016-11-12 15:26:40 +08:00
|
|
|
|
@displayName nvarchar(50),
|
2018-09-13 21:30:33 +08:00
|
|
|
|
@approvedBy nvarchar(50) = null,
|
2018-09-07 15:53:16 +08:00
|
|
|
|
@description nvarchar(500)
|
2016-11-11 09:09:41 +08:00
|
|
|
|
WITH ENCRYPTION
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
|
|
|
|
-- interfering with SELECT statements.
|
|
|
|
|
SET NOCOUNT ON;
|
|
|
|
|
SET XACT_ABORT ON;
|
|
|
|
|
-- Insert statements for procedure here
|
2018-09-13 21:30:33 +08:00
|
|
|
|
declare @approvedTime datetime
|
|
|
|
|
if @approvedBy is not null set @approvedTime = GETDATE()
|
|
|
|
|
|
2018-09-07 15:53:16 +08:00
|
|
|
|
begin
|
|
|
|
|
if(not exists (select 1 from Users Where UserName = @userName))
|
2016-11-11 14:32:52 +08:00
|
|
|
|
begin
|
2018-09-13 14:44:21 +08:00
|
|
|
|
begin tran
|
|
|
|
|
Insert Into Users (UserName, [Password], PassSalt, DisplayName, RegisterTime, ApprovedBy, ApprovedTime, [Description]) values (@userName, @password, @passSalt, @displayName, GETDATE(), @approvedBy, @approvedTime, @description)
|
|
|
|
|
insert into UserRole (UserID, RoleID) select @@IDENTITY, ID from Roles where RoleName = N'Default'
|
|
|
|
|
commit tran
|
2016-11-11 14:32:52 +08:00
|
|
|
|
end
|
2018-09-07 15:53:16 +08:00
|
|
|
|
end
|
2016-11-11 09:46:53 +08:00
|
|
|
|
END
|
|
|
|
|
GO
|
2018-09-08 16:16:51 +08:00
|
|
|
|
|
|
|
|
|
Drop PROCEDURE Proc_RejectUsers
|
|
|
|
|
GO
|
|
|
|
|
-- =============================================
|
|
|
|
|
-- Author: Argo
|
|
|
|
|
-- Create date: 2018-09-07
|
|
|
|
|
-- Description:
|
|
|
|
|
-- =============================================
|
|
|
|
|
CREATE PROCEDURE [dbo].[Proc_RejectUsers]
|
|
|
|
|
-- Add the parameters for the stored procedure here
|
|
|
|
|
@id int,
|
|
|
|
|
@rejectedBy varchar(50),
|
|
|
|
|
@rejectedReason nvarchar(50)
|
|
|
|
|
WITH ENCRYPTION
|
|
|
|
|
AS
|
|
|
|
|
BEGIN
|
|
|
|
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
|
|
|
|
-- interfering with SELECT statements.
|
|
|
|
|
SET NOCOUNT ON;
|
|
|
|
|
SET XACT_ABORT ON;
|
|
|
|
|
-- Insert statements for procedure here
|
|
|
|
|
begin
|
|
|
|
|
declare @registerTime datetime
|
|
|
|
|
declare @userName varchar(50)
|
|
|
|
|
declare @displayName nvarchar(50)
|
|
|
|
|
select @registerTime = Registertime, @userName = UserName, @displayName = DisplayName from Users where ID = @id
|
|
|
|
|
|
|
|
|
|
if @userName is not null
|
|
|
|
|
begin
|
|
|
|
|
begin tran
|
|
|
|
|
insert into RejectUsers (UserName, DisplayName, RegisterTime, RejectedBy, RejectedTime, RejectedReason) values (@userName, @displayName, @registerTime, @rejectedBy, GETDATE(), @rejectedReason)
|
2018-09-13 21:33:56 +08:00
|
|
|
|
delete from UserRole where UserId = @id
|
2018-09-08 16:16:51 +08:00
|
|
|
|
delete from users where ID = @id
|
|
|
|
|
commit tran
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
END
|
|
|
|
|
GO
|