feat: 初始化项目结构并添加核心功能模块

- 新增文档模板和导航结构
- 实现服务器基础API路由和控制器
- 添加扩展插件配置和前端框架
- 引入多租户和权限管理模块
- 集成日志和数据库配置
- 添加核心业务模型和类型定义
This commit is contained in:
2026-03-17 22:07:19 +08:00
parent c0870dce50
commit 136c2fa579
728 changed files with 107690 additions and 5614 deletions

View File

@@ -0,0 +1,58 @@
import { Request, Response } from 'express';
import { CreativeService } from '../../domains/Creative/CreativeService';
import { logger } from '../../utils/logger';
export class CreativeController {
/**
* 创建创作任务 (TTS/IMAGE/VIDEO)
*/
static async createTask(req: Request, res: Response) {
const tenantId = req.headers['x-tenant-id'] as string;
const { type, params } = req.body;
if (!tenantId || !type || !params) {
return res.status(400).json({ success: false, error: 'tenantId, type, and params are required' });
}
try {
const taskId = await CreativeService.createTask({
tenant_id: tenantId,
type,
params
});
return res.json({ success: true, data: { taskId } });
} catch (err: any) {
logger.error(`[CreativeController] Create task failed: ${err.message}`);
return res.status(500).json({ success: false, error: 'Internal server error' });
}
}
/**
* 获取任务详情
*/
static async getTask(req: Request, res: Response) {
const { taskId } = req.params;
try {
const task = await CreativeService.getTask(taskId);
return res.json({ success: true, data: task });
} catch (err: any) {
return res.status(500).json({ success: false, error: err.message });
}
}
/**
* 获取素材列表
*/
static async getAssets(req: Request, res: Response) {
const tenantId = req.headers['x-tenant-id'] as string;
const { type } = req.query;
try {
const assets = await CreativeService.getAssets(tenantId, type as string);
return res.json({ success: true, data: assets });
} catch (err: any) {
return res.status(500).json({ success: false, error: err.message });
}
}
}