Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴迪
gs1-office-web-sit
Commits
0037833c
Commit
0037833c
authored
Oct 14, 2021
by
rongkailun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文章发布列表条件筛选查询以及查看接口
parent
122e842f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
159 additions
and
15 deletions
+159
-15
NewsController.java
...a/io/office/modules/manage/controller/NewsController.java
+13
-13
NewsDao.java
src/main/java/io/office/modules/manage/dao/NewsDao.java
+8
-1
NewsParams.java
.../java/io/office/modules/manage/entity/dto/NewsParams.java
+33
-0
NewsService.java
...in/java/io/office/modules/manage/service/NewsService.java
+4
-0
NewsServiceImpl.java
...o/office/modules/manage/service/impl/NewsServiceImpl.java
+13
-0
NewsDao.xml
src/main/resources/mapper/manage/NewsDao.xml
+88
-1
No files found.
src/main/java/io/office/modules/manage/controller/NewsController.java
View file @
0037833c
...
...
@@ -4,16 +4,16 @@ import java.util.Arrays;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.office.common.utils.Query
;
import
io.office.modules.manage.entity.dto.NewsParams
;
import
io.office.modules.sys.controller.AbstractController
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.manage.service.NewsService
;
...
...
@@ -38,11 +38,11 @@ public class NewsController extends AbstractController {
/**
* 列表
*/
@
Reque
stMapping
(
"/list"
)
@
Po
stMapping
(
"/list"
)
// @RequiresPermissions("manage:news:list")
public
R
list
(
@Request
Param
Map
<
String
,
Object
>
p
arams
)
{
Page
Utils
page
=
newsService
.
queryPage
(
params
);
public
R
list
(
@Request
Body
NewsParams
newsP
arams
)
{
Page
<
NewsEntity
>
page
=
this
.
newsService
.
selectNewsList
(
newsParams
,
new
Page
(
newsParams
.
getPage
(),
newsParams
.
getLimit
()));
return
R
.
ok
().
put
(
"page"
,
page
);
}
...
...
@@ -64,7 +64,7 @@ public class NewsController extends AbstractController {
* @author rkl
* @date 2021/10/13
*/
@
Reque
stMapping
(
"/save"
)
@
Po
stMapping
(
"/save"
)
// @RequiresPermissions("manage:news:save")
public
R
save
(
@RequestBody
NewsEntity
news
)
{
try
{
...
...
@@ -79,7 +79,7 @@ public class NewsController extends AbstractController {
/**
* 修改
*/
@
Reque
stMapping
(
"/update"
)
@
Po
stMapping
(
"/update"
)
// @RequiresPermissions("manage:news:update")
public
R
update
(
@RequestBody
NewsEntity
news
)
{
try
{
...
...
@@ -94,7 +94,7 @@ public class NewsController extends AbstractController {
/**
* 删除
*/
@
Reque
stMapping
(
"/delete"
)
@
Po
stMapping
(
"/delete"
)
// @RequiresPermissions("manage:news:delete")
public
R
delete
(
@RequestBody
List
<
Long
>
ids
)
{
try
{
...
...
@@ -109,7 +109,7 @@ public class NewsController extends AbstractController {
/**
* 删除
*/
@
Reque
stMapping
(
"/verifyNews"
)
@
Po
stMapping
(
"/verifyNews"
)
// @RequiresPermissions("manage:news:verify")
public
R
verify
(
@RequestBody
NewsEntity
news
)
{
try
{
...
...
src/main/java/io/office/modules/manage/dao/NewsDao.java
View file @
0037833c
package
io
.
office
.
modules
.
manage
.
dao
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.office.modules.manage.entity.NewsEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
io.office.modules.manage.entity.dto.NewsParams
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
/**
* ${comments}
...
...
@@ -13,5 +19,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public
interface
NewsDao
extends
BaseMapper
<
NewsEntity
>
{
List
<
NewsEntity
>
selectNewsList
(
@Param
(
"newsParams"
)
NewsParams
newsParams
,
Page
page
);
}
src/main/java/io/office/modules/manage/entity/dto/NewsParams.java
0 → 100644
View file @
0037833c
package
io
.
office
.
modules
.
manage
.
entity
.
dto
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.util.*
;
/**
* @author rkl
* @description 文章管理入参实体类
* @date 2021/10/14
*/
@Data
public
class
NewsParams
{
private
int
page
;
private
int
limit
;
private
String
title
;
private
int
levels
;
private
String
author
;
private
String
editor
;
private
String
keyword
;
private
String
status
;
private
String
auditor
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
releaseTimeStart
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
releaseTimeEnd
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
updateTimeStart
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
updateTimeEnd
;
}
src/main/java/io/office/modules/manage/service/NewsService.java
View file @
0037833c
package
io
.
office
.
modules
.
manage
.
service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.manage.entity.dto.NewsParams
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
java.util.*
;
...
...
@@ -26,5 +28,7 @@ public interface NewsService extends IService<NewsEntity> {
R
deleteNews
(
List
ids
,
SysUserEntity
user
);
R
verifyNews
(
NewsEntity
newsEntity
,
SysUserEntity
user
);
Page
<
NewsEntity
>
selectNewsList
(
NewsParams
newsParams
,
Page
page
);
}
src/main/java/io/office/modules/manage/service/impl/NewsServiceImpl.java
View file @
0037833c
package
io
.
office
.
modules
.
manage
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.office.common.utils.DateUtils
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.NewsclassEntity
;
import
io.office.modules.manage.entity.dto.NewsParams
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
...
...
@@ -25,6 +28,8 @@ import io.office.modules.manage.service.NewsService;
@Service
(
"newsService"
)
public
class
NewsServiceImpl
extends
ServiceImpl
<
NewsDao
,
NewsEntity
>
implements
NewsService
{
@Autowired
private
NewsDao
newsDao
;
@Override
...
...
@@ -96,4 +101,11 @@ public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements
}
}
@Override
public
Page
<
NewsEntity
>
selectNewsList
(
NewsParams
newsParams
,
Page
page
)
{
List
<
NewsEntity
>
newsList
=
this
.
newsDao
.
selectNewsList
(
newsParams
,
page
);
page
.
setRecords
(
newsList
);
return
page
;
}
}
\ No newline at end of file
src/main/resources/mapper/manage/NewsDao.xml
View file @
0037833c
...
...
@@ -32,5 +32,91 @@
<result
property=
"checkdate"
column=
"checkdate"
/>
</resultMap>
<!--查询新闻列表-->
<select
id=
"selectNewsList"
resultMap=
"newsMap"
parameterType=
"io.office.modules.manage.entity.dto.NewsParams"
>
SELECT
t.id,
t.title,
t.author,
t.showtime,
t.startdate,
t.keyword,
t.editor,
t.lasteditor,
t.auditor,
t.status,
t.classid,
t.levels,
t.releasedate,
t.updatedate
FROM
news t
WHERE
(
(classid BETWEEN 4 AND 8)
OR (classid = 29)
OR (classid = 32)
OR (classid = 33)
OR (
classid IN (
SELECT
Id
FROM
newsClass
WHERE
p_id = 5
)
)
OR (
classid IN (
SELECT
Id
FROM
newsClass
WHERE
p_id = 9
)
)
)
AND id NOT IN (
SELECT
newsid
FROM
TopIcNews AS a
LEFT JOIN news AS b ON a.newsid = b.id
WHERE
a.classid in(429,430,428,435)
)
<choose>
<when
test=
"newsParams.levels == 0"
>
AND levels = #{newsParams.levels}
</when>
<otherwise>
AND levels > 0
</otherwise>
</choose>
<if
test=
"newsParams.releaseTimeStart !=null and newsParams.releaseTimeEnd !=null"
>
and releasedate BETWEEN #{newsParams.releaseTimeStart} AND #{newsParams.releaseTimeEnd}
</if>
<if
test=
"newsParams.updateTimeStart !=null and newsParams.updateTimeEnd !=null"
>
and updatedate BETWEEN #{newsParams.updateTimeStart} AND #{newsParams.updateTimeEnd}
</if>
<if
test=
"newsParams.keyword !=null and newsParams.keyword !=''"
>
and keyword like concat('%',#{newsParams.keyword},'%')
</if>
<if
test=
"newsParams.title !=null and newsParams.title !=''"
>
and title like concat('%',#{newsParams.title},'%')
</if>
<if
test=
"newsParams.author !=null and newsParams.author !=''"
>
and author like concat('%',#{newsParams.author},'%')
</if>
<if
test=
"newsParams.status !=null"
>
and status =#{newsParams.status}
</if>
<if
test=
"newsParams.auditor !=null and newsParams.auditor !=''"
>
and auditor =#{newsParams.auditor}
</if>
ORDER BY
releasedate DESC
</select>
</mapper>
\ 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