chore: project

This commit is contained in:
xiaojunnuo
2026-02-13 23:51:27 +08:00
parent 83d81b64b3
commit 956d68695c
21 changed files with 75 additions and 38 deletions
@@ -16,9 +16,10 @@ export class AddonGetterService {
addonService: AddonService;
async getAddonById(id: any, checkUserId: boolean, userId?: number, defaultAddon?:{type:string,name:string} ): Promise<any> {
async getAddonById(id: any, checkUserId: boolean, userId?: number, projectId?: number, defaultAddon?:{type:string,name:string} ): Promise<any> {
const serviceGetter = this.taskServiceBuilder.create({
userId
userId,
projectId,
});
const ctx = {
http,
@@ -58,13 +59,13 @@ export class AddonGetterService {
return await newAddon(entity.addonType, entity.type, input, ctx);
}
async getById(id: any, userId: number): Promise<any> {
return await this.getAddonById(id, true, userId);
async getById(id: any, userId: number, projectId?: number): Promise<any> {
return await this.getAddonById(id, true, userId, projectId);
}
async getBlank(addonType:string,subType:string){
return await this.getAddonById(null,false,0,{
async getBlank(addonType:string,subType:string,projectId?: number){
return await this.getAddonById(null,false,0,projectId,{
type: addonType, name:subType
})
}
@@ -3,15 +3,17 @@ import {DomainService} from "../../../cert/service/domain-service.js";
export class DomainVerifierGetter implements IDomainVerifierGetter {
private userId: number;
private projectId: number;
private domainService: DomainService;
constructor(userId: number, domainService: DomainService) {
constructor(userId: number, projectId: number, domainService: DomainService) {
this.userId = userId;
this.projectId = projectId;
this.domainService = domainService;
}
async getVerifiers(domains: string[]): Promise<DomainVerifiers>{
return await this.domainService.getDomainVerifiers(this.userId,domains);
return await this.domainService.getDomainVerifiers(this.userId,this.projectId,domains);
}
}
@@ -4,17 +4,19 @@ import { DomainService } from "../../../cert/service/domain-service.js";
export class SubDomainsGetter implements ISubDomainsGetter {
userId: number;
projectId: number;
subDomainService: SubDomainService;
domainService: DomainService;
constructor(userId: number, subDomainService: SubDomainService, domainService: DomainService) {
constructor(userId: number, projectId: number, subDomainService: SubDomainService, domainService: DomainService) {
this.userId = userId;
this.projectId = projectId;
this.subDomainService = subDomainService;
this.domainService = domainService;
}
async getSubDomains() {
return await this.subDomainService.getListByUserId(this.userId)
return await this.subDomainService.getListByUserId(this.userId, this.projectId)
}
async hasSubDomain(fullDomain: string) {
@@ -48,7 +48,7 @@ export class TaskServiceGetter implements IServiceGetter{
async getSubDomainsGetter(): Promise<SubDomainsGetter> {
const subDomainsService:SubDomainService = await this.appCtx.getAsync("subDomainService")
const domainService:DomainService = await this.appCtx.getAsync("domainService")
return new SubDomainsGetter(this.userId, subDomainsService,domainService)
return new SubDomainsGetter(this.userId,this.projectId, subDomainsService,domainService)
}
async getAccessService(): Promise<AccessGetter> {
@@ -69,7 +69,7 @@ export class TaskServiceGetter implements IServiceGetter{
async getDomainVerifierGetter(): Promise<DomainVerifierGetter> {
const domainService:DomainService = await this.appCtx.getAsync("domainService")
return new DomainVerifierGetter(this.userId, domainService);
return new DomainVerifierGetter(this.userId, this.projectId, domainService);
}
}
@Provide()
@@ -88,7 +88,7 @@ export class NotificationService extends BaseService<NotificationEntity> {
if (!id) {
throw new ValidateException('id不能为空');
}
if (!userId) {
if (userId==null) {
throw new ValidateException('userId不能为空');
}
const res = await this.repository.findOne({
@@ -135,7 +135,7 @@ export class NotificationService extends BaseService<NotificationEntity> {
if (!id) {
throw new ValidateException('id不能为空');
}
if (!userId) {
if (userId==null) {
throw new ValidateException('userId不能为空');
}
await this.repository.update(
@@ -1082,7 +1082,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
}
}
async createAutoPipeline(req: { domains: string[]; email: string; userId: number, from: string }) {
async createAutoPipeline(req: { domains: string[]; email: string; userId: number,projectId?:number, from: string }) {
const randomHour = Math.floor(Math.random() * 6);
const randomMin = Math.floor(Math.random() * 60);
@@ -1162,6 +1162,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
bean.type = "cert_auto";
bean.disabled = false
bean.keepHistoryCount = 30
bean.projectId = req.projectId
await this.save(bean)
@@ -22,13 +22,14 @@ export class SubDomainService extends BaseService<SubDomainEntity> {
return this.repository;
}
async getListByUserId(userId:number):Promise<string[]>{
if (!userId) {
async getListByUserId(userId:number, projectId?: number):Promise<string[]>{
if (userId==null) {
return [];
}
const list = await this.find({
where: {
userId,
projectId,
disabled: false,
},
});
@@ -37,17 +38,18 @@ export class SubDomainService extends BaseService<SubDomainEntity> {
}
async add(bean: SubDomainEntity) {
const {domain, userId} = bean;
const {domain, userId, projectId} = bean;
if (!domain) {
throw new Error('域名不能为空');
}
if (!userId) {
if (userId==null) {
throw new Error('用户ID不能为空');
}
const exist = await this.repository.findOne({
where: {
domain,
userId,
projectId,
},
});
if (exist) {