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
f86f7eca
Commit
f86f7eca
authored
Jun 20, 2025
by
wangzhengwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
课程 证书 项目分类列表二级查询
parent
ef4bcd6d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
4 deletions
+136
-4
Course.php
app/api/controller/Course.php
+1
-1
Cert.php
app/api/controller/cert/Cert.php
+2
-1
Project.php
app/api/controller/project/Project.php
+3
-1
Cert.php
app/model/Cert.php
+50
-0
Course.php
app/model/Course.php
+32
-0
Project.php
app/model/Project.php
+48
-1
No files found.
app/api/controller/Course.php
View file @
f86f7eca
...
...
@@ -114,7 +114,7 @@ class Course extends BaseController
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$list
=
(
new
CourseModel
())
->
getCourseList
(
$data
[
'
category_id'
],
$page
,
$pageSize
,
$data
[
'searchKeyWords'
]
??
null
);
$list
=
(
new
CourseModel
())
->
getCourseList
Second
(
$data
[
'category_id'
],
$data
[
'second_
category_id'
],
$page
,
$pageSize
,
$data
[
'searchKeyWords'
]
??
null
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
...
...
app/api/controller/cert/Cert.php
View file @
f86f7eca
...
...
@@ -47,7 +47,8 @@ class Cert extends BaseController
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$list
=
(
new
CertModel
())
->
getCertList
(
$data
[
'category_id'
],
$page
,
$pageSize
,
$data
[
'type'
],
$data
[
'searchKeyWords'
]
??
null
);
// $list = (new CertModel())->getCertList($data['category_id'],$page,$pageSize,$data['type'],$data['searchKeyWords'] ?? null);
$list
=
(
new
CertModel
())
->
getCertListSecond
(
$data
[
'category_id'
],
$data
[
'second_category_id'
],
$page
,
$pageSize
,
$data
[
'type'
],
$data
[
'searchKeyWords'
]
??
null
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
...
...
app/api/controller/project/Project.php
View file @
f86f7eca
...
...
@@ -57,7 +57,9 @@ class Project extends BaseController
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$list
=
(
new
ProjectModel
())
->
getProjectList
(
$data
[
'category_id'
],
$page
,
$pageSize
,
$data
[
'type'
],
$data
[
'searchKeyWords'
]
??
null
);
// $list = (new ProjectModel())->getProjectList($data['category_id'],$page,$pageSize,$data['type'],$data['searchKeyWords'] ?? null);
$list
=
(
new
ProjectModel
())
->
getProjectListSecond
(
$data
[
'category_id'
],
$data
[
'second_category_id'
],
$page
,
$pageSize
,
$data
[
'type'
],
$data
[
'searchKeyWords'
]
??
null
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
...
...
app/model/Cert.php
View file @
f86f7eca
...
...
@@ -113,6 +113,56 @@ class Cert extends Model
}
public
function
getCertListSecond
(
$first_category_id
,
$second_category_id
,
$page
,
$pageSize
,
$type
,
$searchKeyWords
=
null
)
{
$where
=
[
'is_sell'
=>
1
,
'is_del'
=>
0
];
$query
=
self
::
where
(
$where
);
// 处理分类查询逻辑
if
(
$second_category_id
>
0
)
{
// 情况1:只要二级分类有值,无论一级分类是什么,都精确查询该二级分类
$query
->
where
(
'cate_id'
,
$second_category_id
);
}
elseif
(
$first_category_id
>
0
)
{
// 情况2:只有一级分类有值,查询该一级分类及其所有子分类
$son_ids
=
CertCategory
::
where
(
'pid'
,
$first_category_id
)
->
column
(
'id'
);
$query
->
whereIn
(
'cate_id'
,
array_merge
([
$first_category_id
],
$son_ids
));
}
// 如果一级分类为0,则不限制分类(查询全部)
if
(
$searchKeyWords
)
{
$query
->
where
(
'title'
,
'like'
,
'%'
.
$searchKeyWords
.
'%'
);
}
if
(
$type
==
2
)
{
$currentTime
=
time
();
$query
->
where
(
'start_time'
,
'<='
,
$currentTime
)
->
where
(
'end_time'
,
'>='
,
$currentTime
);
$query
->
order
(
'end_time'
,
'asc'
);
}
else
{
$query
->
order
(
'createtime'
,
'desc'
);
}
$list
=
$query
->
field
(
'id,thumb_id,title,createtime,description,shrq,fzjg,price,tag_ids,start_time,end_time'
)
->
with
([
'thumb'
])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
if
(
$list
->
isEmpty
()
||
$type
==
2
)
{
return
$list
;
}
$list
=
UtilService
::
listWithTags
(
$list
,
CertTag
::
class
,
'tag_ids'
);
return
$list
;
}
//封面图
public
function
thumb
()
{
...
...
app/model/Course.php
View file @
f86f7eca
...
...
@@ -110,6 +110,38 @@ class Course extends Model
]);
}
// 6.20 两级分类查询
public
function
getCourseListSecond
(
$first_category_id
,
$second_category_id
,
$page
,
$pageSize
,
$searchKeyWords
=
null
)
{
$where
=
[
'status'
=>
3
,
'is_sell'
=>
1
,
'is_del'
=>
0
];
$query
=
self
::
where
(
$where
);
// 处理分类查询逻辑
if
(
$second_category_id
>
0
)
{
// 情况1:只要二级分类有值,无论一级分类是什么,都精确查询该二级分类
$query
->
where
(
'cate_id'
,
$second_category_id
);
}
elseif
(
$first_category_id
>
0
)
{
// 情况2:只有一级分类有值,查询该一级分类及其所有子分类
$son_ids
=
CourseCategory
::
where
(
'pid'
,
$first_category_id
)
->
column
(
'id'
);
$query
->
whereIn
(
'cate_id'
,
array_merge
([
$first_category_id
],
$son_ids
));
}
// 如果一级分类为0,则不限制分类(查询全部)
if
(
$searchKeyWords
)
{
$query
->
where
(
'title'
,
'like'
,
'%'
.
$searchKeyWords
.
'%'
);
}
return
$query
->
field
(
'id,thumb,title,createtime,description,price,content'
)
->
with
([
'thumb'
])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
}
//获取课程详情
public
function
getCourseDetail
(
$course_id
=
0
,
$userId
=
0
)
{
...
...
app/model/Project.php
View file @
f86f7eca
...
...
@@ -125,7 +125,6 @@ class Project extends Model
if
(
$category_id
)
{
// $where['cate_id'] = $category_id;
$son_ids
=
ProjectCategory
::
where
(
'pid'
,
$category_id
)
->
column
(
'id'
);
$query
->
whereIn
(
'cate_id'
,
array_merge
([
$category_id
],
$son_ids
));
}
...
...
@@ -159,6 +158,54 @@ class Project extends Model
}
// 6.20 两级分类查询
public
function
getProjectListSecond
(
$first_category_id
,
$second_category_id
,
$page
,
$pageSize
,
$type
,
$searchKeyWords
=
null
)
{
// 基础查询条件
$where
=
[
'sh_status'
=>
2
,
'status'
=>
1
];
$query
=
self
::
where
(
$where
);
$query
->
where
(
'put_end_time'
,
'>'
,
time
());
// 处理分类查询逻辑
if
(
$second_category_id
>
0
)
{
// 情况1:只要二级分类有值,无论一级分类是什么,都精确查询该二级分类
$query
->
where
(
'cate_id'
,
$second_category_id
);
}
elseif
(
$first_category_id
>
0
)
{
// 情况2:只有一级分类有值,查询该一级分类及其所有子分类
$son_ids
=
ProjectCategory
::
where
(
'pid'
,
$first_category_id
)
->
column
(
'id'
);
$query
->
whereIn
(
'cate_id'
,
array_merge
([
$first_category_id
],
$son_ids
));
}
// 如果一级分类为0,则不限制分类(查询全部)
// 关键词搜索
if
(
$searchKeyWords
)
{
$query
->
where
(
'title'
,
'like'
,
'%'
.
$searchKeyWords
.
'%'
);
}
$query
->
order
(
'createtime'
,
'desc'
);
// 热门项目
if
(
$type
==
3
)
{
$query
->
where
(
'is_hot'
,
1
);
}
$list
=
$query
->
field
(
'id,sn,title,createtime,cate_id,yusuan,zhouqi,tag_ids,put_end_time,thumb'
)
->
with
([
'thumb'
])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
if
(
$list
->
isEmpty
())
{
return
$list
;
}
$list
=
UtilService
::
listWithTags
(
$list
,
ProjectTag
::
class
,
'tag_ids'
);
return
$list
;
}
//项目详情
public
function
projectDetail
(
$id
,
$userId
)
{
...
...
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