chore: project 初步

This commit is contained in:
xiaojunnuo
2026-02-11 00:54:56 +08:00
parent 1e416b9f8a
commit 28dfef985c
5 changed files with 184 additions and 47 deletions
@@ -61,7 +61,7 @@ export abstract class BaseController {
}
}
getProjectId(permission:string) {
async getProjectId(permission:string) {
if (!isEnterprise()) {
return null
}
@@ -71,13 +71,13 @@ export abstract class BaseController {
}
const userId = this.getUserId()
const projectId = parseInt(projectIdStr)
this.checkProjectPermission(userId, projectId,permission)
await this.checkProjectPermission(userId, projectId,permission)
return projectId;
}
getProjectUserId(permission:string){
async getProjectUserId(permission:string){
let userId = this.getUserId()
const projectId = this.getProjectId(permission)
const projectId = await this.getProjectId(permission)
if(projectId){
userId = 0
}
@@ -85,11 +85,19 @@ export abstract class BaseController {
projectId,userId
}
}
async getProjectUserIdRead(){
return await this.getProjectUserId("read")
}
async getProjectUserIdWrite(){
return await this.getProjectUserId("write")
}
async getProjectUserIdAdmin(){
return await this.getProjectUserId("admin")
}
async checkProjectPermission(userId: number, projectId: number,permission:string) {
const projectService:any = await this.applicationContext.getAsync("projectService");
await projectService.checkPermission({userId,projectId,permission})
}
@@ -9,6 +9,7 @@ import { cache, logger, mergeUtils, setGlobalProxy } from '@certd/basic';
import * as dns from 'node:dns';
import { BaseService, setAdminMode } from '../../../basic/index.js';
import { executorQueue } from '../../basic/service/executor-queue.js';
import { isComm } from '@certd/plus-core';
const { merge } = mergeUtils;
/**
* 设置
@@ -116,6 +117,12 @@ export class SysSettingsService extends BaseService<SysSettingsEntity> {
}
async savePublicSettings(bean: SysPublicSettings) {
if(isComm()){
if(bean.adminMode === 'enterprise'){
throw new Error("商业版不支持使用企业管理模式")
}
}
await this.saveSetting(bean);
//让设置生效
await this.reloadPublicSettings();