mirror of
https://github.com/certd/certd.git
synced 2026-04-23 11:37:23 +08:00
feat: ui模式
BREAKING CHANGE: 接口配置变更
This commit is contained in:
@@ -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