mirror of https://github.com/certd/certd
perf: 流水线支持有效期设置
parent
77b4a1eaf6
commit
911e69e3bc
|
|
@ -57,6 +57,7 @@ export default {
|
|||
suiteBuy: "Suite Purchase",
|
||||
myTrade: "My Orders",
|
||||
paymentReturn: "Payment Return",
|
||||
hasExpired: "Expired",
|
||||
user: {
|
||||
greeting: "Hello",
|
||||
profile: "Account Info",
|
||||
|
|
@ -136,6 +137,10 @@ export default {
|
|||
triggerType: "Trigger Type",
|
||||
pipelineId: "Pipeline Id",
|
||||
},
|
||||
pi: {
|
||||
validTime: "Piepline Valid Time",
|
||||
validTimeHelper: "Not filled in means permanent validity",
|
||||
},
|
||||
types: {
|
||||
certApply: "Certificate Application",
|
||||
certUpload: "Certificate Upload",
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ export default {
|
|||
suiteBuy: "套餐购买",
|
||||
myTrade: "我的订单",
|
||||
paymentReturn: "支付返回",
|
||||
hasExpired: "已过期",
|
||||
|
||||
user: {
|
||||
greeting: "您好",
|
||||
|
|
@ -142,6 +143,10 @@ export default {
|
|||
triggerType: "触发类型",
|
||||
pipelineId: "流水线Id",
|
||||
},
|
||||
pi: {
|
||||
validTime: "流水线有效期",
|
||||
validTimeHelper: "不填则为永久有效",
|
||||
},
|
||||
types: {
|
||||
certApply: "证书申请",
|
||||
certUpload: "证书上传",
|
||||
|
|
|
|||
|
|
@ -555,16 +555,36 @@ export default function ({ crudExpose, context: { groupDictRef, selectedRowKeys
|
|||
sorter: true,
|
||||
},
|
||||
},
|
||||
createTime: {
|
||||
title: t("certd.fields.createTime"),
|
||||
type: "datetime",
|
||||
validTime: {
|
||||
title: t("certd.pi.validTime"),
|
||||
type: "date",
|
||||
form: {
|
||||
show: false,
|
||||
show: true,
|
||||
helper: t("certd.pi.validTimeHelper"),
|
||||
valueResolve({ form, key, value }) {
|
||||
if (value) {
|
||||
form[key] = value.valueOf();
|
||||
}
|
||||
},
|
||||
valueBuilder({ form, key, value }) {
|
||||
if (value) {
|
||||
form[key] = dayjs(value);
|
||||
}
|
||||
},
|
||||
},
|
||||
column: {
|
||||
sorter: true,
|
||||
width: 155,
|
||||
align: "center",
|
||||
cellRender({ value }) {
|
||||
if (!value || value <= 0) {
|
||||
return "-";
|
||||
}
|
||||
if (value < Date.now()) {
|
||||
return t("certd.hasExpired");
|
||||
}
|
||||
return dayjs(value).format("YYYY-MM-DD");
|
||||
},
|
||||
},
|
||||
},
|
||||
updateTime: {
|
||||
|
|
|
|||
|
|
@ -15,3 +15,6 @@ CREATE TABLE "cd_group"
|
|||
--分组字段
|
||||
ALTER TABLE cd_site_info ADD COLUMN "group_id" integer;
|
||||
|
||||
|
||||
--流水线有效期
|
||||
ALTER TABLE pi_pipeline ADD COLUMN "valid_time" integer;
|
||||
|
|
|
|||
|
|
@ -43,28 +43,19 @@ export class PipelineEntity {
|
|||
@Column({ name:"is_template", comment: '是否模版', nullable: true, default: false })
|
||||
isTemplate: boolean;
|
||||
|
||||
@Column({
|
||||
name: 'last_history_time',
|
||||
comment: '最后一次执行时间',
|
||||
nullable: true,
|
||||
})
|
||||
@Column({name: 'last_history_time',comment: '最后一次执行时间',nullable: true,})
|
||||
lastHistoryTime: number;
|
||||
|
||||
@Column({name: 'valid_time',comment: '到期时间',nullable: true,default: 0})
|
||||
validTime: number;
|
||||
|
||||
// 变量
|
||||
lastVars: any;
|
||||
|
||||
@Column({
|
||||
name: 'order',
|
||||
comment: '排序',
|
||||
nullable: true,
|
||||
})
|
||||
@Column({name: 'order', comment: '排序', nullable: true,})
|
||||
order: number;
|
||||
|
||||
@Column({
|
||||
name: 'create_time',
|
||||
comment: '创建时间',
|
||||
default: () => 'CURRENT_TIMESTAMP',
|
||||
})
|
||||
@Column({name: 'create_time',comment: '创建时间', default: () => 'CURRENT_TIMESTAMP',})
|
||||
createTime: Date;
|
||||
@Column({
|
||||
name: 'update_time',
|
||||
|
|
|
|||
|
|
@ -457,11 +457,11 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
|||
return;
|
||||
}
|
||||
cron = cron.trim();
|
||||
if (cron.startsWith("* *")) {
|
||||
cron = cron.replace("\* \*", "0 0");
|
||||
if (cron.startsWith("* * ")) {
|
||||
cron = "0 0 " + cron.substring(5);
|
||||
}
|
||||
if (cron.startsWith("*")) {
|
||||
cron = cron.replace("\*", "0");
|
||||
if (cron.startsWith("* ")) {
|
||||
cron = "0 " + cron.substring(2);
|
||||
}
|
||||
const triggerId = trigger.id;
|
||||
const name = this.buildCronKey(pipelineId, triggerId);
|
||||
|
|
@ -493,6 +493,9 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
|||
*/
|
||||
async run(id: number, triggerId: string, stepId?: string) {
|
||||
const entity: PipelineEntity = await this.info(id);
|
||||
if (entity.validTime > 0 && entity.validTime < Date.now()) {
|
||||
return;
|
||||
}
|
||||
await this.doRun(entity, triggerId, stepId);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue