refactor(ProductService): 修复createProduct方法和其他方法错误 fix(InventoryAgingService): 修复AGING_THRESHOLD_DAYS引用问题 fix(InventoryService): 修复predictSKUDemand方法 refactor(ChatBotController): 从tsoa风格改为Express风格 fix(CommandCenterController): 修复类型问题 fix(AdAutoService): 修复stock可能为undefined的问题 docs: 更新SERVICE_MAP、DOMAIN_MODEL等架构文档 chore: 启动前端服务(运行在http://localhost:8000)
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
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 as string);
|
|
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 });
|
|
}
|
|
}
|
|
}
|