mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
chore: project controller
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { Constants, CrudController, SysSettingsService } from '@certd/lib-server';
|
||||
import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js';
|
||||
import { isPlus } from '@certd/plus-core';
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { SiteInfoService } from '../../../modules/monitor/index.js';
|
||||
import { PipelineEntity } from '../../../modules/pipeline/entity/pipeline.js';
|
||||
import { HistoryService } from '../../../modules/pipeline/service/history-service.js';
|
||||
import { PipelineService } from '../../../modules/pipeline/service/pipeline-service.js';
|
||||
import { AuthService } from '../../../modules/sys/authority/service/auth-service.js';
|
||||
import { SiteInfoService } from '../../../modules/monitor/index.js';
|
||||
import { isPlus } from '@certd/plus-core';
|
||||
|
||||
/**
|
||||
* 证书
|
||||
@@ -25,6 +25,7 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
@Inject()
|
||||
siteInfoService: SiteInfoService;
|
||||
|
||||
|
||||
getService() {
|
||||
return this.service;
|
||||
}
|
||||
@@ -34,6 +35,8 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
const isAdmin = await this.authService.isAdmin(this.ctx);
|
||||
const publicSettings = await this.sysSettingsService.getPublicSettings();
|
||||
|
||||
const {projectId,userId} = this.getProjectUserId("read")
|
||||
body.query.projectId = projectId
|
||||
let onlyOther = false
|
||||
if (isAdmin) {
|
||||
if (publicSettings.managerOtherUserPipeline) {
|
||||
@@ -44,10 +47,10 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
delete body.query.userId;
|
||||
}
|
||||
} else {
|
||||
body.query.userId = this.getUserId();
|
||||
body.query.userId = userId;
|
||||
}
|
||||
} else {
|
||||
body.query.userId = this.getUserId();
|
||||
body.query.userId = userId;
|
||||
}
|
||||
|
||||
const title = body.query.title;
|
||||
@@ -76,14 +79,17 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
|
||||
@Post('/getSimpleByIds', { summary: Constants.per.authOnly })
|
||||
async getSimpleById(@Body(ALL) body) {
|
||||
const ret = await this.getService().getSimplePipelines(body.ids, this.getUserId());
|
||||
const {projectId,userId} = this.getProjectUserId("read")
|
||||
const ret = await this.getService().getSimplePipelines(body.ids, userId,projectId);
|
||||
return this.ok(ret);
|
||||
}
|
||||
|
||||
|
||||
@Post('/add', { summary: Constants.per.authOnly })
|
||||
async add(@Body(ALL) bean: PipelineEntity) {
|
||||
bean.userId = this.getUserId();
|
||||
const {projectId,userId} = this.getProjectUserId("write")
|
||||
bean.userId = userId
|
||||
bean.projectId = projectId
|
||||
return super.add(bean);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,8 @@ export class AutoAInitSite {
|
||||
//加载一次密钥
|
||||
await this.sysSettingsService.getSecret();
|
||||
|
||||
await this.sysSettingsService.reloadPrivateSettings();
|
||||
//加载设置
|
||||
await this.sysSettingsService.reloadSettings();
|
||||
|
||||
// 授权许可
|
||||
try {
|
||||
|
||||
@@ -993,7 +993,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
return await this.repository.count({ where: { userId } });
|
||||
}
|
||||
|
||||
async getSimplePipelines(pipelineIds: number[], userId?: number) {
|
||||
async getSimplePipelines(pipelineIds: number[], userId?: number,projectId?:number) {
|
||||
return await this.repository.find({
|
||||
select: {
|
||||
id: true,
|
||||
@@ -1001,7 +1001,8 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
},
|
||||
where: {
|
||||
id: In(pipelineIds),
|
||||
userId
|
||||
userId,
|
||||
projectId
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user