Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
8timerv2
8timerapiv200
Commits
c3fa9bb8
Commit
c3fa9bb8
authored
Jun 25, 2022
by
284718418@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mybatis-plus-join
parent
a45e7414
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
13 deletions
+20
-13
pom.xml
+2
-2
src/main/java/cn/timer/api/controller/qyxx/CmsController.java
+18
-11
No files found.
pom.xml
View file @
c3fa9bb8
...
...
@@ -304,13 +304,13 @@
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.
3.0
</version>
<version>
3.
4.1
</version>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus
</artifactId>
<version>
3.
3.0
</version>
<version>
3.
4.1
</version>
</dependency>
<!-- mybatis-plus-join -->
<dependency>
...
...
src/main/java/cn/timer/api/controller/qyxx/CmsController.java
View file @
c3fa9bb8
...
...
@@ -92,9 +92,13 @@ public class CmsController {
@ApiOperation
(
value
=
"获取最新讯息的标题、发布时间"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
public
Result
<
List
<
CmsContent
>>
groupbyTime
(
@CurrentUser
UserBean
userBean
)
{
Integer
orgCode
=
userBean
.
getOrgCode
();
QueryWrapper
<
CmsContent
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
select
(
"id"
,
"title"
,
"author"
,
"releasetime"
,
"fmtpath"
).
eq
(
"releasestate"
,
0
)
.
eq
(
"organization_id"
,
orgCode
).
orderByDesc
(
"releasetime"
).
last
(
"limit 6"
);
MPJQueryWrapper
<
CmsContent
>
queryWrapper
=
new
MPJQueryWrapper
<>();
queryWrapper
.
select
(
"t.id"
,
"t.title"
,
"t.author"
,
"t.releasetime"
,
"t.fmtpath"
)
.
leftJoin
(
"cms_content_read ccr on t.id = ccr.cms_content_id"
);
queryWrapper
.
eq
(
"t.releasestate"
,
0
).
and
(!
StringUtils
.
isEmpty
(
userBean
.
getEmpNum
()),
wq
->
wq
.
eq
(
"t.open_status"
,
1
).
or
(
true
,
q
->
q
.
eq
(
"t.open_status"
,
0
).
eq
(
"ccr.user_id"
,
userBean
.
getEmpNum
())))
.
eq
(
"t.organization_id"
,
orgCode
)
.
groupBy
(
"t.id"
)
.
orderByDesc
(
"t.releasetime"
).
last
(
"limit 6"
);
List
<
CmsContent
>
qynr
=
CmsContent
.
builder
().
build
().
selectList
(
queryWrapper
);
return
ResultUtil
.
data
(
qynr
,
"查询分类成功!"
);
}
...
...
@@ -151,9 +155,8 @@ public class CmsController {
MPJQueryWrapper
<
CmsContent
>
queryWrapper
=
new
MPJQueryWrapper
<>();
queryWrapper
.
select
(
"t.id"
,
"t.modularid"
,
"t.title"
,
"t.author"
,
"t.releasetime"
)
.
leftJoin
(
"cms_content_read ccr on t.id = ccr.cms_content_id"
);
queryWrapper
.
eq
(
"t.releasestate"
,
0
).
and
(!
StringUtils
.
isEmpty
(
userBean
.
getEmpNum
()),
wq
->
wq
.
eq
(
"t.open_status"
,
1
).
or
(
).
and
(
true
,
q
->
q
.
eq
(
"t.open_status"
,
0
).
eq
(
"ccr.user_id"
,
userBean
.
getEmpNum
())))
queryWrapper
.
eq
(
"t.releasestate"
,
0
).
and
(!
StringUtils
.
isEmpty
(
userBean
.
getEmpNum
()),
wq
->
wq
.
eq
(
"t.open_status"
,
1
).
or
(
true
,
q
->
q
.
eq
(
"t.open_status"
,
0
).
eq
(
"ccr.user_id"
,
userBean
.
getEmpNum
())))
.
eq
(
"ccr.user_id"
,
userBean
.
getEmpNum
())
.
eq
(
"t.organization_id"
,
userBean
.
getOrgCode
()).
orderByDesc
(
"t.releasetime"
).
eq
(
"t.modularid"
,
id
)
.
last
(
"limit 5"
);
List
<
CmsContent
>
qynrs
=
CmsContent
.
builder
().
build
().
selectList
(
queryWrapper
);
...
...
@@ -330,14 +333,18 @@ public class CmsController {
qyxxQueryDto
.
getCurrentPage
()
==
null
?
1
:
qyxxQueryDto
.
getCurrentPage
(),
qyxxQueryDto
.
getTotalPage
()
==
null
?
10
:
qyxxQueryDto
.
getTotalPage
());
QueryWrapper
<
CmsContent
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"organization_id"
,
userBean
.
getOrgCode
()).
eq
(
"status"
,
1
).
eq
(
"releasestate"
,
0
)
.
eq
(
t
!=
null
&&
t
>
-
1
,
"modularid"
,
t
).
eq
(
r
!=
null
&&
r
>
-
1
,
"releasestate"
,
r
)
.
between
(!
StrUtil
.
hasBlank
(
s
)
&&
!
StrUtil
.
hasBlank
(
e
),
"releasetime"
,
MPJQueryWrapper
<
CmsContent
>
queryWrapper
=
new
MPJQueryWrapper
<>();
queryWrapper
.
select
(
"t.id"
,
"t.title"
,
"t.author"
,
"t.releasetime"
,
"t.fmtpath"
)
.
leftJoin
(
"cms_content_read ccr on t.id = ccr.cms_content_id"
);
queryWrapper
.
and
(!
StringUtils
.
isEmpty
(
userBean
.
getEmpNum
()),
wq
->
wq
.
eq
(
"t.open_status"
,
1
).
or
(
true
,
sq
->
sq
.
eq
(
"t.open_status"
,
0
).
eq
(
"ccr.user_id"
,
userBean
.
getEmpNum
())));
queryWrapper
.
eq
(
"t.organization_id"
,
userBean
.
getOrgCode
()).
eq
(
"t.status"
,
1
).
eq
(
"t.releasestate"
,
0
)
.
eq
(
t
!=
null
&&
t
>
-
1
,
"t.modularid"
,
t
).
eq
(
r
!=
null
&&
r
>
-
1
,
"t.releasestate"
,
r
)
.
between
(!
StrUtil
.
hasBlank
(
s
)
&&
!
StrUtil
.
hasBlank
(
e
),
"t.releasetime"
,
!
StrUtil
.
hasBlank
(
s
)
?
s
:
"1000-01-01 00:00:00"
,
!
StrUtil
.
hasBlank
(
e
)
?
e
:
"9999-01-01 00:00:00"
)
.
and
(!
StrUtil
.
hasBlank
(
q
),
wq
->
wq
.
like
(
"userid"
,
q
).
or
().
like
(
"author"
,
q
).
or
().
like
(
"title"
,
q
))
.
orderByDesc
(
"addeddate"
);
.
and
(!
StrUtil
.
hasBlank
(
q
),
wq
->
wq
.
like
(
"t.userid"
,
q
).
or
().
like
(
"t.author"
,
q
).
or
().
like
(
"title"
,
q
))
.
groupBy
(
"t.id"
)
.
orderByDesc
(
"t.addeddate"
);
IPage
<
CmsContent
>
cmsContentPage
=
CmsContent
.
builder
().
build
().
selectPage
(
page
,
queryWrapper
);
List
<
CmsContent
>
cmsContents
=
cmsContentPage
.
getRecords
();
cmsContentPage
.
getCurrent
();
...
...
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