10 KiB
name, overview, todos, isProject
| name | overview | todos | isProject | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Migrate APIs to crmeb-front | Migrate all backend API implementations that models-api.js currently calls from models-integration to crmeb-front, and update the frontend to route all requests through crmeb-front's /api/front/ prefix. |
|
false |
Migrate models-api.js Backend to crmeb-front
Current Architecture
The frontend models-api.js calls API_BASE_URL = 'https://sophia-shop.uj345.cc/models' (models-integration, port 5081). The goal is to migrate all these endpoints to crmeb-front (port 8081) so the frontend only needs to call /api/front/ endpoints.
Endpoint Mapping: models-api.js -> models-integration -> crmeb-front
Already Ported (only need frontend URL change)
These endpoints already exist in crmeb-front and have working service implementations:
- Coze Chat:
/api/coze/chat->/api/front/coze/chat(CozeController) - Coze Retrieve:
/api/coze/chat/retrieve->/api/front/coze/chat/retrieve - Coze Messages:
/api/coze/chat/messages/list->/api/front/coze/chat/messages/list - Coze Workflow Run:
/api/coze/workflow/run->/api/front/coze/workflow/run - Coze Workflow Stream:
/api/coze/workflow/stream->/api/front/coze/workflow/stream - Coze File Upload:
/api/coze/file/upload->/api/front/coze/file/upload - KieAI Image Edit:
/api/kieai/image/image-edit->/api/front/kieai/image-edit(KieAIController) - Upload File: already calls
sophia-shop.uj345.cc/api/front/upload/imageOuter(crmeb-front)
Need to Add to crmeb-front (3 modules)
Module 1: KieAI Video (Sora2) -- 6 endpoints
Source: KieAI2VideoController.java + Sora2ServiceImpl.java
New endpoints to add to KieAIController or a new KieAIVideoController:
POST /api/front/kieai/text-to-video(createTextToVideoTask)POST /api/front/kieai/image-to-video(createImageToVideoTask)POST /api/front/kieai/pro/text-to-video(createProTextToVideoTask)POST /api/front/kieai/pro/image-to-video(createProImageToVideoTask)POST /api/front/kieai/remove-watermark(removeWatermark)POST /api/front/kieai/file-url-upload(uploadFileByUrl)GET /api/front/kieai/video/task/{taskId}(getTaskStatus - video task query)
Files to create/copy:
- DTO: Copy
Sora2Request->com.zbkj.common.request.kieai.Sora2Request - DTO: Copy
TaskStatus->com.zbkj.common.response.kieai.KieAIVideoTaskStatus - DTO: Copy
CreateProTextToVideoRequest->com.zbkj.common.request.kieai.CreateProTextToVideoRequest - Service: Create
ToolSora2Serviceinterface incrmeb-service - ServiceImpl: Copy
Sora2ServiceImpllogic ->ToolSora2ServiceImplincrmeb-service - Controller: Add video endpoints to KieAIController.java or new controller
- Helper: Copy
HttpRequestUtils->com.zbkj.common.utils.HttpRequestUtils(or reuse existing crmeb HTTP utils)
Dependencies already available:
- Apache HttpClient (in crmeb-common pom.xml)
- FastJSON (in crmeb parent pom.xml)
KieAIConfigalready exists withbaseUrl,apiCallbackUrletc.
Config to add to KieAIConfig:
apiUploadBaseUrlproperty (used by Sora2ServiceImpl for file uploads)
Module 2: Tencent ASR -- 3 endpoints
Source: TencentAsrController.java + TencentAsrServiceImpl.java
New endpoints:
POST /api/front/tencent/asr/create-taskGET /api/front/tencent/asr/query-status/{taskId}POST /api/front/tencent/asr/sentence-recognition
Files to create/copy:
- DTO: Copy
TencentAsrRequest->com.zbkj.common.request.tencent.TencentAsrRequest - DTO: Copy
TencentAsrResponse->com.zbkj.common.response.tencent.TencentAsrResponse - DTO: Copy
TencentAsrTaskStatus->com.zbkj.common.response.tencent.TencentAsrTaskStatus - Config: Create
TencentAsrConfigincom.zbkj.common.config(prefixtencent-asr, fields: secretId, secretKey, region, connectTimeout, readTimeout, defaultEngineModel, defaultResTextFormat, defaultChannelNum, enabled) - Service: Create
ToolTencentAsrServiceinterface - ServiceImpl: Copy
TencentAsrServiceImpllogic ->ToolTencentAsrServiceImpl - Controller: Create
TencentAsrControllerin crmeb-front at/api/front/tencent/asr
New dependency needed in crmeb-common/pom.xml:
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>3.1.880</version>
</dependency>
Config to add to application-sophia.yml:
tencent-asr:
secret-id: ${TENCENT_SECRET_ID:xxx}
secret-key: ${TENCENT_SECRET_KEY:xxx}
region: ap-shanghai
enabled: true
Module 3: Articles (models-integration style) -- 3 endpoints
Source: ArticleController.java
Note: crmeb-front already has an ArticleController at /api/front/article for CMS articles, but that is a different data model (CRMEB's own articles). The models-integration ArticleController manages AI-generated content articles in a separate eb_article table with fields like taskId, prompt, videoUrl, statusTask.
Approach: Add these as new endpoints in a new controller ArticleModelsController at /api/front/article-models to avoid conflict with the existing crmeb ArticleController.
New endpoints:
GET /api/front/article-models/{id}(getArticleById)GET /api/front/article-models(getArticleList, paginated)GET /api/front/article-models/search(searchArticles)
Files needed:
- The
Articlemodel,ArticleVO,ArticleMapper,UserMapperalready exist in models-integration's DB tables. Need to ensure the crmeb service can access the sameeb_articletable or create equivalent mapper/model in crmeb-common. - Service: Create
ToolArticleModelsServiceinterface + impl - Controller: Create
ArticleModelsController
Callback Endpoints (remain in models-integration)
The following callbacks should stay in models-integration since they are called by external services (KieAI, Coze) and need a stable URL:
POST /api/kieai/callbackPOST /api/kieai/callback20994POST /api/diet-checkin/callback/videoPOST /api/diet-checkin/callback/analysis
These use callBackUrl that is configured in the task creation requests, so they can continue pointing to models-integration.
Coze Workflow Resume
The frontend cozeWorkflowResume function calls /api/coze/workflow/resume, but this endpoint does not exist in either models-integration or crmeb-front. The Coze SDK does support workflow resume. Need to:
- Add
/api/front/coze/workflow/resumeendpoint to crmeb-front CozeController - Add
workflowResume()method toToolCozeService/ToolCozeServiceImpl
Frontend Changes (models-api.js)
After backend is ready, update models-api.js:
- Change
API_BASE_URLfrom'https://sophia-shop.uj345.cc/models'to'https://sophia-shop.uj345.cc'(crmeb-front domain) - Update all API paths to use
/api/front/prefix:
/api/articles/{id}->/api/front/article-models/{id}/api/articles->/api/front/article-models/api/articles/search->/api/front/article-models/search/api/kieai/text-to-video->/api/front/kieai/text-to-video/api/kieai/image-to-video->/api/front/kieai/image-to-video/api/kieai/image/image-edit->/api/front/kieai/image-edit/api/kieai/task/{taskId}->/api/front/kieai/video/task/{taskId}/api/kieai/file-url-upload->/api/front/kieai/file-url-upload/api/tencent/asr/create-task->/api/front/tencent/asr/create-task/api/tencent/asr/query-status/{id}->/api/front/tencent/asr/query-status/{id}/api/coze/chat->/api/front/coze/chat/api/coze/chat/retrieve->/api/front/coze/chat/retrieve/api/coze/chat/messages/list->/api/front/coze/chat/messages/list/api/coze/workflow/run->/api/front/coze/workflow/run/api/coze/workflow/stream->/api/front/coze/workflow/stream/api/coze/workflow/resume->/api/front/coze/workflow/resume/api/coze/file/upload->/api/front/coze/file/upload(incozeUploadFile)
- Remove hardcoded
tenant_id,api_key, callback URLs from frontend -- move these to server-side config
Interceptor Config
Ensure the new routes are excluded from token interceptor in WebConfig (or application.yml excludePathPatterns):
/api/front/tencent/asr/**/api/front/article-models/**- KieAI video endpoints are under
/api/front/kieai/**which is likely already excluded