mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 08:25:53 +08:00
后端新增新闻模块
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
package com.ruoyi.iot.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.iot.model.IdAndName;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.iot.domain.NewsCategory;
|
||||
import com.ruoyi.iot.service.INewsCategoryService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 新闻分类Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
@Api(tags = "新闻分类")
|
||||
@RestController
|
||||
@RequestMapping("/iot/newsCategory")
|
||||
public class NewsCategoryController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private INewsCategoryService newsCategoryService;
|
||||
|
||||
/**
|
||||
* 查询新闻分类列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:newsCategory:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("新闻分类分页列表")
|
||||
public TableDataInfo list(NewsCategory newsCategory)
|
||||
{
|
||||
startPage();
|
||||
List<NewsCategory> list = newsCategoryService.selectNewsCategoryList(newsCategory);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询新闻分类简短列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:newsCategory:list')")
|
||||
@GetMapping("/newsCategoryShortList")
|
||||
@ApiOperation("分类简短列表")
|
||||
public AjaxResult newsCategoryShortList()
|
||||
{
|
||||
List<IdAndName> list = newsCategoryService.selectNewsCategoryShortList();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出新闻分类列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:newsCategory:export')")
|
||||
@Log(title = "新闻分类", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, NewsCategory newsCategory)
|
||||
{
|
||||
List<NewsCategory> list = newsCategoryService.selectNewsCategoryList(newsCategory);
|
||||
ExcelUtil<NewsCategory> util = new ExcelUtil<NewsCategory>(NewsCategory.class);
|
||||
util.exportExcel(response, list, "新闻分类数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新闻分类详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:newsCategory:query')")
|
||||
@GetMapping(value = "/{categoryId}")
|
||||
@ApiOperation("新闻分类详情")
|
||||
public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId)
|
||||
{
|
||||
return AjaxResult.success(newsCategoryService.selectNewsCategoryByCategoryId(categoryId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增新闻分类
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:newsCategory:add')")
|
||||
@Log(title = "新闻分类", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("添加新闻分类")
|
||||
public AjaxResult add(@RequestBody NewsCategory newsCategory)
|
||||
{
|
||||
return toAjax(newsCategoryService.insertNewsCategory(newsCategory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改新闻分类
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:newsCategory:edit')")
|
||||
@Log(title = "新闻分类", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
@ApiOperation("修改新闻分类")
|
||||
public AjaxResult edit(@RequestBody NewsCategory newsCategory)
|
||||
{
|
||||
return toAjax(newsCategoryService.updateNewsCategory(newsCategory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除新闻分类
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:newsCategory:remove')")
|
||||
@Log(title = "新闻分类", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{categoryIds}")
|
||||
@ApiOperation("删除新闻分类")
|
||||
public AjaxResult remove(@PathVariable Long[] categoryIds)
|
||||
{
|
||||
return toAjax(newsCategoryService.deleteNewsCategoryByCategoryIds(categoryIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.ruoyi.iot.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.iot.domain.News;
|
||||
import com.ruoyi.iot.service.INewsService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 新闻资讯Controller
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
@Api(tags = "新闻资讯")
|
||||
@RestController
|
||||
@RequestMapping("/iot/news")
|
||||
public class NewsController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private INewsService newsService;
|
||||
|
||||
/**
|
||||
* 查询新闻资讯列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:news:list')")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("新闻分页列表")
|
||||
public TableDataInfo list(News news)
|
||||
{
|
||||
startPage();
|
||||
List<News> list = newsService.selectNewsList(news);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出新闻资讯列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:news:export')")
|
||||
@Log(title = "新闻资讯", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, News news)
|
||||
{
|
||||
List<News> list = newsService.selectNewsList(news);
|
||||
ExcelUtil<News> util = new ExcelUtil<News>(News.class);
|
||||
util.exportExcel(response, list, "新闻资讯数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新闻资讯详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:news:query')")
|
||||
@GetMapping(value = "/{newsId}")
|
||||
@ApiOperation("新闻详情")
|
||||
public AjaxResult getInfo(@PathVariable("newsId") Long newsId)
|
||||
{
|
||||
return AjaxResult.success(newsService.selectNewsByNewsId(newsId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增新闻资讯
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:news:add')")
|
||||
@Log(title = "新闻资讯", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("添加新闻资讯")
|
||||
public AjaxResult add(@RequestBody News news)
|
||||
{
|
||||
return toAjax(newsService.insertNews(news));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改新闻资讯
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:news:edit')")
|
||||
@Log(title = "新闻资讯", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
@ApiOperation("修改新闻资讯")
|
||||
public AjaxResult edit(@RequestBody News news)
|
||||
{
|
||||
return toAjax(newsService.updateNews(news));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除新闻资讯
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:news:remove')")
|
||||
@Log(title = "新闻资讯", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{newsIds}")
|
||||
@ApiOperation("删除新闻资讯")
|
||||
public AjaxResult remove(@PathVariable Long[] newsIds)
|
||||
{
|
||||
return toAjax(newsService.deleteNewsByNewsIds(newsIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.ruoyi.iot.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 新闻资讯对象 news
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
public class News extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 新闻ID */
|
||||
private Long newsId;
|
||||
|
||||
/** 标题 */
|
||||
@Excel(name = "标题")
|
||||
private String title;
|
||||
|
||||
/** 内容 */
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
/** 图片 */
|
||||
@Excel(name = "图片")
|
||||
private String imgUrl;
|
||||
|
||||
/** 置顶 */
|
||||
@Excel(name = "置顶")
|
||||
private Integer isTop;
|
||||
|
||||
/** 广告 */
|
||||
@Excel(name = "广告")
|
||||
private Integer isBanner;
|
||||
|
||||
/** 分类ID */
|
||||
@Excel(name = "分类ID")
|
||||
private Long categoryId;
|
||||
|
||||
/** 分类名称 */
|
||||
@Excel(name = "分类名称")
|
||||
private String categoryName;
|
||||
|
||||
/** 发布 */
|
||||
@Excel(name = "发布")
|
||||
private Integer status;
|
||||
|
||||
/** 作者 */
|
||||
@Excel(name = "作者")
|
||||
private String author;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
public void setNewsId(Long newsId)
|
||||
{
|
||||
this.newsId = newsId;
|
||||
}
|
||||
|
||||
public Long getNewsId()
|
||||
{
|
||||
return newsId;
|
||||
}
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
public void setImgUrl(String imgUrl)
|
||||
{
|
||||
this.imgUrl = imgUrl;
|
||||
}
|
||||
|
||||
public String getImgUrl()
|
||||
{
|
||||
return imgUrl;
|
||||
}
|
||||
public void setIsTop(Integer isTop)
|
||||
{
|
||||
this.isTop = isTop;
|
||||
}
|
||||
|
||||
public Integer getIsTop()
|
||||
{
|
||||
return isTop;
|
||||
}
|
||||
public void setIsBanner(Integer isBanner)
|
||||
{
|
||||
this.isBanner = isBanner;
|
||||
}
|
||||
|
||||
public Integer getIsBanner()
|
||||
{
|
||||
return isBanner;
|
||||
}
|
||||
public void setCategoryId(Long categoryId)
|
||||
{
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public Long getCategoryId()
|
||||
{
|
||||
return categoryId;
|
||||
}
|
||||
public void setCategoryName(String categoryName)
|
||||
{
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getCategoryName()
|
||||
{
|
||||
return categoryName;
|
||||
}
|
||||
public void setStatus(Integer status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("newsId", getNewsId())
|
||||
.append("title", getTitle())
|
||||
.append("content", getContent())
|
||||
.append("imgUrl", getImgUrl())
|
||||
.append("isTop", getIsTop())
|
||||
.append("isBanner", getIsBanner())
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("categoryName", getCategoryName())
|
||||
.append("status", getStatus())
|
||||
.append("author", getAuthor())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.ruoyi.iot.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 新闻分类对象 news_category
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
public class NewsCategory extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 分类ID */
|
||||
@Excel(name = "分类ID")
|
||||
private Long categoryId;
|
||||
|
||||
/** 分类名字 */
|
||||
@Excel(name = "分类名字")
|
||||
private String categoryName;
|
||||
|
||||
/** 显示顺序 */
|
||||
@Excel(name = "显示顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
public void setCategoryId(Long categoryId)
|
||||
{
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public Long getCategoryId()
|
||||
{
|
||||
return categoryId;
|
||||
}
|
||||
public void setCategoryName(String categoryName)
|
||||
{
|
||||
this.categoryName = categoryName;
|
||||
}
|
||||
|
||||
public String getCategoryName()
|
||||
{
|
||||
return categoryName;
|
||||
}
|
||||
public void setOrderNum(Integer orderNum)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("categoryName", getCategoryName())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.ruoyi.iot.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.iot.domain.NewsCategory;
|
||||
import com.ruoyi.iot.model.IdAndName;
|
||||
|
||||
/**
|
||||
* 新闻分类Mapper接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
public interface NewsCategoryMapper
|
||||
{
|
||||
/**
|
||||
* 查询新闻分类
|
||||
*
|
||||
* @param categoryId 新闻分类主键
|
||||
* @return 新闻分类
|
||||
*/
|
||||
public NewsCategory selectNewsCategoryByCategoryId(Long categoryId);
|
||||
|
||||
/**
|
||||
* 查询新闻分类列表
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 新闻分类集合
|
||||
*/
|
||||
public List<NewsCategory> selectNewsCategoryList(NewsCategory newsCategory);
|
||||
|
||||
/**
|
||||
* 查询新闻分类简短列表
|
||||
*
|
||||
* @return 新闻分类集合
|
||||
*/
|
||||
public List<IdAndName> selectNewsCategoryShortList();
|
||||
|
||||
/**
|
||||
* 新增新闻分类
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertNewsCategory(NewsCategory newsCategory);
|
||||
|
||||
/**
|
||||
* 修改新闻分类
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateNewsCategory(NewsCategory newsCategory);
|
||||
|
||||
/**
|
||||
* 删除新闻分类
|
||||
*
|
||||
* @param categoryId 新闻分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsCategoryByCategoryId(Long categoryId);
|
||||
|
||||
/**
|
||||
* 批量删除新闻分类
|
||||
*
|
||||
* @param categoryIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsCategoryByCategoryIds(Long[] categoryIds);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.iot.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.iot.domain.News;
|
||||
|
||||
/**
|
||||
* 新闻资讯Mapper接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
public interface NewsMapper
|
||||
{
|
||||
/**
|
||||
* 查询新闻资讯
|
||||
*
|
||||
* @param newsId 新闻资讯主键
|
||||
* @return 新闻资讯
|
||||
*/
|
||||
public News selectNewsByNewsId(Long newsId);
|
||||
|
||||
/**
|
||||
* 查询新闻资讯列表
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 新闻资讯集合
|
||||
*/
|
||||
public List<News> selectNewsList(News news);
|
||||
|
||||
/**
|
||||
* 新增新闻资讯
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertNews(News news);
|
||||
|
||||
/**
|
||||
* 修改新闻资讯
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateNews(News news);
|
||||
|
||||
/**
|
||||
* 删除新闻资讯
|
||||
*
|
||||
* @param newsId 新闻资讯主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsByNewsId(Long newsId);
|
||||
|
||||
/**
|
||||
* 批量删除新闻资讯
|
||||
*
|
||||
* @param newsIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsByNewsIds(Long[] newsIds);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.ruoyi.iot.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.iot.domain.NewsCategory;
|
||||
import com.ruoyi.iot.model.IdAndName;
|
||||
|
||||
/**
|
||||
* 新闻分类Service接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
public interface INewsCategoryService
|
||||
{
|
||||
/**
|
||||
* 查询新闻分类
|
||||
*
|
||||
* @param categoryId 新闻分类主键
|
||||
* @return 新闻分类
|
||||
*/
|
||||
public NewsCategory selectNewsCategoryByCategoryId(Long categoryId);
|
||||
|
||||
/**
|
||||
* 查询新闻分类列表
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 新闻分类集合
|
||||
*/
|
||||
public List<NewsCategory> selectNewsCategoryList(NewsCategory newsCategory);
|
||||
|
||||
/**
|
||||
* 查询新闻分类简短列表
|
||||
*
|
||||
* @return 新闻分类集合
|
||||
*/
|
||||
public List<IdAndName> selectNewsCategoryShortList();
|
||||
|
||||
/**
|
||||
* 新增新闻分类
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertNewsCategory(NewsCategory newsCategory);
|
||||
|
||||
/**
|
||||
* 修改新闻分类
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateNewsCategory(NewsCategory newsCategory);
|
||||
|
||||
/**
|
||||
* 批量删除新闻分类
|
||||
*
|
||||
* @param categoryIds 需要删除的新闻分类主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsCategoryByCategoryIds(Long[] categoryIds);
|
||||
|
||||
/**
|
||||
* 删除新闻分类信息
|
||||
*
|
||||
* @param categoryId 新闻分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsCategoryByCategoryId(Long categoryId);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.iot.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.iot.domain.News;
|
||||
|
||||
/**
|
||||
* 新闻资讯Service接口
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
public interface INewsService
|
||||
{
|
||||
/**
|
||||
* 查询新闻资讯
|
||||
*
|
||||
* @param newsId 新闻资讯主键
|
||||
* @return 新闻资讯
|
||||
*/
|
||||
public News selectNewsByNewsId(Long newsId);
|
||||
|
||||
/**
|
||||
* 查询新闻资讯列表
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 新闻资讯集合
|
||||
*/
|
||||
public List<News> selectNewsList(News news);
|
||||
|
||||
/**
|
||||
* 新增新闻资讯
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertNews(News news);
|
||||
|
||||
/**
|
||||
* 修改新闻资讯
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateNews(News news);
|
||||
|
||||
/**
|
||||
* 批量删除新闻资讯
|
||||
*
|
||||
* @param newsIds 需要删除的新闻资讯主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsByNewsIds(Long[] newsIds);
|
||||
|
||||
/**
|
||||
* 删除新闻资讯信息
|
||||
*
|
||||
* @param newsId 新闻资讯主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteNewsByNewsId(Long newsId);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.ruoyi.iot.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.iot.model.IdAndName;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.iot.mapper.NewsCategoryMapper;
|
||||
import com.ruoyi.iot.domain.NewsCategory;
|
||||
import com.ruoyi.iot.service.INewsCategoryService;
|
||||
|
||||
/**
|
||||
* 新闻分类Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
@Service
|
||||
public class NewsCategoryServiceImpl implements INewsCategoryService
|
||||
{
|
||||
@Autowired
|
||||
private NewsCategoryMapper newsCategoryMapper;
|
||||
|
||||
/**
|
||||
* 查询新闻分类
|
||||
*
|
||||
* @param categoryId 新闻分类主键
|
||||
* @return 新闻分类
|
||||
*/
|
||||
@Override
|
||||
public NewsCategory selectNewsCategoryByCategoryId(Long categoryId)
|
||||
{
|
||||
return newsCategoryMapper.selectNewsCategoryByCategoryId(categoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询新闻分类列表
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 新闻分类
|
||||
*/
|
||||
@Override
|
||||
public List<NewsCategory> selectNewsCategoryList(NewsCategory newsCategory)
|
||||
{
|
||||
return newsCategoryMapper.selectNewsCategoryList(newsCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询新闻分类简短列表
|
||||
*
|
||||
* @return 新闻分类
|
||||
*/
|
||||
@Override
|
||||
public List<IdAndName> selectNewsCategoryShortList()
|
||||
{
|
||||
return newsCategoryMapper.selectNewsCategoryShortList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增新闻分类
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertNewsCategory(NewsCategory newsCategory)
|
||||
{
|
||||
newsCategory.setCreateTime(DateUtils.getNowDate());
|
||||
return newsCategoryMapper.insertNewsCategory(newsCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改新闻分类
|
||||
*
|
||||
* @param newsCategory 新闻分类
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateNewsCategory(NewsCategory newsCategory)
|
||||
{
|
||||
newsCategory.setUpdateTime(DateUtils.getNowDate());
|
||||
return newsCategoryMapper.updateNewsCategory(newsCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除新闻分类
|
||||
*
|
||||
* @param categoryIds 需要删除的新闻分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteNewsCategoryByCategoryIds(Long[] categoryIds)
|
||||
{
|
||||
return newsCategoryMapper.deleteNewsCategoryByCategoryIds(categoryIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除新闻分类信息
|
||||
*
|
||||
* @param categoryId 新闻分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteNewsCategoryByCategoryId(Long categoryId)
|
||||
{
|
||||
return newsCategoryMapper.deleteNewsCategoryByCategoryId(categoryId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.ruoyi.iot.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.iot.mapper.NewsMapper;
|
||||
import com.ruoyi.iot.domain.News;
|
||||
import com.ruoyi.iot.service.INewsService;
|
||||
|
||||
/**
|
||||
* 新闻资讯Service业务层处理
|
||||
*
|
||||
* @author kerwincui
|
||||
* @date 2022-04-09
|
||||
*/
|
||||
@Service
|
||||
public class NewsServiceImpl implements INewsService
|
||||
{
|
||||
@Autowired
|
||||
private NewsMapper newsMapper;
|
||||
|
||||
/**
|
||||
* 查询新闻资讯
|
||||
*
|
||||
* @param newsId 新闻资讯主键
|
||||
* @return 新闻资讯
|
||||
*/
|
||||
@Override
|
||||
public News selectNewsByNewsId(Long newsId)
|
||||
{
|
||||
return newsMapper.selectNewsByNewsId(newsId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询新闻资讯列表
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 新闻资讯
|
||||
*/
|
||||
@Override
|
||||
public List<News> selectNewsList(News news)
|
||||
{
|
||||
return newsMapper.selectNewsList(news);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增新闻资讯
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertNews(News news)
|
||||
{
|
||||
news.setCreateTime(DateUtils.getNowDate());
|
||||
return newsMapper.insertNews(news);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改新闻资讯
|
||||
*
|
||||
* @param news 新闻资讯
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateNews(News news)
|
||||
{
|
||||
news.setUpdateTime(DateUtils.getNowDate());
|
||||
return newsMapper.updateNews(news);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除新闻资讯
|
||||
*
|
||||
* @param newsIds 需要删除的新闻资讯主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteNewsByNewsIds(Long[] newsIds)
|
||||
{
|
||||
return newsMapper.deleteNewsByNewsIds(newsIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除新闻资讯信息
|
||||
*
|
||||
* @param newsId 新闻资讯主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteNewsByNewsId(Long newsId)
|
||||
{
|
||||
return newsMapper.deleteNewsByNewsId(newsId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.iot.mapper.NewsCategoryMapper">
|
||||
|
||||
<resultMap type="NewsCategory" id="NewsCategoryResult">
|
||||
<result property="categoryId" column="category_id" />
|
||||
<result property="categoryName" column="category_name" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.ruoyi.iot.model.IdAndName" id="CategoryShortResult">
|
||||
<result property="id" column="category_id" />
|
||||
<result property="name" column="category_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectNewsCategoryVo">
|
||||
select category_id, category_name, order_num, del_flag, create_by, create_time, update_by, update_time, remark from news_category
|
||||
</sql>
|
||||
|
||||
<select id="selectNewsCategoryList" parameterType="NewsCategory" resultMap="NewsCategoryResult">
|
||||
<include refid="selectNewsCategoryVo"/>
|
||||
<where>
|
||||
<if test="categoryName != null and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
|
||||
</where>
|
||||
order by order_num
|
||||
</select>
|
||||
|
||||
<select id="selectNewsCategoryShortList" resultMap="CategoryShortResult">
|
||||
select category_id, category_name
|
||||
from news_category
|
||||
order by order_num
|
||||
</select>
|
||||
|
||||
<select id="selectNewsCategoryByCategoryId" parameterType="Long" resultMap="NewsCategoryResult">
|
||||
<include refid="selectNewsCategoryVo"/>
|
||||
where category_id = #{categoryId}
|
||||
</select>
|
||||
|
||||
<insert id="insertNewsCategory" parameterType="NewsCategory" useGeneratedKeys="true" keyProperty="categoryId">
|
||||
insert into news_category
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="categoryName != null and categoryName != ''">category_name,</if>
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateNewsCategory" parameterType="NewsCategory">
|
||||
update news_category
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where category_id = #{categoryId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteNewsCategoryByCategoryId" parameterType="Long">
|
||||
delete from news_category where category_id = #{categoryId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteNewsCategoryByCategoryIds" parameterType="String">
|
||||
delete from news_category where category_id in
|
||||
<foreach item="categoryId" collection="array" open="(" separator="," close=")">
|
||||
#{categoryId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.iot.mapper.NewsMapper">
|
||||
|
||||
<resultMap type="News" id="NewsResult">
|
||||
<result property="newsId" column="news_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="content" column="content" />
|
||||
<result property="imgUrl" column="img_url" />
|
||||
<result property="isTop" column="is_top" />
|
||||
<result property="isBanner" column="is_banner" />
|
||||
<result property="categoryId" column="category_id" />
|
||||
<result property="categoryName" column="category_name" />
|
||||
<result property="status" column="status" />
|
||||
<result property="author" column="author" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectNewsVo">
|
||||
select news_id, title, content, img_url, is_top, is_banner, category_id, category_name, status, author, del_flag, create_by, create_time, update_by, update_time, remark from news
|
||||
</sql>
|
||||
|
||||
<select id="selectNewsList" parameterType="News" resultMap="NewsResult">
|
||||
<include refid="selectNewsVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''"> and title = #{title}</if>
|
||||
<if test="isTop != null "> and is_top = #{isTop}</if>
|
||||
<if test="isBanner != null "> and is_banner = #{isBanner}</if>
|
||||
<if test="categoryName != null and categoryName != ''"> and catgory_name like concat('%', #{categoryName}, '%')</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectNewsByNewsId" parameterType="Long" resultMap="NewsResult">
|
||||
<include refid="selectNewsVo"/>
|
||||
where news_id = #{newsId}
|
||||
</select>
|
||||
|
||||
<insert id="insertNews" parameterType="News" useGeneratedKeys="true" keyProperty="newsId">
|
||||
insert into news
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null and title != ''">title,</if>
|
||||
<if test="content != null and content != ''">content,</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">img_url,</if>
|
||||
<if test="isTop != null">is_top,</if>
|
||||
<if test="isBanner != null">is_banner,</if>
|
||||
<if test="categoryId != null">category_id,</if>
|
||||
<if test="categoryName != null and categoryName != ''">category_name,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="author != null and author != ''">author,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="title != null and title != ''">#{title},</if>
|
||||
<if test="content != null and content != ''">#{content},</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
|
||||
<if test="isTop != null">#{isTop},</if>
|
||||
<if test="isBanner != null">#{isBanner},</if>
|
||||
<if test="categoryId != null">#{categoryId},</if>
|
||||
<if test="categoryName != null and categoryName != ''">#{categoryName},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="author != null and author != ''">#{author},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateNews" parameterType="News">
|
||||
update news
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="title != null and title != ''">title = #{title},</if>
|
||||
<if test="content != null and content != ''">content = #{content},</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
|
||||
<if test="isTop != null">is_top = #{isTop},</if>
|
||||
<if test="isBanner != null">is_banner = #{isBanner},</if>
|
||||
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="author != null and author != ''">author = #{author},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where news_id = #{newsId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteNewsByNewsId" parameterType="Long">
|
||||
delete from news where news_id = #{newsId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteNewsByNewsIds" parameterType="String">
|
||||
delete from news where news_id in
|
||||
<foreach item="newsId" collection="array" open="(" separator="," close=")">
|
||||
#{newsId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user