temp
This commit is contained in:
64
src/routes/app-manager/module/app-domain.ts
Normal file
64
src/routes/app-manager/module/app-domain.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { sequelize } from '../../../modules/sequelize.ts';
|
||||
import { DataTypes, Model } from 'sequelize';
|
||||
export type DomainList = Partial<InstanceType<typeof AppDomainModel>>;
|
||||
|
||||
// 审核,通过,驳回
|
||||
const appDomainStatus = ['audit', 'auditReject', 'auditPending', 'running', 'stop'] as const;
|
||||
|
||||
type AppDomainStatus = (typeof appDomainStatus)[number];
|
||||
/**
|
||||
* 应用域名管理
|
||||
*/
|
||||
export class AppDomainModel extends Model {
|
||||
declare id: string;
|
||||
declare domain: string;
|
||||
declare appId: string;
|
||||
// 状态,
|
||||
declare status: AppDomainStatus;
|
||||
declare uid: string;
|
||||
|
||||
declare createdAt: Date;
|
||||
declare updatedAt: Date;
|
||||
|
||||
checkCanUpdateStatus(newStatus: AppDomainStatus) {
|
||||
// 原本是运行中,可以改为停止,原本是停止,可以改为运行。
|
||||
if (this.status === 'running' || this.status === 'stop') {
|
||||
return true;
|
||||
}
|
||||
// 原本是审核状态,不能修改。
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AppDomainModel.init(
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
comment: 'id',
|
||||
},
|
||||
domain: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
appId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
uid: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'kv_app_domain',
|
||||
paranoid: true,
|
||||
},
|
||||
);
|
||||
|
||||
AppDomainModel.sync({ alter: true, logging: false }).catch((e) => {
|
||||
console.error('AppDomainModel sync', e);
|
||||
});
|
||||
Reference in New Issue
Block a user