mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-19 09:25:54 +08:00
新增App资讯相关接口
This commit is contained in:
@@ -121,6 +121,6 @@ public class NewsCategoryController extends BaseController
|
||||
@ApiOperation("删除新闻分类")
|
||||
public AjaxResult remove(@PathVariable Long[] categoryIds)
|
||||
{
|
||||
return toAjax(newsCategoryService.deleteNewsCategoryByCategoryIds(categoryIds));
|
||||
return newsCategoryService.deleteNewsCategoryByCategoryIds(categoryIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.iot.controller;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.iot.model.CategoryNews;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -51,6 +52,33 @@ public class NewsController extends BaseController
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询轮播的新闻资讯
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:news:list')")
|
||||
@GetMapping("/bannerList")
|
||||
@ApiOperation("轮播新闻列表")
|
||||
public AjaxResult bannerList()
|
||||
{
|
||||
News news=new News();
|
||||
news.setIsBanner(1);
|
||||
news.setStatus(1);
|
||||
List<News> list = newsService.selectNewsList(news);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询置顶的新闻资讯
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:news:list')")
|
||||
@GetMapping("/topList")
|
||||
@ApiOperation("置顶新闻列表")
|
||||
public AjaxResult topList()
|
||||
{
|
||||
List<CategoryNews> list = newsService.selectTopNewsList();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出新闻资讯列表
|
||||
*/
|
||||
|
||||
@@ -66,4 +66,12 @@ public interface NewsCategoryMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsCategoryByCategoryIds(Long[] categoryIds);
|
||||
|
||||
/**
|
||||
* 分类下的新闻数量
|
||||
*
|
||||
* @param categoryIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int newsCountInCategorys(Long[] categoryIds);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,13 @@ public interface NewsMapper
|
||||
*/
|
||||
public List<News> selectNewsList(News news);
|
||||
|
||||
/**
|
||||
* 查询置顶新闻资讯列表
|
||||
*
|
||||
* @return 新闻资讯集合
|
||||
*/
|
||||
public List<News> selectTopNewsList();
|
||||
|
||||
/**
|
||||
* 新增新闻资讯
|
||||
*
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.ruoyi.iot.model;
|
||||
|
||||
import com.ruoyi.iot.domain.News;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 产品分类的Id和名称输出
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2021-12-16
|
||||
*/
|
||||
public class CategoryNews
|
||||
{
|
||||
private Long categoryId;
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private List<News> newsList;
|
||||
|
||||
public CategoryNews(){
|
||||
this.newsList=new ArrayList<>();
|
||||
}
|
||||
|
||||
public Long getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setCategoryId(Long categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getCategoryName() {
|
||||
return categoryName;
|
||||
}
|
||||
|
||||
public void setCategoryName(String categoryName) {
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public List<News> getNewsList() {
|
||||
return newsList;
|
||||
}
|
||||
|
||||
public void setNewsList(List<News> newsList) {
|
||||
this.newsList = newsList;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ruoyi.iot.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.iot.domain.NewsCategory;
|
||||
import com.ruoyi.iot.model.IdAndName;
|
||||
|
||||
@@ -57,7 +59,7 @@ public interface INewsCategoryService
|
||||
* @param categoryIds 需要删除的新闻分类主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsCategoryByCategoryIds(Long[] categoryIds);
|
||||
public AjaxResult deleteNewsCategoryByCategoryIds(Long[] categoryIds);
|
||||
|
||||
/**
|
||||
* 删除新闻分类信息
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ruoyi.iot.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.iot.domain.News;
|
||||
import com.ruoyi.iot.model.CategoryNews;
|
||||
|
||||
/**
|
||||
* 新闻资讯Service接口
|
||||
@@ -27,6 +28,13 @@ public interface INewsService
|
||||
*/
|
||||
public List<News> selectNewsList(News news);
|
||||
|
||||
/**
|
||||
* 查询置顶新闻资讯列表
|
||||
*
|
||||
* @return 新闻资讯集合
|
||||
*/
|
||||
public List<CategoryNews> selectTopNewsList();
|
||||
|
||||
/**
|
||||
* 新增新闻资讯
|
||||
*
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ruoyi.iot.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.iot.model.IdAndName;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -89,9 +91,16 @@ public class NewsCategoryServiceImpl implements INewsCategoryService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteNewsCategoryByCategoryIds(Long[] categoryIds)
|
||||
public AjaxResult deleteNewsCategoryByCategoryIds(Long[] categoryIds)
|
||||
{
|
||||
return newsCategoryMapper.deleteNewsCategoryByCategoryIds(categoryIds);
|
||||
int productCount=newsCategoryMapper.newsCountInCategorys(categoryIds);
|
||||
if(productCount>0){
|
||||
return AjaxResult.error("删除失败,请先删除对应分类下的新闻资讯");
|
||||
}
|
||||
if(newsCategoryMapper.deleteNewsCategoryByCategoryIds(categoryIds)>0){
|
||||
return AjaxResult.success("删除成功");
|
||||
}
|
||||
return AjaxResult.error("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.ruoyi.iot.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.iot.mapper.NewsCategoryMapper;
|
||||
import com.ruoyi.iot.model.CategoryNews;
|
||||
import com.ruoyi.iot.model.IdAndName;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.iot.mapper.NewsMapper;
|
||||
@@ -44,6 +49,36 @@ public class NewsServiceImpl implements INewsService
|
||||
return newsMapper.selectNewsList(news);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询置顶新闻资讯列表
|
||||
*
|
||||
* @return 新闻资讯
|
||||
*/
|
||||
@Override
|
||||
public List<CategoryNews> selectTopNewsList()
|
||||
{
|
||||
List<CategoryNews> categoryNewsList =new ArrayList<>();
|
||||
List<News> newsList=newsMapper.selectTopNewsList();
|
||||
for(int i=0;i<newsList.size();i++){
|
||||
boolean isAdd=false;
|
||||
for(int j=0;j<categoryNewsList.size();j++){
|
||||
if(newsList.get(i).getCategoryId().longValue()==categoryNewsList.get(j).getCategoryId().longValue()){
|
||||
categoryNewsList.get(j).getNewsList().add(newsList.get(i));
|
||||
isAdd=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!isAdd) {
|
||||
CategoryNews categoryNews = new CategoryNews();
|
||||
categoryNews.setCategoryId(newsList.get(i).getCategoryId());
|
||||
categoryNews.setCategoryName(newsList.get(i).getCategoryName());
|
||||
categoryNews.getNewsList().add(newsList.get(i));
|
||||
categoryNewsList.add(categoryNews);
|
||||
}
|
||||
}
|
||||
return categoryNewsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增新闻资讯
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user