Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecttwo
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangtao
projecttwo
Commits
91792091
Commit
91792091
authored
Jul 03, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
学习进度优化
parent
f3000da9
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
165 additions
and
51 deletions
+165
-51
Test.php
app/api/controller/Test.php
+58
-0
CourseProgressService.php
app/api/service/CourseProgressService.php
+106
-50
CertOrder.php
app/model/CertOrder.php
+1
-1
No files found.
app/api/controller/Test.php
0 → 100644
View file @
91792091
<?php
namespace
app\api\controller
;
use
OSS\OssClient
;
class
Test
{
public
function
concurrentUpload
(
$object
,
$filePath
)
{
$ossClient
=
new
OssClient
(
/* 配置 */
);
$uploadId
=
$ossClient
->
initiateMultipartUpload
(
config
(
'oss.bucket'
),
$object
);
$partSize
=
10
*
1024
*
1024
;
$fileSize
=
filesize
(
$filePath
);
$partNum
=
ceil
(
$fileSize
/
$partSize
);
$parts
=
[];
$promises
=
[];
// 使用Guzzle或其他HTTP客户端并发请求
$client
=
new
\GuzzleHttp\Client
();
for
(
$i
=
1
;
$i
<=
$partNum
;
$i
++
)
{
$from
=
(
$i
-
1
)
*
$partSize
;
$to
=
min
(
$i
*
$partSize
,
$fileSize
);
$promises
[]
=
$client
->
postAsync
(
'您的上传处理接口'
,
[
'multipart'
=>
[
[
'name'
=>
'part_index'
,
'contents'
=>
$i
],
[
'name'
=>
'file'
,
'contents'
=>
fopen
(
$filePath
,
'r'
),
'headers'
=>
[
'Content-Range'
=>
'bytes '
.
$from
.
'-'
.
$to
.
'/'
.
$fileSize
]
]
]
])
->
then
(
function
(
$response
)
use
(
&
$parts
,
$i
)
{
$parts
[
$i
]
=
[
'PartNumber'
=>
$i
,
'ETag'
=>
$response
->
getHeader
(
'ETag'
)[
0
]
];
});
}
// 等待所有分片上传完成
\GuzzleHttp\Promise\Utils
::
all
(
$promises
)
->
wait
();
// 按分片顺序排序
ksort
(
$parts
);
// 完成上传
$ossClient
->
completeMultipartUpload
(
config
(
'oss.bucket'
),
$object
,
$uploadId
,
$parts
);
}
}
\ No newline at end of file
app/api/service/CourseProgressService.php
View file @
91792091
This diff is collapsed.
Click to expand it.
app/model/CertOrder.php
View file @
91792091
...
...
@@ -73,7 +73,7 @@ class CertOrder extends Model
$list
=
self
::
where
(
$where
)
->
with
([
'user'
=>
[
'headico'
],
'cert'
])
->
order
(
'createtime'
,
'desc'
)
->
field
(
'id,cert_id,user_id,name,updatetime'
)
->
field
(
'id,cert_id,user_id,name,updatetime
,createtime
'
)
->
append
([
'updatetime_text'
])
->
paginate
([
...
...
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