From 3163364da34b30dbed8d858c3132bcf8b09f4a65 Mon Sep 17 00:00:00 2001 From: kerwincui <164770707@qq.com> Date: Thu, 14 Apr 2022 00:48:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E6=96=B0=E5=A2=9E=E6=96=B0?= =?UTF-8?q?=E9=97=BB=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NewsCategoryController.java | 126 ++++++++++++ .../ruoyi/iot/controller/NewsController.java | 113 +++++++++++ .../main/java/com/ruoyi/iot/domain/News.java | 181 ++++++++++++++++++ .../com/ruoyi/iot/domain/NewsCategory.java | 84 ++++++++ .../ruoyi/iot/mapper/NewsCategoryMapper.java | 69 +++++++ .../java/com/ruoyi/iot/mapper/NewsMapper.java | 61 ++++++ .../iot/service/INewsCategoryService.java | 69 +++++++ .../com/ruoyi/iot/service/INewsService.java | 61 ++++++ .../service/impl/NewsCategoryServiceImpl.java | 108 +++++++++++ .../iot/service/impl/NewsServiceImpl.java | 96 ++++++++++ .../mapper/iot/NewsCategoryMapper.xml | 96 ++++++++++ .../main/resources/mapper/iot/NewsMapper.xml | 117 +++++++++++ 12 files changed, 1181 insertions(+) create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/NewsCategoryController.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/NewsController.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/News.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/NewsCategory.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/NewsCategoryMapper.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/NewsMapper.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/INewsCategoryService.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/INewsService.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/NewsCategoryServiceImpl.java create mode 100644 springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/NewsServiceImpl.java create mode 100644 springboot/wumei-iot/src/main/resources/mapper/iot/NewsCategoryMapper.xml create mode 100644 springboot/wumei-iot/src/main/resources/mapper/iot/NewsMapper.xml diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/NewsCategoryController.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/NewsCategoryController.java new file mode 100644 index 00000000..065e2f93 --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/NewsCategoryController.java @@ -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 list = newsCategoryService.selectNewsCategoryList(newsCategory); + return getDataTable(list); + } + + /** + * 查询新闻分类简短列表 + */ + @PreAuthorize("@ss.hasPermi('iot:newsCategory:list')") + @GetMapping("/newsCategoryShortList") + @ApiOperation("分类简短列表") + public AjaxResult newsCategoryShortList() + { + List 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 list = newsCategoryService.selectNewsCategoryList(newsCategory); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/NewsController.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/NewsController.java new file mode 100644 index 00000000..d2cfd962 --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/NewsController.java @@ -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 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 list = newsService.selectNewsList(news); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/News.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/News.java new file mode 100644 index 00000000..a552988a --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/News.java @@ -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(); + } +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/NewsCategory.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/NewsCategory.java new file mode 100644 index 00000000..b50ff04a --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/domain/NewsCategory.java @@ -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(); + } +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/NewsCategoryMapper.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/NewsCategoryMapper.java new file mode 100644 index 00000000..16ca10fa --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/NewsCategoryMapper.java @@ -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 selectNewsCategoryList(NewsCategory newsCategory); + + /** + * 查询新闻分类简短列表 + * + * @return 新闻分类集合 + */ + public List 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); +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/NewsMapper.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/NewsMapper.java new file mode 100644 index 00000000..824faf7a --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/mapper/NewsMapper.java @@ -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 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); +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/INewsCategoryService.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/INewsCategoryService.java new file mode 100644 index 00000000..a74c6af1 --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/INewsCategoryService.java @@ -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 selectNewsCategoryList(NewsCategory newsCategory); + + /** + * 查询新闻分类简短列表 + * + * @return 新闻分类集合 + */ + public List 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); +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/INewsService.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/INewsService.java new file mode 100644 index 00000000..45b6f0fa --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/INewsService.java @@ -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 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); +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/NewsCategoryServiceImpl.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/NewsCategoryServiceImpl.java new file mode 100644 index 00000000..0b281b39 --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/NewsCategoryServiceImpl.java @@ -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 selectNewsCategoryList(NewsCategory newsCategory) + { + return newsCategoryMapper.selectNewsCategoryList(newsCategory); + } + + /** + * 查询新闻分类简短列表 + * + * @return 新闻分类 + */ + @Override + public List 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); + } +} diff --git a/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/NewsServiceImpl.java b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/NewsServiceImpl.java new file mode 100644 index 00000000..17fad709 --- /dev/null +++ b/springboot/wumei-iot/src/main/java/com/ruoyi/iot/service/impl/NewsServiceImpl.java @@ -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 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); + } +} diff --git a/springboot/wumei-iot/src/main/resources/mapper/iot/NewsCategoryMapper.xml b/springboot/wumei-iot/src/main/resources/mapper/iot/NewsCategoryMapper.xml new file mode 100644 index 00000000..f1ccb821 --- /dev/null +++ b/springboot/wumei-iot/src/main/resources/mapper/iot/NewsCategoryMapper.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + select category_id, category_name, order_num, del_flag, create_by, create_time, update_by, update_time, remark from news_category + + + + + + + + + + insert into news_category + + category_name, + order_num, + del_flag, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{categoryName}, + #{orderNum}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update news_category + + category_name = #{categoryName}, + order_num = #{orderNum}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where category_id = #{categoryId} + + + + delete from news_category where category_id = #{categoryId} + + + + delete from news_category where category_id in + + #{categoryId} + + + \ No newline at end of file diff --git a/springboot/wumei-iot/src/main/resources/mapper/iot/NewsMapper.xml b/springboot/wumei-iot/src/main/resources/mapper/iot/NewsMapper.xml new file mode 100644 index 00000000..7e82a990 --- /dev/null +++ b/springboot/wumei-iot/src/main/resources/mapper/iot/NewsMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + insert into news + + 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, + + + #{title}, + #{content}, + #{imgUrl}, + #{isTop}, + #{isBanner}, + #{categoryId}, + #{categoryName}, + #{status}, + #{author}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update news + + title = #{title}, + content = #{content}, + img_url = #{imgUrl}, + is_top = #{isTop}, + is_banner = #{isBanner}, + category_id = #{categoryId}, + category_name = #{categoryName}, + status = #{status}, + author = #{author}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where news_id = #{newsId} + + + + delete from news where news_id = #{newsId} + + + + delete from news where news_id in + + #{newsId} + + + \ No newline at end of file