mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-19 17:35:54 +08:00
新增App资讯相关接口
This commit is contained in:
@@ -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