查看具有特定部门ID的文档 [英] view documents with specific department id

查看:75
本文介绍了查看具有特定部门ID的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似于部门的表格



i have a table which is department like

departmentid  department type
 1             computer science
 2             hr
 3               finance





这里是查看文件的商店程序





here is the store procedure to view documents

ALTER PROCEDURE [dbo].[statuschange]
AS
SELECT  di.DocID, 
    di.DocName, 
    di.Uploadfile, 
    dt.DocType,
    d.DepType, 
    at.ApproveType
FROM    DocumentInfo di
JOIN
    DocType dt ON dt.DocTypeID = di.DocTypeID
JOIN 
    Department d ON d.DepID = di.DepID
LEFT OUTER JOIN
    Approval a ON a.DocID = di.DocID
JOIN
    ApproveType at ON at.ApproveID = ISNULL(a.Approveid, 3)



现在我想显示具有特定部门ID的文件



计算机科学管理员将只能查看计算机科学文档和hr管理员查看仅hr文档



any解决方案?


now i want to show documents with specific department id

computer-science admin will be able to view only computer-science documents and hr admin view only hr documents

any solution?

推荐答案

您只需要将参数传递给存储过程。例如:



You just need to pass a parameter to your stored procedure. For example:

ALTER PROCEDURE [dbo].[statuschange]
(
 @department_id INT
)
AS
SELECT  di.DocID...
WHERE department_id = @department_id





或者,如果它基于用户ID,您可以传入用户ID,然后执行逻辑以确定他们可以访问的内容。



Or, if it is based on user id you can pass in the user id and then do your logic to determine what they have access to.


这篇关于查看具有特定部门ID的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆