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
ebbcd743
Commit
ebbcd743
authored
May 29, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5.29
parent
f4139d0a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
20 deletions
+108
-20
Course.php
app/api/controller/Course.php
+22
-6
Project.php
app/api/controller/manage/Project.php
+1
-1
ProjectService.php
app/api/service/ProjectService.php
+1
-1
Course.php
app/model/Course.php
+59
-11
CourseTeacher.php
app/model/CourseTeacher.php
+8
-0
Project.php
app/model/Project.php
+17
-1
No files found.
app/api/controller/Course.php
View file @
ebbcd743
...
@@ -15,14 +15,30 @@ class Course extends BaseController
...
@@ -15,14 +15,30 @@ class Course extends BaseController
{
{
/**获取推荐课程列表
/**获取推荐课程列表
* @return \app\html
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
*/
public
function
getRecommendList
()
public
function
getRecommendList
(
Request
$request
)
{
{
$list
=
(
new
CourseModel
())
->
getRecommendList
();
$data
=
$request
->
param
();
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$list
=
(
new
CourseModel
())
->
getRecommendList
(
$data
[
'category_id'
],
$page
,
$pageSize
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
/**获取热门课程列表
*/
public
function
getHostList
(
Request
$request
)
{
$data
=
$request
->
param
();
$page
=
$request
->
param
(
'page'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize'
,
10
);
$list
=
(
new
CourseModel
())
->
getHostList
(
$data
[
'category_id'
],
$page
,
$pageSize
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
}
...
...
app/api/controller/manage/Project.php
View file @
ebbcd743
...
@@ -199,7 +199,7 @@ class Project extends BaseController
...
@@ -199,7 +199,7 @@ class Project extends BaseController
}
}
// 更新项目状态
// 更新项目状态
$projectUpdate
=
[
'status'
=>
2
,
'updatetime'
=>
time
()];
$projectUpdate
=
[
'status'
=>
2
,
'updatetime'
=>
time
()
,
'put_time'
=>
time
()
];
$projectResult
=
ProjectModel
::
where
(
'id'
,
$data
[
'project_id'
])
$projectResult
=
ProjectModel
::
where
(
'id'
,
$data
[
'project_id'
])
->
update
(
$projectUpdate
);
->
update
(
$projectUpdate
);
...
...
app/api/service/ProjectService.php
View file @
ebbcd743
...
@@ -42,7 +42,7 @@ class ProjectService
...
@@ -42,7 +42,7 @@ class ProjectService
}
}
// 4. 更新项目状态为已完成
// 4. 更新项目状态为已完成
$projectUpdate
=
[
'status'
=>
4
,
'updatetime'
=>
time
()];
$projectUpdate
=
[
'status'
=>
4
,
'updatetime'
=>
time
()
,
'complete_time'
=>
time
()
];
$projectResult
=
Project
::
where
(
'id'
,
$putData
[
'project_id'
])
->
update
(
$projectUpdate
);
$projectResult
=
Project
::
where
(
'id'
,
$putData
[
'project_id'
])
->
update
(
$projectUpdate
);
if
(
!
$projectResult
)
{
if
(
!
$projectResult
)
{
throw
new
\Exception
(
'更新项目状态失败'
);
throw
new
\Exception
(
'更新项目状态失败'
);
...
...
app/model/Course.php
View file @
ebbcd743
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
namespace
app\model
;
namespace
app\model
;
use
app\api\service\UserService
;
use
app\api\service\UserService
;
use
app\api\service\UtilService
;
use
app\model\system\SystemUploadFile
;
use
app\model\system\SystemUploadFile
;
use
think\facade\Db
;
use
think\facade\Db
;
use
think\Model
;
use
think\Model
;
...
@@ -22,18 +23,65 @@ class Course extends Model
...
@@ -22,18 +23,65 @@ class Course extends Model
{
{
/**获取推荐课程列表
/**获取推荐课程列表
* @return Course[]|array|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
*/
public
function
getRecommendList
()
public
function
getRecommendList
(
$category_id
,
$page
,
$pageSize
)
{
{
return
self
::
where
([
'status'
=>
3
,
'is_sell'
=>
1
,
'is_del'
=>
0
])
$query
=
self
::
where
([
->
order
(
'click,tvclick,createtime'
,
'desc'
)
'status'
=>
3
,
->
field
(
'id,thumb,title'
)
'is_sell'
=>
1
,
->
limit
(
5
)
'is_del'
=>
0
,
->
select
();
'is_tj'
=>
1
]);
if
(
!
empty
(
$category_id
))
{
$query
->
where
(
'cate_id'
,
$category_id
);
}
$list
=
$query
->
order
(
'click,tvclick,createtime'
,
'desc'
)
->
field
(
'id,thumb,title,description,tag_ids,teacher_id'
)
->
with
([
'thumb'
,
'getTeacher'
=>
[
'thumb'
]])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
if
(
$list
->
isEmpty
())
{
return
$list
;
}
$list
=
UtilService
::
listWithTags
(
$list
,
CourseTag
::
class
,
'tag_ids'
);
return
$list
;
}
/**获取热门课程列表
*/
public
function
getHostList
(
$category_id
,
$page
,
$pageSize
)
{
$query
=
self
::
where
([
'status'
=>
3
,
'is_sell'
=>
1
,
'is_del'
=>
0
,
'is_hot'
=>
1
]);
if
(
!
empty
(
$category_id
))
{
$query
->
where
(
'cate_id'
,
$category_id
);
}
$list
=
$query
->
order
(
'click,tvclick,createtime'
,
'desc'
)
->
field
(
'id,thumb,title,description,tag_ids,teacher_id'
)
->
with
([
'thumb'
,
'getTeacher'
=>
[
'thumb'
]])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
if
(
$list
->
isEmpty
())
{
return
$list
;
}
$list
=
UtilService
::
listWithTags
(
$list
,
CourseTag
::
class
,
'tag_ids'
);
return
$list
;
}
}
/**获取分类下的课程列表
/**获取分类下的课程列表
...
@@ -88,7 +136,7 @@ class Course extends Model
...
@@ -88,7 +136,7 @@ class Course extends Model
public
function
getTeacher
()
public
function
getTeacher
()
{
{
return
$this
->
hasOne
(
CourseTeacher
::
class
,
'id'
,
'teacher_id'
)
return
$this
->
hasOne
(
CourseTeacher
::
class
,
'id'
,
'teacher_id'
)
->
field
(
'id,nickname,description'
);
->
field
(
'id,nickname,description
,thumb_id
'
);
}
}
//关联章节
//关联章节
...
...
app/model/CourseTeacher.php
View file @
ebbcd743
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
namespace
app\model
;
namespace
app\model
;
use
app\model\system\SystemUploadFile
;
use
think\facade\Db
;
use
think\facade\Db
;
use
think\Model
;
use
think\Model
;
...
@@ -28,4 +29,11 @@ class CourseTeacher extends Model
...
@@ -28,4 +29,11 @@ class CourseTeacher extends Model
return
date
(
'Y-m-d H:i:s'
,
$data
[
'createtime'
]);
return
date
(
'Y-m-d H:i:s'
,
$data
[
'createtime'
]);
}
}
public
function
thumb
()
{
return
$this
->
hasOne
(
SystemUploadFile
::
class
,
'fileid'
,
'thumb_id'
)
->
where
(
'isdel'
,
0
)
->
field
(
'fileid,filename,filesize,fileurl,filetype'
);
}
}
}
\ No newline at end of file
app/model/Project.php
View file @
ebbcd743
...
@@ -30,7 +30,23 @@ class Project extends Model
...
@@ -30,7 +30,23 @@ class Project extends Model
protected
$createTime
=
'createtime'
;
protected
$createTime
=
'createtime'
;
protected
$updateTime
=
'updatetime'
;
protected
$updateTime
=
'updatetime'
;
public
function
getShStatusTimeAttr
(
$value
)
{
if
(
!
$value
)
return
null
;
return
date
(
'Y-m-d H:i:s'
,
$value
);
}
public
function
getPutTimeAttr
(
$value
)
{
if
(
!
$value
)
return
null
;
return
date
(
'Y-m-d H:i:s'
,
$value
);
}
public
function
getCompleteTimeAttr
(
$value
)
{
if
(
!
$value
)
return
null
;
return
date
(
'Y-m-d H:i:s'
,
$value
);
}
public
function
getCreatetimeAttr
(
$value
)
public
function
getCreatetimeAttr
(
$value
)
...
@@ -118,7 +134,7 @@ class Project extends Model
...
@@ -118,7 +134,7 @@ class Project extends Model
'page'
=>
$page
,
'page'
=>
$page
,
'list_rows'
=>
$pageSize
'list_rows'
=>
$pageSize
]);
]);
if
(
$list
->
isEmpty
()
||
$type
==
2
)
{
if
(
$list
->
isEmpty
())
{
return
$list
;
return
$list
;
}
}
...
...
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