Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-communication
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-communication
Commits
58ee4446
Commit
58ee4446
authored
Jul 31, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
04375d70
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
yd-communication-api/src/main/java/com/yd/communication/api/service/impl/ApiRecordingTaskServiceImpl.java
+20
-12
No files found.
yd-communication-api/src/main/java/com/yd/communication/api/service/impl/ApiRecordingTaskServiceImpl.java
View file @
58ee4446
package
com
.
yd
.
communication
.
api
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.yd.common.enums.CommonEnum
;
import
com.yd.common.enums.ProjectEnum
;
import
com.yd.common.enums.TenantEnum
;
...
...
@@ -37,6 +38,9 @@ public class ApiRecordingTaskServiceImpl implements ApiRecordingTaskService {
@Resource
private
ApiOssFeignClient
apiOssFeignClient
;
@Resource
private
ObjectMapper
objectMapper
;
// 注入 Jackson ObjectMapper
/**
* 开始录制
* @param request
...
...
@@ -96,42 +100,46 @@ public class ApiRecordingTaskServiceImpl implements ApiRecordingTaskService {
ApiUploadFileRequest
uploadRequest
=
new
ApiUploadFileRequest
();
uploadRequest
.
setTenantBizId
(
TenantEnum
.
YD
.
getTenantBizId
());
uploadRequest
.
setProjectBizId
(
ProjectEnum
.
SFP_CLIENT
.
getProjectBizId
());
// 对象业务ID
uploadRequest
.
setObjectBizId
(
task
.
getBizId
());
// 对象类型:录制文件
uploadRequest
.
setObjectType
(
"recording_task"
);
// 对象所属表名:录制任务表
uploadRequest
.
setObjectTableName
(
"recording_task"
);
// 3. 调用 OSS Feign 客户端上传文件
Result
<
ApiUploadResponse
>
uploadResult
=
apiOssFeignClient
.
uploadFileBody
(
file
,
uploadRequest
);
// 3. 将 uploadRequest 转为 JSON 字符串
String
requestJson
;
try
{
requestJson
=
objectMapper
.
writeValueAsString
(
uploadRequest
);
}
catch
(
Exception
e
)
{
log
.
error
(
"序列化请求参数失败"
,
e
);
throw
new
BusinessException
(
"请求参数序列化失败"
);
}
// 4. 调用新的 Feign 接口(使用 JSON 字符串方式)
Result
<
ApiUploadResponse
>
uploadResult
=
apiOssFeignClient
.
uploadFileBodyWithJson
(
file
,
requestJson
);
if
(
uploadResult
==
null
||
uploadResult
.
getCode
()
!=
200
)
{
String
errorMsg
=
uploadResult
!=
null
?
uploadResult
.
getMsg
()
:
"上传服务返回空"
;
log
.
error
(
"上传文件到OSS失败: {}"
,
errorMsg
);
throw
new
BusinessException
(
"上传文件失败: "
+
errorMsg
);
}
//
4
. 获取上传结果
//
5
. 获取上传结果
ApiUploadResponse
uploadResponse
=
uploadResult
.
getData
();
if
(
uploadResponse
==
null
)
{
throw
new
BusinessException
(
"上传文件成功但未返回文件信息"
);
}
// 5. 更新录制任务
//文件URL
// 6. 更新录制任务
task
.
setFileUrl
(
uploadResponse
.
getUrl
());
task
.
setFileSize
(
uploadResponse
.
getFileSize
());
task
.
setStatus
(
"3"
);
// 已停止
//文件扩展名
task
.
setStatus
(
"3"
);
task
.
setFileFormat
(
uploadResponse
.
getFileType
());
task
.
setStopTime
(
LocalDateTime
.
now
());
iRecordingTaskService
.
updateById
(
task
);
//
6
. 返回结果
//
7
. 返回结果
Map
<
String
,
String
>
result
=
new
HashMap
<>();
result
.
put
(
"taskId"
,
task
.
getTaskId
());
result
.
put
(
"fileUrl"
,
task
.
getFileUrl
());
result
.
put
(
"fileKey"
,
uploadResponse
.
getFileKey
());
// 方便前端后续操作
result
.
put
(
"fileKey"
,
uploadResponse
.
getFileKey
());
log
.
info
(
"录制文件上传成功,fileUrl={}"
,
task
.
getFileUrl
());
return
Result
.
success
(
result
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment