mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
feat: ui模式
BREAKING CHANGE: 接口配置变更
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { ALL, Body, Post, Query } from "@midwayjs/decorator";
|
||||
import { BaseController } from "./base-controller";
|
||||
import { ALL, Body, Post, Query } from '@midwayjs/decorator';
|
||||
import { BaseController } from './base-controller';
|
||||
|
||||
export abstract class CrudController extends BaseController {
|
||||
abstract getService();
|
||||
export abstract class CrudController<T> extends BaseController {
|
||||
abstract getService<T>();
|
||||
|
||||
@Post('/page')
|
||||
async page(
|
||||
@@ -62,4 +62,3 @@ export abstract class CrudController extends BaseController {
|
||||
return this.ok(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,7 @@ export default {
|
||||
logging: true,
|
||||
|
||||
// 配置实体模型 或者 entities: '/entity',
|
||||
entities: [
|
||||
'**/modules/*/entity/*.ts',
|
||||
FlywayHistory,
|
||||
UserEntity,
|
||||
],
|
||||
entities: ['**/modules/*/entity/*.ts', FlywayHistory, UserEntity],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -6,20 +6,19 @@ import { Configuration, App } from '@midwayjs/decorator';
|
||||
import * as koa from '@midwayjs/koa';
|
||||
import * as orm from '@midwayjs/typeorm';
|
||||
import * as cache from '@midwayjs/cache';
|
||||
import * as cors from '@koa/cors';
|
||||
import cors from '@koa/cors';
|
||||
import { join } from 'path';
|
||||
import * as flyway from 'midway-flyway-js';
|
||||
import {ReportMiddleware} from "./middleware/report";
|
||||
import {GlobalExceptionMiddleware} from "./middleware/global-exception";
|
||||
import {PreviewMiddleware} from "./middleware/preview";
|
||||
import {AuthorityMiddleware} from "./middleware/authority";
|
||||
|
||||
import { ReportMiddleware } from './middleware/report';
|
||||
import { GlobalExceptionMiddleware } from './middleware/global-exception';
|
||||
import { PreviewMiddleware } from './middleware/preview';
|
||||
import { AuthorityMiddleware } from './middleware/authority';
|
||||
|
||||
import * as pipeline from './plugins/pipeline';
|
||||
import * as cron from './plugins/cron';
|
||||
|
||||
@Configuration({
|
||||
imports: [koa, orm, cache, flyway, validateComp,pipeline, cron],
|
||||
imports: [koa, orm, cache, flyway, validateComp, pipeline, cron],
|
||||
importConfigs: [
|
||||
{
|
||||
default: defaultConfig,
|
||||
|
||||
@@ -60,4 +60,3 @@ export class PermissionController extends CrudController<PermissionService> {
|
||||
return this.ok(tree);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { UserEntity } from '../entity/user';
|
||||
import * as _ from 'lodash';
|
||||
import * as md5 from 'md5';
|
||||
import md5 from 'md5';
|
||||
import { CommonException } from '../../../basic/exception/common-exception';
|
||||
import { BaseService } from '../../../basic/base-service';
|
||||
import { logger } from '../../../utils/logger';
|
||||
@@ -36,7 +36,7 @@ export class UserService extends BaseService<UserEntity> {
|
||||
const info = await this.repository.findOne({
|
||||
where: {
|
||||
id: this.ctx.user.id,
|
||||
}
|
||||
},
|
||||
});
|
||||
delete info.password;
|
||||
return info;
|
||||
@@ -48,9 +48,9 @@ export class UserService extends BaseService<UserEntity> {
|
||||
*/
|
||||
async add(param) {
|
||||
const exists = await this.repository.findOne({
|
||||
where:{
|
||||
where: {
|
||||
username: param.username,
|
||||
}
|
||||
},
|
||||
});
|
||||
if (!_.isEmpty(exists)) {
|
||||
throw new CommonException('用户名已经存在');
|
||||
@@ -74,7 +74,7 @@ export class UserService extends BaseService<UserEntity> {
|
||||
throw new CommonException('id不能为空');
|
||||
}
|
||||
const userInfo = await this.repository.findOne({
|
||||
where:{ id: param.id }
|
||||
where: { id: param.id },
|
||||
});
|
||||
if (!userInfo) {
|
||||
throw new CommonException('用户不存在');
|
||||
@@ -92,7 +92,7 @@ export class UserService extends BaseService<UserEntity> {
|
||||
|
||||
async findOne(param) {
|
||||
return this.repository.findOne({
|
||||
where:param
|
||||
where: param,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import { AccessService } from '../service/access-service';
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/pi/access')
|
||||
export class AccessController extends CrudController {
|
||||
export class AccessController extends CrudController<AccessService> {
|
||||
@Inject()
|
||||
service: AccessService;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { HistoryLogEntity } from '../entity/history-log';
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/pi/history')
|
||||
export class HistoryController extends CrudController {
|
||||
export class HistoryController extends CrudController<HistoryService> {
|
||||
@Inject()
|
||||
service: HistoryService;
|
||||
@Inject()
|
||||
|
||||
@@ -16,7 +16,7 @@ import { PipelineEntity } from '../entity/pipeline';
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/pi/pipeline')
|
||||
export class PipelineController extends CrudController {
|
||||
export class PipelineController extends CrudController<PipelineService> {
|
||||
@Inject()
|
||||
service: PipelineService;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Provide, Scope, ScopeEnum } from "@midwayjs/decorator";
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
|
||||
import { dnsProviderRegistry } from '@certd/plugin-cert';
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Singleton)
|
||||
|
||||
@@ -139,9 +139,9 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
if (cron == null) {
|
||||
return;
|
||||
}
|
||||
if(cron.startsWith("*")){
|
||||
cron = "0"+ cron.substring(1,cron.length)
|
||||
return
|
||||
if (cron.startsWith('*')) {
|
||||
cron = '0' + cron.substring(1, cron.length);
|
||||
return;
|
||||
}
|
||||
this.cron.register({
|
||||
name: this.buildCronKey(pipelineId, trigger.id),
|
||||
@@ -168,7 +168,17 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
|
||||
const onChanged = async (history: RunHistory) => {
|
||||
//保存执行历史
|
||||
await this.saveHistory(history);
|
||||
try {
|
||||
await this.saveHistory(history);
|
||||
} catch (e) {
|
||||
const pipelineEntity = new PipelineEntity();
|
||||
pipelineEntity.id = parseInt(history.pipeline.id);
|
||||
pipelineEntity.status = 'error';
|
||||
pipelineEntity.lastHistoryTime = history.pipeline.status.startTime;
|
||||
await this.update(pipelineEntity);
|
||||
logger.error('保存执行历史失败:', e);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
const userId = entity.userId;
|
||||
@@ -228,6 +238,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
entity.id = parseInt(history.id);
|
||||
entity.userId = history.pipeline.userId;
|
||||
entity.pipeline = JSON.stringify(history.pipeline);
|
||||
entity.pipelineId = parseInt(history.pipeline.id);
|
||||
await this.historyService.save(entity);
|
||||
|
||||
const logEntity: HistoryLogEntity = new HistoryLogEntity();
|
||||
|
||||
Reference in New Issue
Block a user