|
@@ -7,6 +7,7 @@ import {Logger} from "@util/Logger";
|
|
|
import {PrjPlanTaskDraft} from "@core-models/PrjPlanTaskDraft";
|
|
|
import {PrjPhaseDefine} from "@core-models/PrjPhaseDefine";
|
|
|
import {Resp} from "@util/Resp";
|
|
|
+import {PrjFile} from "@core-models/PrjFile";
|
|
|
|
|
|
/// 是否是项目特权账户
|
|
|
export async function is_project_privileged_account(account_id: string): Promise<boolean> {
|
|
@@ -110,6 +111,18 @@ export async function is_project_accessible(account_id: string, project_id: stri
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+/// 检查账号是否是项目文档的创建者
|
|
|
+export async function is_project_document_creator(account_id: string, document_id: string): Promise<boolean> {
|
|
|
+ let document = await PrjFile.findOne({where: {id: document_id}, raw: true});
|
|
|
+ if (document && document.creator_id === account_id) {
|
|
|
+ Logger.trace(`${account_id} 是项目文档 ${document_id} 的创建者。`);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ Logger.trace(`${account_id} 不是项目文档 ${document_id} 的创建者。`);
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
/// 是否有修改项目信息的权限
|
|
|
export async function is_project_modifiable(account_id: string, project_id: string): Promise<boolean> {
|
|
|
if (
|
|
@@ -191,6 +204,7 @@ export async function is_project_task_outcome_modifiable(account_id: string, tas
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
export interface ITaskManageableCheckResult {
|
|
|
manageable: boolean;
|
|
|
error: any;
|
|
@@ -236,3 +250,43 @@ export async function if_project_task_manageable_in_current_phase(draft: boolean
|
|
|
result.manageable = true;
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+// 检查是否对项目文档有取列表查看权限
|
|
|
+export async function is_project_document_listable(account_id: string, prj_id: string): Promise<boolean> {
|
|
|
+ return await is_project_accessible(account_id, prj_id);
|
|
|
+}
|
|
|
+
|
|
|
+/// 检查是否对项目文档有上传权限
|
|
|
+export async function is_project_document_uploadable(account_id: string, prj_id: string): Promise<boolean> {
|
|
|
+ // 项目成员、特权人员、项目负责人、商务负责人、审核人员都有权限
|
|
|
+ return await is_project_privileged_account(account_id) ||
|
|
|
+ await is_project_leader(account_id, prj_id) ||
|
|
|
+ await is_project_business_leader(account_id, prj_id) ||
|
|
|
+ await is_project_member(account_id, prj_id);
|
|
|
+}
|
|
|
+
|
|
|
+// 检查是否对项目文档有下载权限
|
|
|
+export async function is_project_document_downloadable(account_id: string, prj_id: string, document_id: string): Promise<boolean> {
|
|
|
+ return await is_project_accessible(account_id, prj_id) ||
|
|
|
+ await is_project_document_creator(account_id, document_id);
|
|
|
+}
|
|
|
+
|
|
|
+// 检查是否对项目文档和修改文件名的权限
|
|
|
+export async function is_project_document_modifiable(account_id: string, prj_id: string, document_id: string): Promise<boolean> {
|
|
|
+ return await is_project_privileged_account(account_id) ||
|
|
|
+ await is_project_leader(account_id, prj_id) ||
|
|
|
+ await is_project_document_creator(account_id, document_id);
|
|
|
+}
|
|
|
+
|
|
|
+// 检查是否对项目文档有删除权限
|
|
|
+export async function is_project_document_deletable(account_id: string, prj_id: string, document_id: string): Promise<boolean> {
|
|
|
+ return await is_project_privileged_account(account_id) ||
|
|
|
+ await is_project_leader(account_id, prj_id) ||
|
|
|
+ await is_project_document_creator(account_id, document_id);
|
|
|
+}
|
|
|
+
|
|
|
+// 检查是否对项目文档有归档权限
|
|
|
+export async function is_project_document_archivable(account_id: string, prj_id: string): Promise<boolean> {
|
|
|
+ return await is_project_privileged_account(account_id) ||
|
|
|
+ await is_project_leader(account_id, prj_id);
|
|
|
+}
|