fix(订单中心):一键成片逻辑优化,兼容素材数量为4个的订单
This commit is contained in:
@@ -137,6 +137,80 @@ stateDiagram-v2
|
||||
|
||||
### 4. 关键接口设计
|
||||
|
||||
#### 4.0 获取访问Token(OAuth2)
|
||||
|
||||
**接口地址:** `POST /api-uaa/oauth/token`
|
||||
|
||||
**认证方式:** HTTP Basic(`Authorization: Basic base64(clientId:clientSecret)`)
|
||||
|
||||
**请求头:**
|
||||
- `Authorization: Basic {base64(clientId:clientSecret)}`
|
||||
- `Content-Type: application/x-www-form-urlencoded`
|
||||
|
||||
**授权模式与参数:**
|
||||
- 密码验证码模式(推荐)
|
||||
- `grant_type=password_code`
|
||||
- `username` 用户名
|
||||
- `password` 密码
|
||||
- `validCode` 校验码(图形/短信)
|
||||
- `deviceId` 设备ID(可用于风控)
|
||||
- 密码模式
|
||||
- `grant_type=password`
|
||||
- `username`
|
||||
- `password`
|
||||
- 客户端模式(服务器到服务器)
|
||||
- `grant_type=client_credentials`
|
||||
- 刷新令牌
|
||||
- `grant_type=refresh_token`
|
||||
- `refresh_token` 刷新令牌
|
||||
|
||||
**响应示例:**
|
||||
```json
|
||||
{
|
||||
"access_token": "eyJraWQiOi...",
|
||||
"token_type": "Bearer",
|
||||
"expires_in": 3600,
|
||||
"refresh_token": "def50200...",
|
||||
"scope": "all openid profile"
|
||||
}
|
||||
```
|
||||
|
||||
**调用示例:**
|
||||
|
||||
- 密码验证码模式
|
||||
```bash
|
||||
curl -X POST 'https://{gateway}/api-uaa/oauth/token' \
|
||||
-H 'Authorization: Basic {base64(clientId:clientSecret)}' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-d 'grant_type=password_code&username=admin&password=123456&validCode=abcd&deviceId=web'
|
||||
```
|
||||
|
||||
- 密码模式
|
||||
```bash
|
||||
curl -X POST 'https://{gateway}/api-uaa/oauth/token' \
|
||||
-H 'Authorization: Basic {base64(clientId:clientSecret)}' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-d 'grant_type=password&username=admin&password=123456'
|
||||
```
|
||||
|
||||
- 客户端模式
|
||||
```bash
|
||||
curl -X POST 'https://{gateway}/api-uaa/oauth/token' \
|
||||
-H 'Authorization: Basic {base64(clientId:clientSecret)}' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-d 'grant_type=client_credentials'
|
||||
```
|
||||
|
||||
- 刷新令牌
|
||||
```bash
|
||||
curl -X POST 'https://{gateway}/api-uaa/oauth/token' \
|
||||
-H 'Authorization: Basic {base64(clientId:clientSecret)}' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-d 'grant_type=refresh_token&refresh_token={refresh_token}'
|
||||
```
|
||||
|
||||
> 说明:可用客户端在 `oauth_client_details` 管理(如 `webApp`、`app`、`zlt` 等示例);令牌类型支持不透明令牌与JWT,网关域名与前缀以实际环境为准。
|
||||
|
||||
#### 4.1 设备执行任务API
|
||||
|
||||
**接口地址:** `POST /api-device/execute/task`
|
||||
|
||||
+19
-10
@@ -131,7 +131,7 @@ public class MediaServiceImpl implements IMediaService {
|
||||
|
||||
// 3. 获取视频文件
|
||||
// List<OrderFile> videoFiles = orderFileService.getOrderVideoFiles(orderNo);
|
||||
if (orderFiles == null || orderFiles.size() < 7) {
|
||||
if (orderFiles == null || orderFiles.size() < qrCode.getMaterialCount()) {
|
||||
throw new BusinessException("订单视频文件数量不足,至少需要2个视频文件");
|
||||
}
|
||||
|
||||
@@ -188,16 +188,17 @@ public class MediaServiceImpl implements IMediaService {
|
||||
List<OrderFile> videoFiles = taskData.getVideoFiles();
|
||||
//@TODO 后期需要通过模板参数进行动态设置clips参数
|
||||
|
||||
clips.put("1", fileCenterService.getViewUrlByPath(videoFiles.get(4).getFilePath()));
|
||||
clips.put("2", fileCenterService.getViewUrlByPath(videoFiles.get(5).getFilePath()));
|
||||
clips.put("3", fileCenterService.getViewUrlByPath(videoFiles.get(6).getFilePath()));
|
||||
clips.put("4", fileCenterService.getViewUrlByPath(videoFiles.get(0).getFilePath()));
|
||||
clips.put("5", fileCenterService.getViewUrlByPath(videoFiles.get(1).getFilePath()));
|
||||
clips.put("6", fileCenterService.getViewUrlByPath(videoFiles.get(2).getFilePath()));
|
||||
clips.put("7", fileCenterService.getViewUrlByPath(videoFiles.get(3).getFilePath()));
|
||||
// 保持既有模板顺序;当索引越界或无素材时返回空URL
|
||||
clips.put("1", getUrlBySafeIndex(videoFiles, 4));
|
||||
clips.put("2", getUrlBySafeIndex(videoFiles, 5));
|
||||
clips.put("3", getUrlBySafeIndex(videoFiles, 6));
|
||||
clips.put("4", getUrlBySafeIndex(videoFiles, 0));
|
||||
clips.put("5", getUrlBySafeIndex(videoFiles, 1));
|
||||
clips.put("6", getUrlBySafeIndex(videoFiles, 2));
|
||||
clips.put("7", getUrlBySafeIndex(videoFiles, 3));
|
||||
|
||||
if (taskData.getVideoFiles().size() > 7) {
|
||||
clips.put("8", fileCenterService.getViewUrlByPath(videoFiles.get(7).getFilePath()));
|
||||
if (videoFiles != null && videoFiles.size() > 7) {
|
||||
clips.put("8", getUrlBySafeIndex(videoFiles, 7));
|
||||
}
|
||||
|
||||
return JSON.toJSONString(clips);
|
||||
@@ -206,6 +207,14 @@ public class MediaServiceImpl implements IMediaService {
|
||||
}
|
||||
}
|
||||
|
||||
private String getUrlBySafeIndex(List<OrderFile> videoFiles, int index) {
|
||||
int size = (videoFiles == null) ? 0 : videoFiles.size();
|
||||
if (size == 0 || index < 0 || index >= size) {
|
||||
return "";
|
||||
}
|
||||
return fileCenterService.getViewUrlByPath(videoFiles.get(index).getFilePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建输出配置
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user