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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
158 additions
and
14 deletions
+158
-14
NewsController.java
...a/io/office/modules/manage/controller/NewsController.java
+13
-13
NewsDao.java
src/main/java/io/office/modules/manage/dao/NewsDao.java
+7
-0
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;
...
@@ -4,16 +4,16 @@ import java.util.Arrays;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
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.controller.AbstractController
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.*
;
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
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.manage.service.NewsService
;
import
io.office.modules.manage.service.NewsService
;
...
@@ -38,11 +38,11 @@ public class NewsController extends AbstractController {
...
@@ -38,11 +38,11 @@ public class NewsController extends AbstractController {
/**
/**
* 列表
* 列表
*/
*/
@
Reque
stMapping
(
"/list"
)
@
Po
stMapping
(
"/list"
)
// @RequiresPermissions("manage:news:list")
// @RequiresPermissions("manage:news:list")
public
R
list
(
@Request
Param
Map
<
String
,
Object
>
p
arams
)
{
public
R
list
(
@Request
Body
NewsParams
newsP
arams
)
{
Page
Utils
page
=
newsService
.
queryPage
(
params
);
Page
<
NewsEntity
>
page
=
this
.
newsService
.
selectNewsList
(
newsParams
,
new
Page
(
newsParams
.
getPage
(),
newsParams
.
getLimit
()));
return
R
.
ok
().
put
(
"page"
,
page
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
}
...
@@ -64,7 +64,7 @@ public class NewsController extends AbstractController {
...
@@ -64,7 +64,7 @@ public class NewsController extends AbstractController {
* @author rkl
* @author rkl
* @date 2021/10/13
* @date 2021/10/13
*/
*/
@
Reque
stMapping
(
"/save"
)
@
Po
stMapping
(
"/save"
)
// @RequiresPermissions("manage:news:save")
// @RequiresPermissions("manage:news:save")
public
R
save
(
@RequestBody
NewsEntity
news
)
{
public
R
save
(
@RequestBody
NewsEntity
news
)
{
try
{
try
{
...
@@ -79,7 +79,7 @@ public class NewsController extends AbstractController {
...
@@ -79,7 +79,7 @@ public class NewsController extends AbstractController {
/**
/**
* 修改
* 修改
*/
*/
@
Reque
stMapping
(
"/update"
)
@
Po
stMapping
(
"/update"
)
// @RequiresPermissions("manage:news:update")
// @RequiresPermissions("manage:news:update")
public
R
update
(
@RequestBody
NewsEntity
news
)
{
public
R
update
(
@RequestBody
NewsEntity
news
)
{
try
{
try
{
...
@@ -94,7 +94,7 @@ public class NewsController extends AbstractController {
...
@@ -94,7 +94,7 @@ public class NewsController extends AbstractController {
/**
/**
* 删除
* 删除
*/
*/
@
Reque
stMapping
(
"/delete"
)
@
Po
stMapping
(
"/delete"
)
// @RequiresPermissions("manage:news:delete")
// @RequiresPermissions("manage:news:delete")
public
R
delete
(
@RequestBody
List
<
Long
>
ids
)
{
public
R
delete
(
@RequestBody
List
<
Long
>
ids
)
{
try
{
try
{
...
@@ -109,7 +109,7 @@ public class NewsController extends AbstractController {
...
@@ -109,7 +109,7 @@ public class NewsController extends AbstractController {
/**
/**
* 删除
* 删除
*/
*/
@
Reque
stMapping
(
"/verifyNews"
)
@
Po
stMapping
(
"/verifyNews"
)
// @RequiresPermissions("manage:news:verify")
// @RequiresPermissions("manage:news:verify")
public
R
verify
(
@RequestBody
NewsEntity
news
)
{
public
R
verify
(
@RequestBody
NewsEntity
news
)
{
try
{
try
{
...
...
src/main/java/io/office/modules/manage/dao/NewsDao.java
View file @
0037833c
package
io
.
office
.
modules
.
manage
.
dao
;
package
io
.
office
.
modules
.
manage
.
dao
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.manage.entity.NewsEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
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.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* ${comments}
* ${comments}
...
@@ -14,4 +20,5 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -14,4 +20,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
@Mapper
public
interface
NewsDao
extends
BaseMapper
<
NewsEntity
>
{
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
;
package
io
.
office
.
modules
.
manage
.
service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.R
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.manage.entity.NewsEntity
;
import
io.office.modules.manage.entity.dto.NewsParams
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
java.util.*
;
import
java.util.*
;
...
@@ -26,5 +28,7 @@ public interface NewsService extends IService<NewsEntity> {
...
@@ -26,5 +28,7 @@ public interface NewsService extends IService<NewsEntity> {
R
deleteNews
(
List
ids
,
SysUserEntity
user
);
R
deleteNews
(
List
ids
,
SysUserEntity
user
);
R
verifyNews
(
NewsEntity
newsEntity
,
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
;
package
io
.
office
.
modules
.
manage
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
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.DateUtils
;
import
io.office.common.utils.R
;
import
io.office.common.utils.R
;
import
io.office.modules.manage.entity.NewsclassEntity
;
import
io.office.modules.manage.entity.NewsclassEntity
;
import
io.office.modules.manage.entity.dto.NewsParams
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
io.office.modules.sys.entity.SysUserEntity
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -25,6 +28,8 @@ import io.office.modules.manage.service.NewsService;
...
@@ -25,6 +28,8 @@ import io.office.modules.manage.service.NewsService;
@Service
(
"newsService"
)
@Service
(
"newsService"
)
public
class
NewsServiceImpl
extends
ServiceImpl
<
NewsDao
,
NewsEntity
>
implements
NewsService
{
public
class
NewsServiceImpl
extends
ServiceImpl
<
NewsDao
,
NewsEntity
>
implements
NewsService
{
@Autowired
private
NewsDao
newsDao
;
@Override
@Override
...
@@ -96,4 +101,11 @@ public class NewsServiceImpl extends ServiceImpl<NewsDao, NewsEntity> implements
...
@@ -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 @@
...
@@ -32,5 +32,91 @@
<result
property=
"checkdate"
column=
"checkdate"
/>
<result
property=
"checkdate"
column=
"checkdate"
/>
</resultMap>
</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>
</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