mirror of
https://github.com/certd/certd.git
synced 2026-04-14 20:40:53 +08:00
chore:
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { BaseController, Constants } from '@certd/lib-server';
|
||||
import {ALL, Body, Controller, Inject, Post, Provide} from '@midwayjs/core';
|
||||
import {AccessGetter, AccessService, BaseController, Constants} from '@certd/lib-server';
|
||||
import {
|
||||
AccessRequestHandleReq,
|
||||
ITaskPlugin,
|
||||
@@ -10,10 +10,10 @@ import {
|
||||
PluginRequestHandleReq,
|
||||
TaskInstanceContext,
|
||||
} from '@certd/pipeline';
|
||||
import { AccessService, AccessGetter } from '@certd/lib-server';
|
||||
import { EmailService } from '../../../modules/basic/service/email-service.js';
|
||||
import { http, HttpRequestConfig, logger, mergeUtils, utils } from '@certd/basic';
|
||||
import { NotificationService } from '../../../modules/pipeline/service/notification-service.js';
|
||||
import {EmailService} from '../../../modules/basic/service/email-service.js';
|
||||
import {http, HttpRequestConfig, logger, mergeUtils, utils} from '@certd/basic';
|
||||
import {NotificationService} from '../../../modules/pipeline/service/notification-service.js';
|
||||
import {CertApplyUploadService} from "../../../modules/pipeline/service/cert-apply-upload-service.js";
|
||||
|
||||
@Provide()
|
||||
@Controller('/api/pi/handle')
|
||||
@@ -24,6 +24,9 @@ export class HandleController extends BaseController {
|
||||
@Inject()
|
||||
emailService: EmailService;
|
||||
|
||||
@Inject()
|
||||
certApplyUploadService: CertApplyUploadService;
|
||||
|
||||
@Inject()
|
||||
notificationService: NotificationService;
|
||||
|
||||
@@ -92,6 +95,15 @@ export class HandleController extends BaseController {
|
||||
savePath,
|
||||
});
|
||||
};
|
||||
|
||||
const serviceContainer:any = {
|
||||
CertApplyUploadService:this.certApplyUploadService
|
||||
}
|
||||
const serviceGetter = {
|
||||
get:(name: string) => {
|
||||
return serviceContainer[name]
|
||||
}
|
||||
}
|
||||
//@ts-ignore
|
||||
const taskCtx: TaskInstanceContext = {
|
||||
pipeline: undefined,
|
||||
@@ -107,6 +119,7 @@ export class HandleController extends BaseController {
|
||||
userContext: undefined,
|
||||
fileStore: undefined,
|
||||
signal: undefined,
|
||||
user: {id:userId,role:"user"},
|
||||
// pipelineContext: this.pipelineContext,
|
||||
// userContext: this.contextFactory.getContext('user', this.options.userId),
|
||||
// fileStore: new FileStore({
|
||||
@@ -116,6 +129,7 @@ export class HandleController extends BaseController {
|
||||
// }),
|
||||
// signal: this.abort.signal,
|
||||
utils,
|
||||
serviceGetter
|
||||
};
|
||||
instance.setCtx(taskCtx);
|
||||
mergeUtils.merge(plugin, body.input);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import {ICertApplyUploadService} from "@certd/plugin-cert";
|
||||
import {IMidwayContext, Inject, Provide} from "@midwayjs/core";
|
||||
import {CertInfoService} from "../../monitor/index.js";
|
||||
import {CertUploadService} from "../../monitor/service/cert-upload-service.js";
|
||||
|
||||
@Provide("CertApplyUploadService")
|
||||
export class CertApplyUploadService implements ICertApplyUploadService {
|
||||
@Inject()
|
||||
ctx : IMidwayContext
|
||||
|
||||
async getCertInfo(opts: { certId: number; userId: number; }) {
|
||||
const certInfoService = this.ctx.getApp().getApplicationContext().get<CertInfoService>("CertInfoService")
|
||||
const { certId, userId } = opts;
|
||||
return await certInfoService.getCertInfo({
|
||||
certId,
|
||||
userId: Number(userId),
|
||||
});
|
||||
};
|
||||
async updateCert(opts: { certId: any; userId: any; cert: any; }){
|
||||
const certUploadService = this.ctx.getApp().getApplicationContext().get<CertUploadService>("CertUploadService")
|
||||
return await certUploadService.updateCert({
|
||||
id:opts.certId,
|
||||
userId:opts.userId,
|
||||
cert:opts.cert
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import { NotificationService } from "./notification-service.js";
|
||||
import { NotificationGetter } from "./notification-getter.js";
|
||||
import { UserSuiteEntity, UserSuiteService } from "@certd/commercial-core";
|
||||
import { CertInfoService } from "../../monitor/service/cert-info-service.js";
|
||||
import {CertApplyUploadService} from "./cert-apply-upload-service.js";
|
||||
|
||||
const runningTasks: Map<string | number, Executor> = new Map();
|
||||
|
||||
@@ -92,6 +93,8 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
@Inject()
|
||||
certInfoService: CertInfoService;
|
||||
|
||||
@Inject()
|
||||
certApplyUploadService: CertApplyUploadService;
|
||||
//@ts-ignore
|
||||
getRepository() {
|
||||
return this.repository;
|
||||
@@ -481,7 +484,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
sysInfo.title = siteInfo.title;
|
||||
}
|
||||
const serviceContainer = {
|
||||
CertInfoService: this.certInfoService
|
||||
CertApplyUploadService: this.certApplyUploadService
|
||||
}
|
||||
const serviceGetter = {
|
||||
get:(name: string) => {
|
||||
|
||||
Reference in New Issue
Block a user