Initial commit: MSH System\n\n- msh_single_uniapp: Vue 2 + UniApp 前端(微信小程序/H5/App/支付宝小程序)\n- msh_crmeb_22: Spring Boot 2.2 后端(C端API/管理端/业务逻辑)\n- models-integration: AI服务集成(Coze/KieAI/腾讯ASR)\n- docs: 产品文档与设计稿

This commit is contained in:
2026-02-28 05:40:21 +08:00
commit 14d29d51c0
2182 changed files with 482509 additions and 0 deletions

View File

@@ -0,0 +1,193 @@
---
name: Migrate APIs to crmeb-front
overview: 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.
todos:
- id: module-1-video
content: "Module 1: Copy KieAI Video (Sora2) -- DTO, Service, ServiceImpl, Controller endpoints (text-to-video, image-to-video, pro variants, watermark, file-upload, task query)"
status: completed
- id: module-2-asr
content: "Module 2: Copy Tencent ASR -- add tencentcloud-sdk-java dependency, Config, DTO, Service, ServiceImpl, Controller (create-task, query-status, sentence-recognition)"
status: completed
- id: module-3-articles
content: "Module 3: Copy Article Models -- Model/VO/Mapper, Service, Controller at /api/front/article-models (getById, list, search)"
status: completed
- id: coze-resume
content: Add Coze workflow resume endpoint to existing CozeController and ToolCozeService
status: completed
- id: interceptor-config
content: Update WebConfig/application.yml to exclude new routes from token interceptor
status: completed
- id: frontend-update
content: "Update models-api.js: change API_BASE_URL, update all paths to /api/front/ prefix, move secrets to server-side config"
status: completed
isProject: 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](models-integration/src/main/java/com/integration/api/controller/KieAI2VideoController.java) + [Sora2ServiceImpl.java](models-integration/src/main/java/com/integration/api/service/impl/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 `ToolSora2Service` interface in `crmeb-service`
- **ServiceImpl**: Copy `Sora2ServiceImpl` logic -> `ToolSora2ServiceImpl` in `crmeb-service`
- **Controller**: Add video endpoints to [KieAIController.java](msh_crmeb_22/crmeb-front/src/main/java/com/zbkj/front/controller/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)
- `KieAIConfig` already exists with `baseUrl`, `apiCallbackUrl` etc.
Config to add to `KieAIConfig`:
- `apiUploadBaseUrl` property (used by Sora2ServiceImpl for file uploads)
#### Module 2: Tencent ASR -- 3 endpoints
Source: [TencentAsrController.java](models-integration/src/main/java/com/integration/api/controller/TencentAsrController.java) + [TencentAsrServiceImpl.java](models-integration/src/main/java/com/integration/api/service/impl/TencentAsrServiceImpl.java)
New endpoints:
- `POST /api/front/tencent/asr/create-task`
- `GET /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 `TencentAsrConfig` in `com.zbkj.common.config` (prefix `tencent-asr`, fields: secretId, secretKey, region, connectTimeout, readTimeout, defaultEngineModel, defaultResTextFormat, defaultChannelNum, enabled)
- **Service**: Create `ToolTencentAsrService` interface
- **ServiceImpl**: Copy `TencentAsrServiceImpl` logic -> `ToolTencentAsrServiceImpl`
- **Controller**: Create `TencentAsrController` in crmeb-front at `/api/front/tencent/asr`
**New dependency needed** in `crmeb-common/pom.xml`:
```xml
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>3.1.880</version>
</dependency>
```
**Config to add** to `application-sophia.yml`:
```yaml
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](models-integration/src/main/java/com/integration/api/controller/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 `Article` model, `ArticleVO`, `ArticleMapper`, `UserMapper` already exist in models-integration's DB tables. Need to ensure the crmeb service can access the same `eb_article` table or create equivalent mapper/model in crmeb-common.
- **Service**: Create `ToolArticleModelsService` interface + 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/callback`
- `POST /api/kieai/callback20994`
- `POST /api/diet-checkin/callback/video`
- `POST /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/resume` endpoint to crmeb-front CozeController
- Add `workflowResume()` method to `ToolCozeService` / `ToolCozeServiceImpl`
## Frontend Changes (models-api.js)
After backend is ready, update [models-api.js](msh_single_uniapp/utils/models-api.js):
1. Change `API_BASE_URL` from `'https://sophia-shop.uj345.cc/models'` to `'https://sophia-shop.uj345.cc'` (crmeb-front domain)
2. 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` (in `cozeUploadFile`)
3. 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