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
98078496
Commit
98078496
authored
Jun 13, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
章节目录学习情况新增
parent
69e4b998
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
Course.php
app/api/controller/Course.php
+13
-7
CourseClass.php
app/model/CourseClass.php
+15
-0
No files found.
app/api/controller/Course.php
View file @
98078496
...
...
@@ -155,20 +155,26 @@ class Course extends BaseController
return
$vo
;
}
$data
=
$request
->
param
();
$token
=
$request
->
header
(
'token'
);
$userId
=
TokenService
::
verifyToken
(
$token
)[
'user_id'
]
??
0
;
$data
=
(
new
CourseModel
())
->
with
([
'getSections'
=>
function
(
$query
)
{
$query
->
with
([
'getCourseClass'
=>
function
(
$query
)
{
$query
->
with
([
'fileData'
])
'getSections'
=>
function
(
$query
)
use
(
$userId
)
{
$query
->
with
([
'getCourseClass'
=>
function
(
$query
)
use
(
$userId
)
{
$query
->
with
([
'fileData'
,
'courseProgress'
=>
function
(
$query
)
use
(
$userId
)
{
$query
->
where
(
'user_id'
,
$userId
);
}])
->
append
([
'tvtime_str'
])
->
order
(
'sort'
,
'asc'
);
// 按 sort 升序排序
->
order
(
'sort'
,
'asc'
);
}]);
},
'getCourseClass'
=>
function
(
$query
)
{
$query
->
with
([
'fileData'
])
'getCourseClass'
=>
function
(
$query
)
use
(
$userId
)
{
$query
->
with
([
'fileData'
,
'courseProgress'
=>
function
(
$query
)
use
(
$userId
)
{
$query
->
where
(
'user_id'
,
$userId
);
}])
->
append
([
'tvtime_str'
])
->
order
(
'sort'
,
'asc'
);
// 按 sort 升序排序
->
order
(
'sort'
,
'asc'
);
}
])
->
where
(
'id'
,
$data
[
'course_id'
])
...
...
app/model/CourseClass.php
View file @
98078496
...
...
@@ -32,4 +32,19 @@ class CourseClass extends Model
// 否则返回 H:i:s 格式
return
sprintf
(
"%02d:%02d:%02d"
,
$hours
,
$minutes
,
$seconds
);
}
public
function
getProgressAttr
(
$value
,
$data
)
{
if
(
empty
(
$data
[
'id'
]))
{
return
[];
}
return
CourseProgress
::
where
(
'class_id'
,
$data
[
'id'
])
->
column
(
'look_tvtime,is_wc_look'
);
}
public
function
courseProgress
()
{
return
$this
->
hasOne
(
CourseProgress
::
class
,
'class_id'
,
'id'
);
}
}
\ No newline at end of file
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