@@ -41,6 +47,7 @@ import SuiteValue from "/@/views/sys/suite/product/suite-value.vue";
import { ref } from "vue";
import ExpiresTimeText from "/@/components/expires-time-text.vue";
import api, { SuiteDetail } from "/@/views/certd/suite/mine/api";
+import { FsIcon } from "@fast-crud/fast-crud";
defineOptions({
name: "SuiteCard"
diff --git a/packages/ui/certd-client/src/views/sys/suite/user-suite/crud.tsx b/packages/ui/certd-client/src/views/sys/suite/user-suite/crud.tsx
index d1909e5b..db494247 100644
--- a/packages/ui/certd-client/src/views/sys/suite/user-suite/crud.tsx
+++ b/packages/ui/certd-client/src/views/sys/suite/user-suite/crud.tsx
@@ -1,4 +1,4 @@
-import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
+import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
import { pipelineGroupApi } from "./api";
import { useRouter } from "vue-router";
import SuiteValueEdit from "/@/views/sys/suite/product/suite-value-edit.vue";
@@ -6,6 +6,7 @@ import SuiteValue from "/@/views/sys/suite/product/suite-value.vue";
import DurationValue from "/@/views/sys/suite/product/duration-value.vue";
import dayjs from "dayjs";
import createCrudOptionsUser from "/@/views/sys/authority/user/crud";
+import UserSuiteStatus from "/@/views/certd/suite/mine/user-suite-status.vue";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const api = pipelineGroupApi;
@@ -68,6 +69,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
// }
}
},
+ toolbar: { show: false },
rowHandle: {
width: 200,
fixed: "right",
@@ -234,7 +236,10 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
component: {
name: SuiteValue,
vModel: "modelValue",
- unit: "次"
+ unit: "次",
+ used: compute(({ row }) => {
+ return row.deployCountUsed;
+ })
},
align: "center"
}
@@ -281,29 +286,16 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
column: {
width: 100,
align: "center",
+ component: {
+ name: UserSuiteStatus,
+ userSuite: compute(({ row }) => {
+ return row;
+ })
+ },
conditionalRender: {
match() {
return false;
}
- },
- cellRender({ row }) {
- if (row.activeTime == null) {
- return
未使用;
- }
- const now = dayjs().valueOf();
- //已过期
- const isExpired = row.expiresTime != -1 && now > row.expiresTime;
- if (isExpired) {
- return
已过期;
- }
- //如果在激活时间之前
- if (now < row.activeTime) {
- return
待生效;
- }
- // 是否在激活时间和过期时间之间
- if (now > row.activeTime && (row.expiresTime == -1 || now < row.expiresTime)) {
- return
生效中;
- }
}
}
},
@@ -342,6 +334,29 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
width: 100,
align: "center"
}
+ },
+ createTime: {
+ title: "创建时间",
+ type: "datetime",
+ form: {
+ show: false
+ },
+ column: {
+ sorter: true,
+ width: 160,
+ align: "center"
+ }
+ },
+ updateTime: {
+ title: "更新时间",
+ type: "datetime",
+ form: {
+ show: false
+ },
+ column: {
+ show: true,
+ width: 160
+ }
}
}
}
diff --git a/packages/ui/certd-server/src/config/config.default.ts b/packages/ui/certd-server/src/config/config.default.ts
index f1e489ee..bd760f3b 100644
--- a/packages/ui/certd-server/src/config/config.default.ts
+++ b/packages/ui/certd-server/src/config/config.default.ts
@@ -72,7 +72,7 @@ const development = {
type: 'better-sqlite3',
database: './data/db.sqlite',
synchronize: false, // 如果第一次使用,不存在表,有同步的需求可以写 true
- logging: true,
+ logging: false,
highlightSql: false,
// 配置实体模型 或者 entities: '/entity',
diff --git a/packages/ui/certd-server/src/middleware/global-exception.ts b/packages/ui/certd-server/src/middleware/global-exception.ts
index c36b1aa0..5a6ec009 100644
--- a/packages/ui/certd-server/src/middleware/global-exception.ts
+++ b/packages/ui/certd-server/src/middleware/global-exception.ts
@@ -1,7 +1,7 @@
import { Provide } from '@midwayjs/core';
import { IWebMiddleware, IMidwayKoaContext, NextFunction } from '@midwayjs/koa';
import { logger } from '@certd/basic';
-import { Result } from '@certd/lib-server';
+import { BaseException, Result } from '@certd/lib-server';
@Provide()
export class GlobalExceptionMiddleware implements IWebMiddleware {
@@ -14,7 +14,11 @@ export class GlobalExceptionMiddleware implements IWebMiddleware {
await next();
logger.info('请求完成:', url, Date.now() - startTime + 'ms');
} catch (err) {
- logger.error('请求异常:', url, Date.now() - startTime + 'ms', err);
+ logger.error('请求异常:', url, Date.now() - startTime + 'ms', err.message);
+ if (!(err instanceof BaseException)) {
+ logger.error(err);
+ }
+
ctx.status = 200;
if (err.code == null || typeof err.code !== 'number') {
err.code = 1;
diff --git a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
index 0620ea18..dac7f98e 100644
--- a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
+++ b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
@@ -148,7 +148,7 @@ export class PipelineService extends BaseService
{
return new PipelineDetail(pipeline);
}
- async update(bean: PipelineEntity) {
+ async update(bean: Partial) {
//更新非trigger部分
await super.update(bean);
}
@@ -304,13 +304,17 @@ export class PipelineService extends BaseService {
}
async trigger(id: any, stepId?: string) {
+ const entity: PipelineEntity = await this.info(id);
+ if (isComm()) {
+ await this.checkHasDeployCount(id, entity.userId);
+ }
this.cron.register({
name: `pipeline.${id}.trigger.once`,
cron: null,
job: async () => {
logger.info('用户手动启动job');
try {
- await this.run(id, null, stepId);
+ await this.doRun(entity, null, stepId);
} catch (e) {
logger.error('手动job执行失败:', e);
}
@@ -318,6 +322,21 @@ export class PipelineService extends BaseService {
});
}
+ async checkHasDeployCount(pipelineId: number, userId: number) {
+ try {
+ return await this.userSuiteService.checkHasDeployCount(userId);
+ } catch (e) {
+ if (e instanceof NeedSuiteException) {
+ logger.error(e.message);
+ await this.update({
+ id: pipelineId,
+ status: 'no_deploy_count',
+ });
+ }
+ throw e;
+ }
+ }
+
async delete(id: any) {
await this.clearTriggers(id);
//TODO 删除storage
@@ -390,10 +409,14 @@ export class PipelineService extends BaseService {
async run(id: number, triggerId: string, stepId?: string) {
const entity: PipelineEntity = await this.info(id);
+ await this.doRun(entity, triggerId, stepId);
+ }
+ async doRun(entity: PipelineEntity, triggerId: string, stepId?: string) {
+ const id = entity.id;
let suite: UserSuiteEntity = null;
if (isComm()) {
- suite = await this.userSuiteService.checkHasDeployCount(entity.userId);
+ suite = await this.checkHasDeployCount(id, entity.userId);
}
const pipeline = JSON.parse(entity.content);