Database stored procedures in Rights management

Source: Internet
Author: User
Tags joins

1, according to the user read the relevant permissions

CREATE PROCEDURE [dbo]. [Getroleaction]
@UserGUID uniqueidentifier,
@DepartmentGUID uniqueidentifier
As
BEGIN
IF @UserGUID = ' f425ba38-df44-45d0-a9bb-f5c904bfee1c '
BEGIN
SELECT A.guid,a.controllername,a.actionname from Action a
END
ELSE
BEGIN
SELECT DISTINCT A.guid,a.controllername,a.actionname from Action a
INNER JOIN role_action ra on RA. Actionguid=a.guid
INNER JOIN Role R on R.guid=ra. Roleguid
Left joins user_role ur on ur. Roleguid=r.guid
Left JOIN Department_role Dr. on Dr. Roleguid=r.guid
WHERE [email protected] OR [email protected]
END
END

2. Get menu permission list according to user

CREATE PROCEDURE [dbo]. [Getrolemenu]
@UserGUID uniqueidentifier,
@DepartmentGUID uniqueidentifier
As
BEGIN
IF @UserGUID = ' f425ba38-df44-45d0-a9bb-f5c904bfee1c '
BEGIN
SELECT M.guid,m.parentguid,m.displayname,m.iconclass,m.requesturl,m.rootlevel,m.orderindex from Menu m
END
ELSE
BEGIN
SELECT DISTINCT M.guid,m.parentguid,m.displayname,m.iconclass,m.requesturl,m.rootlevel,m.orderindex from Menu m
INNER JOIN Role_menu RM on RM. Menuguid=m.guid
INNER JOIN Role R on R.guid=rm. Roleguid
Left joins user_role ur on ur. Roleguid=r.guid
Left JOIN Department_role Dr. on Dr. Roleguid=r.guid
WHERE [email protected] OR [email protected]
END
END

Database stored procedures in Rights management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.