feat: 新增app管理和文件管理
This commit is contained in:
71
src/routes/app-manager/module/app.ts
Normal file
71
src/routes/app-manager/module/app.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { sequelize } from '../../../modules/sequelize.ts';
|
||||
import { DataTypes, Model } from 'sequelize';
|
||||
|
||||
export interface AppData {
|
||||
files: { name: string; path: string }[];
|
||||
}
|
||||
export type AppType = 'web-single' | 'web-module';
|
||||
|
||||
export type App = Partial<InstanceType<typeof AppModel>>;
|
||||
|
||||
/**
|
||||
* APP 管理
|
||||
*/
|
||||
export class AppModel extends Model {
|
||||
declare id: string;
|
||||
declare data: AppData;
|
||||
declare version: string;
|
||||
declare domain: string;
|
||||
declare appType: string;
|
||||
declare key: string;
|
||||
declare type: string;
|
||||
declare uid: string;
|
||||
declare user: string;
|
||||
}
|
||||
AppModel.init(
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
comment: 'id',
|
||||
},
|
||||
data: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
},
|
||||
version: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
domain: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
appType: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
key: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true,
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
uid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'kv_app',
|
||||
paranoid: true,
|
||||
},
|
||||
);
|
||||
|
||||
AppModel.sync({ alter: true, logging: false }).catch((e) => {
|
||||
console.error('AppModel sync', e);
|
||||
});
|
||||
Reference in New Issue
Block a user