feat(container): add CRUD operations for container management
- Implemented routes for listing, retrieving, updating, and deleting containers. - Added ContainerModel with necessary fields and methods for data handling. - Created utility functions for fetching container data by ID. feat(page): enhance page management with CRUD and publish functionality - Developed routes for managing pages, including listing, updating, and deleting. - Integrated caching and zip file generation for page exports. - Added publish functionality to manage app versions and file uploads. feat(prompts): implement prompt management with CRUD operations - Created routes for listing, updating, and deleting prompts. - Added pagination and search capabilities for prompt listing. test: add common query utilities and prompt tests - Implemented common query utilities for API interactions. - Added tests for prompt listing functionality.
This commit is contained in:
88
src/old-apps/page/models/index.ts
Normal file
88
src/old-apps/page/models/index.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { sequelize } from '../../../modules/sequelize.ts';
|
||||
import { DataTypes, Model } from 'sequelize';
|
||||
|
||||
type PageNodeData = {
|
||||
id: string;
|
||||
type: string;
|
||||
data: {
|
||||
label?: string; // 容器 开始 结束
|
||||
root?: boolean; // 是否是根节点
|
||||
|
||||
// 容器上的属性
|
||||
cid?: string; // 容器id
|
||||
style?: { [key: string]: string };
|
||||
className?: string;
|
||||
showChild?: boolean;
|
||||
shadowRoot?: boolean;
|
||||
};
|
||||
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export interface PageData {
|
||||
edges: any[];
|
||||
nodes: PageNodeData[];
|
||||
viewport: any;
|
||||
[key: string]: any;
|
||||
}
|
||||
export type Publish = {
|
||||
id?: string; // resource id
|
||||
description?: string;
|
||||
key?: string;
|
||||
version?: string;
|
||||
};
|
||||
/**
|
||||
* 页面数据
|
||||
*/
|
||||
export class PageModel extends Model {
|
||||
declare id: string;
|
||||
declare title: string;
|
||||
declare description: string;
|
||||
declare type: string;
|
||||
declare data: PageData;
|
||||
declare publish: Publish;
|
||||
declare uid: string;
|
||||
}
|
||||
PageModel.init(
|
||||
{
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
comment: 'id',
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: '',
|
||||
},
|
||||
data: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
},
|
||||
publish: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
},
|
||||
uid: {
|
||||
type: DataTypes.UUID,
|
||||
allowNull: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
tableName: 'kv_page',
|
||||
paranoid: true,
|
||||
},
|
||||
);
|
||||
|
||||
// PageModel.sync({ alter: true, logging: false }).catch((e) => {
|
||||
// console.error('PageModel sync', e);
|
||||
// });
|
||||
Reference in New Issue
Block a user