查询栏目ID以逗号分隔

This commit is contained in:
xpecya 2024-12-12 18:48:54 +08:00
parent 9dcd003187
commit cbba37e4dc
3 changed files with 13 additions and 14 deletions

View File

@ -190,7 +190,7 @@ public class NewsController {
@GetMapping
public PageObject<NewsVO> queryNews(@RequestHeader("auth-token") String token,
@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "column", required = false) Long column,
@RequestParam(value = "column", required = false) String columnList,
@RequestParam(value = "status", required = false) Integer status,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "size", required = false, defaultValue = "10") int size,
@ -217,12 +217,12 @@ public class NewsController {
log.info("path: /news, method: GET, request user id: {}, keyword: {}, column: {}, status: {}, " +
"page: {}, size: {}, last: {}, current: {}, orderBy: {}, direction: {}",
adminUser.getId(), keyword, column, status, page, size, last, current, orderBy, direction);
adminUser.getId(), keyword, columnList, status, page, size, last, current, orderBy, direction);
} catch (Exception e) {
log.error("解析登陆Token出错!", e);
return PageObject.failedPage(500, "服务端错误,请联系系统管理员!");
}
return newsService.queryNews(keyword, column, status, page, size, last, current, orderBy, direction);
return newsService.queryNews(keyword, columnList, status, page, size, last, current, orderBy, direction);
}
}

View File

@ -95,7 +95,7 @@ public interface NewsMapper {
"news.title like concat('%', #{keyword}, '%') " +
"</if>" +
"<if test=\"column != null\">" +
"and news_column_rel.column_id = #{column} " +
"and news_column_rel.column_id in (#{column}) " +
"</if>" +
"<if test=\"status != null\">" +
"and news.status = #{status} " +
@ -111,7 +111,7 @@ public interface NewsMapper {
"limit ${limit} offset ${offset}" +
"</script>")
List<News> queryNews(@Param("keyword") String keyword,
@Param("column") Long column,
@Param("column") String columnList,
@Param("status") Integer status,
@Param("last") Integer last,
@Param("orderBy") String orderBy,
@ -129,7 +129,7 @@ public interface NewsMapper {
"news.title like concat('%', #{keyword}, '%') " +
"</if>" +
"<if test=\"column != null\">" +
"and news_column_rel.column_id = #{column} " +
"and news_column_rel.column_id in (#{column}) " +
"</if>" +
"<if test=\"status != null\">" +
"and news.status = #{status} " +
@ -137,6 +137,6 @@ public interface NewsMapper {
"</where>" +
"</script>")
int queryTotal(@Param("keyword") String keyword,
@Param("column") Long column,
@Param("column") String columnParam,
@Param("status") Integer status);
}

View File

@ -259,7 +259,7 @@ public class NewsService {
public ResultObject<Void> createPublish(Long editorId, SaveNewsDTO saveNewsDTO) {
Long id = saveNewsDTO.getId();
Long newsId = saveNewsDTO.getId();
News news = null;
News news;
if (id != null) {
news = newsMapper.getById(id);
Long draftId = news.getDraftId();
@ -279,7 +279,7 @@ public class NewsService {
newsId = newList.get(0).getId();
}
Long newIdRl = null;
Long newIdRl;
if (id == null) {
newIdRl = newsId;
} else {
@ -329,7 +329,6 @@ public class NewsService {
if (earlyKnow != null) {
Boolean show = earlyKnow.getShow();
if (show != null && show) {
Integer type = earlyKnow.getType();
columnMapper.saveNewsColumnRel(newIdRl, 13L, null);
}
}
@ -454,7 +453,7 @@ public class NewsService {
}
}
}
Long newsId = null;
Long newsId;
if (news.getId() != null) {
newsId = news.getId();
} else {
@ -540,7 +539,7 @@ public class NewsService {
return ResultObject.success();
}
public PageObject<NewsVO> queryNews(String keyword, Long column, Integer status, int page, int size,
public PageObject<NewsVO> queryNews(String keyword, String columnParam, Integer status, int page, int size,
Integer last, Integer current, String orderBy, String direction) {
int offset = 0;
if (current != null) {
@ -549,7 +548,7 @@ public class NewsService {
List<News> newsList;
try {
newsList = newsMapper.queryNews(keyword, column, status, last, orderBy, direction, size, offset);
newsList = newsMapper.queryNews(keyword, columnParam, status, last, orderBy, direction, size, offset);
} catch (Exception e) {
log.error("搜索新闻异常!", e);
return PageObject.failedPage(500, "服务器错误,请联系系统管理员!");
@ -558,7 +557,7 @@ public class NewsService {
PageObject<NewsVO> pageObject = new PageObject<>();
if (page == 1) {
try {
int total = newsMapper.queryTotal(keyword, column, status);
int total = newsMapper.queryTotal(keyword, columnParam, status);
pageObject.setTotal(total);
} catch (Exception e) {
log.error("获取新闻总数异常!", e);