87 lines
1.7 KiB
TypeScript
87 lines
1.7 KiB
TypeScript
import { sequelize } from '@/modules/sequelize.ts';
|
|
import { DataTypes, Model } from 'sequelize';
|
|
|
|
export type MicroApp = Partial<InstanceType<typeof MicroAppUploadModel>>;
|
|
|
|
type MicroAppData = {
|
|
file?: {
|
|
path: string;
|
|
size: number;
|
|
hash: string;
|
|
name: string;
|
|
};
|
|
key?: string;
|
|
data?: any;
|
|
collection?: any; // 上传的信息汇总
|
|
};
|
|
export class MicroAppUploadModel extends Model {
|
|
declare id: string;
|
|
declare title: string;
|
|
declare description: string;
|
|
declare type: string;
|
|
declare tags: string[];
|
|
declare data: MicroAppData;
|
|
declare uid: string;
|
|
declare updatedAt: Date;
|
|
declare createdAt: Date;
|
|
declare source: string;
|
|
declare share: boolean;
|
|
declare uname: string;
|
|
}
|
|
|
|
MicroAppUploadModel.init(
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
primaryKey: true,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
comment: 'id',
|
|
},
|
|
title: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
tags: {
|
|
type: DataTypes.JSONB,
|
|
defaultValue: [],
|
|
},
|
|
type: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
source: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
data: {
|
|
type: DataTypes.JSONB,
|
|
defaultValue: {},
|
|
},
|
|
share: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: false,
|
|
},
|
|
uname: {
|
|
type: DataTypes.TEXT,
|
|
defaultValue: '',
|
|
},
|
|
uid: {
|
|
type: DataTypes.UUID,
|
|
allowNull: true,
|
|
},
|
|
},
|
|
{
|
|
sequelize,
|
|
tableName: 'micro_apps_upload',
|
|
// paranoid: true,
|
|
},
|
|
);
|
|
|
|
MicroAppUploadModel.sync({ alter: true, logging: false }).catch((e) => {
|
|
console.error('MicroAppUploadModel sync', e);
|
|
});
|