添加删除文件

This commit is contained in:
2025-03-26 00:05:58 +08:00
parent 64c70ce527
commit 501a92eb88
10 changed files with 236 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
import { sequelize } from '../../../modules/sequelize.ts';
import { DataTypes, Model } from 'sequelize';
export type DomainList = Partial<InstanceType<typeof AppDomainModel>>;
import { redis } from '../../../modules/redis.ts';
// 审核,通过,驳回
const appDomainStatus = ['audit', 'auditReject', 'auditPending', 'running', 'stop'] as const;
@@ -16,6 +17,7 @@ export class AppDomainModel extends Model {
// 状态,
declare status: AppDomainStatus;
declare uid: string;
declare data: Record<string, any>;
declare createdAt: Date;
declare updatedAt: Date;
@@ -28,6 +30,18 @@ export class AppDomainModel extends Model {
// 原本是审核状态,不能修改。
return false;
}
async clearCache() {
// 清除缓存
const cacheKey = `domain:${this.domain}`;
const checkHas = async () => {
const has = await redis.get(cacheKey);
return has;
};
const has = await checkHas();
if (has) {
await redis.set(cacheKey, '', 'EX', 1);
}
}
}
AppDomainModel.init(
@@ -43,13 +57,22 @@ AppDomainModel.init(
allowNull: false,
unique: true,
},
appId: {
data: {
type: DataTypes.JSONB,
allowNull: true,
},
status: {
type: DataTypes.STRING,
allowNull: false,
defaultValue: 'running',
},
appId: {
type: DataTypes.STRING,
allowNull: true,
},
uid: {
type: DataTypes.STRING,
allowNull: false,
allowNull: true,
},
},
{