chore: project

This commit is contained in:
xiaojunnuo
2026-02-13 22:24:04 +08:00
parent 4ee6e38a94
commit cfd5b388f1
16 changed files with 95 additions and 67 deletions
@@ -28,9 +28,11 @@ export class OpenCertController extends BaseOpenController {
async get(@Body(ALL) bean: CertGetReq, @Query(ALL) query: CertGetReq) {
const openKey: OpenKey = this.ctx.openKey;
const userId = openKey.userId;
if (!userId) {
throw new CodeException(Constants.res.openKeyError);
}
const projectId = openKey.projectId;
const req = merge({}, bean, query)
@@ -39,7 +41,8 @@ export class OpenCertController extends BaseOpenController {
domains: req.domains,
certId: req.certId,
autoApply: req.autoApply??false,
format: req.format
format: req.format,
projectId,
});
return this.ok(res);
}
@@ -158,23 +158,18 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
@Post("/setting/get", { summary: Constants.per.authOnly })
async get() {
const { userId } = await this.getProjectUserIdRead()
const setting = await this.service.getSetting(userId)
const { userId, projectId } = await this.getProjectUserIdRead()
const setting = await this.service.getSetting(userId, projectId)
return this.ok(setting);
}
@Post("/setting/save", { summary: Constants.per.authOnly })
async save(@Body(ALL) bean: any) {
const { userId } = await this.getProjectUserIdWrite()
if(userId === 0){
if(!this.isAdmin()){
throw new Error("仅管理员可以修改");
}
}
const { userId, projectId} = await this.getProjectUserIdWrite()
const setting = new UserSiteMonitorSetting();
merge(setting, bean);
await this.service.saveSetting(userId, setting);
await this.service.saveSetting(userId, projectId,setting);
return this.ok({});
}
@@ -257,7 +257,7 @@ export class HistoryController extends CrudController<HistoryService> {
throw new PermissionException();
}
// 是否允许管理员查看
const setting = await this.userSettingsService.getSetting<UserGrantSetting>(history.userId, UserGrantSetting, false);
const setting = await this.userSettingsService.getSetting<UserGrantSetting>(history.userId, null, UserGrantSetting, false);
if (setting?.allowAdminViewCerts!==true) {
//不允许管理员查看
throw new PermissionException("该流水线的用户还未授权管理员下载证书,请先让用户在”设置->授权委托“中打开开关");
@@ -103,11 +103,12 @@ export class PipelineController extends CrudController<PipelineService> {
@Post('/save', { summary: Constants.per.authOnly })
async save(@Body(ALL) bean: { addToMonitorEnabled: boolean, addToMonitorDomains: string } & PipelineEntity) {
const { userId } = await this.getProjectUserIdWrite()
const { userId ,projectId} = await this.getProjectUserIdWrite()
if (bean.id > 0) {
await this.checkOwner(this.getService(), bean.id,"write",true);
} else {
bean.userId = userId;
bean.projectId = projectId;
}
if (!this.isAdmin()) {
@@ -124,6 +125,7 @@ export class PipelineController extends CrudController<PipelineService> {
await this.siteInfoService.doImport({
text: bean.addToMonitorDomains,
userId: userId,
projectId: projectId,
});
}
}