Commit 0037833c by rongkailun

文章发布列表条件筛选查询以及查看接口

parent 122e842f
...@@ -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 {
/** /**
* 列表 * 列表
*/ */
@RequestMapping("/list") @PostMapping("/list")
// @RequiresPermissions("manage:news:list") // @RequiresPermissions("manage:news:list")
public R list(@RequestParam Map<String, Object> params) { public R list(@RequestBody NewsParams newsParams) {
PageUtils 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
*/ */
@RequestMapping("/save") @PostMapping("/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 {
/** /**
* 修改 * 修改
*/ */
@RequestMapping("/update") @PostMapping("/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 {
/** /**
* 删除 * 删除
*/ */
@RequestMapping("/delete") @PostMapping("/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 {
/** /**
* 删除 * 删除
*/ */
@RequestMapping("/verifyNews") @PostMapping("/verifyNews")
// @RequiresPermissions("manage:news:verify") // @RequiresPermissions("manage:news:verify")
public R verify(@RequestBody NewsEntity news) { public R verify(@RequestBody NewsEntity news) {
try { try {
......
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}
...@@ -13,5 +19,6 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -13,5 +19,6 @@ 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);
} }
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;
}
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);
} }
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
...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment