新增新闻模块(新闻分类和新闻资讯),采取多对一的模式,前端富文本新增三个依赖(支持图片拖放与缩放)

This commit is contained in:
sxh
2022-04-09 14:59:05 +08:00
parent e6d67faaf9
commit af30a8d2cd
32 changed files with 3086 additions and 34 deletions

View File

@@ -204,6 +204,12 @@
<groupId>com.wumei</groupId>
<artifactId>wumei-iot</artifactId>
<version>${wumei.version}</version>
</dependency>
<!-- 新闻模块-->
<dependency>
<groupId>com.wumei</groupId>
<artifactId>wumei-news</artifactId>
<version>${wumei.version}</version>
</dependency>
</dependencies>
@@ -217,6 +223,7 @@
<module>wumei-generator</module>
<module>wumei-common</module>
<module>wumei-iot</module>
<module>wumei-news</module>
</modules>
<packaging>pom</packaging>

View File

@@ -65,6 +65,11 @@
<dependency>
<groupId>com.wumei</groupId>
<artifactId>wumei-iot</artifactId>
</dependency>
<!-- 新闻模块-->
<dependency>
<groupId>com.wumei</groupId>
<artifactId>wumei-news</artifactId>
</dependency>
</dependencies>

View File

@@ -8,14 +8,14 @@ spring:
master:
url: jdbc:mysql://localhost/wumei-smart?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: wumei-smart
password: root
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
@@ -35,7 +35,7 @@ spring:
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
webStatFilter:
enabled: true
statViewServlet:
enabled: true

View File

@@ -9,7 +9,7 @@ ruoyi:
# 实例演示开关
demoEnabled: true
# 文件路径 示例( Windows配置D:/wumei-smart/uploadPathLinux配置 /var/wumei-smart/java/uploadPath
profile: /var/wumei-smart/java/uploadPath
profile: D:/wumei-smart/uploadPath
# 获取ip地址开关
addressEnabled: true
# 验证码类型 math 数组计算 char 字符验证
@@ -42,15 +42,15 @@ spring:
messages:
# 国际化资源文件路径
basename: i18n/messages
profiles:
profiles:
active: druid
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
multipart:
# 单个文件大小
max-file-size: 10MB
# 设置总上传的文件大小
max-request-size: 20MB
# 服务模块
devtools:
restart:
@@ -63,9 +63,9 @@ spring:
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
database: 3
# 密码
password: wumei-smart
#password: wumei-smart
# 连接超时时间
timeout: 10s
lettuce:
@@ -94,30 +94,30 @@ spring:
core-size: 10 # 最小连接数
max-size: 30 # 最大连接数
queue-capacity: 3000 # 最大容量
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklwumeismartrstuvwxyz
# 令牌有效期默认30分钟1440为一天
expireTime: 1440
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklwumeismartrstuvwxyz
# 令牌有效期默认30分钟1440为一天
expireTime: 1440
# MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
# PageHelper分页插件
pagehelper:
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
params: count=countSql
# Swagger配置
swagger:
@@ -127,7 +127,7 @@ swagger:
pathMapping: /dev-api
# 防止XSS攻击
xss:
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)

View File

@@ -4,12 +4,13 @@ import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.domain.entity.NewsClassify;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysMenu;
/**
* Treeselect树结构实体类
*
*
* @author ruoyi
*/
public class TreeSelect implements Serializable
@@ -26,9 +27,11 @@ public class TreeSelect implements Serializable
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
public TreeSelect()
public TreeSelect(NewsClassify classify)
{
this.id = classify.getClassifyId();
this.label = classify.getClassifyName();
// this.children = classify.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public TreeSelect(SysDept dept)

View File

@@ -0,0 +1,83 @@
package com.ruoyi.common.core.domain.entity;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 新闻分类对象 news_classify
*
* @author kerwincui
* @date 2022-04-07
*/
public class NewsClassify extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 分类ID */
private Long classifyId;
/** 分类名字 */
@Excel(name = "分类名字")
private String classifyName;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/** 分类状态0正常 1停用 */
@Excel(name = "分类状态", readConverterExp = "0=正常,1=停用")
private String status;
public void setClassifyId(Long classifyId)
{
this.classifyId = classifyId;
}
public Long getClassifyId()
{
return classifyId;
}
public void setClassifyName(String classifyName)
{
this.classifyName = classifyName;
}
public String getClassifyName()
{
return classifyName;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("classifyId", getClassifyId())
.append("classifyName", getClassifyName())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("status", getStatus())
.toString();
}
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>wumei</artifactId>
<groupId>com.wumei</groupId>
<version>3.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>wumei-news</artifactId>
<description>
新闻模块
</description>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.wumei</groupId>
<artifactId>wumei-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,131 @@
package com.ruoyi.news.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.NewsClassify;
import com.ruoyi.news.service.INewsClassifyService;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 新闻分类Controller
*
* @author kerwincui
* @date 2022-04-07
*/
@RestController
@RequestMapping("/news/classify")
public class NewsClassifyController extends BaseController
{
@Autowired
private INewsClassifyService newsClassifyService;
/**
* 查询新闻分类列表
*/
@PreAuthorize("@ss.hasPermi('news:classify:list')")
@GetMapping("/list")
public TableDataInfo list(NewsClassify newsClassify)
{
startPage();
List<NewsClassify> list = newsClassifyService.selectNewsClassifyList(newsClassify);
return getDataTable(list);
}
/**
* 导出新闻分类列表
*/
@PreAuthorize("@ss.hasPermi('news:classify:export')")
@Log(title = "新闻分类", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, NewsClassify newsClassify)
{
List<NewsClassify> list = newsClassifyService.selectNewsClassifyList(newsClassify);
ExcelUtil<NewsClassify> util = new ExcelUtil<NewsClassify>(NewsClassify.class);
util.exportExcel(response, list, "新闻分类数据");
}
/**
* 获取新闻分类详细信息
*/
@PreAuthorize("@ss.hasPermi('news:classify:query')")
@GetMapping(value = "/{classifyId}")
public AjaxResult getInfo(@PathVariable("classifyId") Long classifyId)
{
return AjaxResult.success(newsClassifyService.selectNewsClassifyByClassifyId(classifyId));
}
/**
* 新增新闻分类
*/
@PreAuthorize("@ss.hasPermi('news:classify:add')")
@Log(title = "新闻分类", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody NewsClassify newsClassify)
{
return toAjax(newsClassifyService.insertNewsClassify(newsClassify));
}
/**
* 修改新闻分类
*/
@PreAuthorize("@ss.hasPermi('news:classify:edit')")
@Log(title = "新闻分类", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody NewsClassify newsClassify)
{
return toAjax(newsClassifyService.updateNewsClassify(newsClassify));
}
/**
* 删除新闻分类
*/
@PreAuthorize("@ss.hasPermi('news:classify:remove')")
@Log(title = "新闻分类", businessType = BusinessType.DELETE)
@DeleteMapping("/{classifyIds}")
public AjaxResult remove(@PathVariable Long[] classifyIds)
{
return AjaxResult.success(newsClassifyService.deleteNewsClassifyByClassifyIds(classifyIds));
}
/**
* 获取分类下拉树列表
*/
@GetMapping("/treeselect")
public AjaxResult treeselect( NewsClassify newsClassify)
{
List<NewsClassify> newsClassifies = newsClassifyService.selectClassifyList(newsClassify);
return AjaxResult.success(newsClassifyService.buildClassifyTreeSelect(newsClassifies));
}
/**
* 加载对应新闻分类列表树
*/
@GetMapping(value = "/newsClassifyTreeselect/{newsId}")
public AjaxResult newsClassifyTreeselect(@PathVariable("newsId") Long newsId)
{
NewsClassify newsClassify = new NewsClassify();
List<NewsClassify> classifies = newsClassifyService.selectClassifyList(newsClassify);
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", newsClassifyService.selectClassifyListByNewsId(newsId));
ajax.put("menus", newsClassifyService.buildClassifyTreeSelect(classifies));
return ajax;
}
}

View File

@@ -0,0 +1,105 @@
package com.ruoyi.news.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.news.domain.News;
import com.ruoyi.news.service.INewsService;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 新闻Controller
*
* @author kerwincui
* @date 2022-04-07
*/
@RestController
@RequestMapping("/news/news")
public class NewsController extends BaseController
{
@Autowired
private INewsService newsService;
/**
* 查询新闻列表
*/
@PreAuthorize("@ss.hasPermi('news:consult:list')")
@GetMapping("/list")
public TableDataInfo list(News news)
{
startPage();
List<News> list = newsService.selectNewsList(news);
return getDataTable(list);
}
/**
* 导出新闻列表
*/
@PreAuthorize("@ss.hasPermi('news:consult: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('news:consult:query')")
@GetMapping(value = "/{newsId}")
public AjaxResult getInfo(@PathVariable("newsId") Long newsId)
{
return AjaxResult.success(newsService.selectNewsByNewsId(newsId));
}
/**
* 新增新闻
*/
@PreAuthorize("@ss.hasPermi('news:consult:add')")
@Log(title = "新闻", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody News news)
{
return toAjax(newsService.insertNews(news));
}
/**
* 修改新闻
*/
@PreAuthorize("@ss.hasPermi('news:consult:edit')")
@Log(title = "新闻", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody News news)
{
return toAjax(newsService.updateNews(news));
}
/**
* 删除新闻
*/
@PreAuthorize("@ss.hasPermi('news:consult:remove')")
@Log(title = "新闻", businessType = BusinessType.DELETE)
@DeleteMapping("/{newsIds}")
public AjaxResult remove(@PathVariable Long[] newsIds)
{
return toAjax(newsService.deleteNewsByNewsIds(newsIds));
}
}

View File

@@ -0,0 +1,181 @@
package com.ruoyi.news.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;
import java.util.List;
/**
* 新闻对象 news
*
* @author kerwincui
* @date 2022-04-07
*/
public class News extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 新闻ID */
private Long newsId;
/** 新闻标题 */
@Excel(name = "新闻标题")
private String newsName;
/** 新闻内容 */
@Excel(name = "新闻内容")
private String newsContent;
/** 新闻封面 */
@Excel(name = "新闻封面")
private String newsCover;
/** 是否置顶 */
@Excel(name = "是否置顶")
private String newsIsTop;
/** 是否banner */
@Excel(name = "是否banner")
private String newsIsBanner;
/** 分类ID */
@Excel(name = "分类ID")
private List<Long> classifyId;
/** 分类ID */
@Excel(name = "分类ID")
private Long classifyIds;
/** 分类名称 */
@Excel(name = "分类名称")
private String classifyName;
/** 新闻状态0正常 1停用 */
@Excel(name = "新闻状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
public void setNewsId(Long newsId)
{
this.newsId = newsId;
}
public Long getNewsId()
{
return newsId;
}
public void setNewsName(String newsName)
{
this.newsName = newsName;
}
public String getNewsName()
{
return newsName;
}
public void setNewsContent(String newsContent)
{
this.newsContent = newsContent;
}
public String getNewsContent()
{
return newsContent;
}
public void setNewsCover(String newsCover)
{
this.newsCover = newsCover;
}
public String getNewsCover()
{
return newsCover;
}
public void setNewsIsTop(String newsIsTop)
{
this.newsIsTop = newsIsTop;
}
public String getNewsIsTop()
{
return newsIsTop;
}
public void setNewsIsBanner(String newsIsBanner)
{
this.newsIsBanner = newsIsBanner;
}
public String getNewsIsBanner()
{
return newsIsBanner;
}
public List<Long> getClassifyId() {
return classifyId;
}
public Long getClassifyIds() {
return classifyIds;
}
public void setClassifyIds(Long classifyIds) {
this.classifyIds = classifyIds;
}
public void setClassifyId(List<Long> classifyId) {
this.classifyId = classifyId;
}
public void setClassifyName(String classifyName)
{
this.classifyName = classifyName;
}
public String getClassifyName()
{
return classifyName;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
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("newsName", getNewsName())
.append("newsContent", getNewsContent())
.append("newsCover", getNewsCover())
.append("newsIsTop", getNewsIsTop())
.append("newsIsBanner", getNewsIsBanner())
.append("classifyId", getClassifyId())
.append("classifyName", getClassifyName())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@@ -0,0 +1,52 @@
package com.ruoyi.news.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_and_classify
*
* @author kerwincui
* @date 2022-04-08
*/
public class NewsAndClassify extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 新闻ID */
@Excel(name = "新闻ID")
private Long newId;
/** 分类ID */
@Excel(name = "分类ID")
private Long classifyId;
public void setNewId(Long newId)
{
this.newId = newId;
}
public Long getNewId()
{
return newId;
}
public void setClassifyId(Long classifyId)
{
this.classifyId = classifyId;
}
public Long getClassifyId()
{
return classifyId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("newId", getNewId())
.append("classifyId", getClassifyId())
.toString();
}
}

View File

@@ -0,0 +1,82 @@
package com.ruoyi.news.mapper;
import com.ruoyi.news.domain.NewsAndClassify;
import java.util.List;
/**
* 新闻分类Mapper接口
*
* @author kerwincui
* @date 2022-04-08
*/
public interface NewsAndClassifyMapper
{
/**
* 查询新闻分类
*
* @param newId 新闻分类主键
* @return 新闻分类
*/
public NewsAndClassify selectNewsAndClassifyByNewId(Long newId);
/**
* 查询新闻分类
*
* @param newId 新闻分类主键
* @return 新闻分类
*/
public List<NewsAndClassify> selectNewsAndClassifysByNewId(Long newId);
/**
* 查询新闻分类
*
* @param classifyId 分类主键
* @return 新闻分类
*/
public NewsAndClassify selectNewsAndClassifyByClassifyId(Long classifyId);
/**
* 查询新闻分类列表
*
* @param newsAndClassify 新闻分类
* @return 新闻分类集合
*/
public List<NewsAndClassify> selectNewsAndClassifyList(NewsAndClassify newsAndClassify);
/**
* 新增新闻分类
*
* @param newsAndClassify 新闻分类
* @return 结果
*/
public int insertNewsAndClassify(NewsAndClassify newsAndClassify);
/**
* 修改新闻分类
*
* @param newsAndClassify 新闻分类
* @return 结果
*/
public int updateNewsAndClassify(NewsAndClassify newsAndClassify);
/**
* 删除新闻分类
*
* @param newId 新闻分类主键
* @return 结果
*/
public int deleteNewsAndClassifyByNewId(Long newId);
/**
* 批量删除新闻分类
*
* @param newIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteNewsAndClassifyByNewIds(Long[] newIds);
}

View File

@@ -0,0 +1,64 @@
package com.ruoyi.news.mapper;
import com.ruoyi.common.core.domain.entity.NewsClassify;
import java.util.List;
/**
* 新闻分类Mapper接口
*
* @author kerwincui
* @date 2022-04-07
*/
public interface NewsClassifyMapper
{
/**
* 查询新闻分类
*
* @param classifyId 新闻分类主键
* @return 新闻分类
*/
public NewsClassify selectNewsClassifyByClassifyId(Long classifyId);
/**
* 查询新闻分类列表
*
* @param newsClassify 新闻分类
* @return 新闻分类集合
*/
public List<NewsClassify> selectNewsClassifyList(NewsClassify newsClassify);
/**
* 新增新闻分类
*
* @param newsClassify 新闻分类
* @return 结果
*/
public int insertNewsClassify(NewsClassify newsClassify);
/**
* 修改新闻分类
*
* @param newsClassify 新闻分类
* @return 结果
*/
public int updateNewsClassify(NewsClassify newsClassify);
/**
* 删除新闻分类
*
* @param classifyId 新闻分类主键
* @return 结果
*/
public int deleteNewsClassifyByClassifyId(Long classifyId);
/**
* 批量删除新闻分类
*
* @param classifyIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteNewsClassifyByClassifyIds(Long[] classifyIds);
}

View File

@@ -0,0 +1,71 @@
package com.ruoyi.news.mapper;
import com.ruoyi.news.domain.News;
import java.util.List;
/**
* 新闻Mapper接口
*
* @author kerwincui
* @date 2022-04-07
*/
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);
/**
* 关联分类和新闻
*
* @param newsIds 需要删除的数据主键集合
* @return 结果
*/
}

View File

@@ -0,0 +1,70 @@
package com.ruoyi.news.service;
import java.util.List;
import com.ruoyi.news.domain.NewsAndClassify;
/**
* 新闻分类Service接口
*
* @author kerwincui
* @date 2022-04-08
*/
public interface INewsAndClassifyService
{
/**
* 查询新闻分类
*
* @param newId 新闻分类主键
* @return 新闻分类
*/
public NewsAndClassify selectNewsAndClassifyByNewId(Long newId);
/**
* 查询新闻分类
*
* @param classifyId 分类主键
* @return 新闻分类
*/
public NewsAndClassify selectNewsAndClassifyByClassifyId(Long classifyId);
/**
* 查询新闻分类列表
*
* @param newsAndClassify 新闻分类
* @return 新闻分类集合
*/
public List<NewsAndClassify> selectNewsAndClassifyList(NewsAndClassify newsAndClassify);
/**
* 新增新闻分类
*
* @param newsAndClassify 新闻分类
* @return 结果
*/
public int insertNewsAndClassify(NewsAndClassify newsAndClassify);
/**
* 修改新闻分类
*
* @param newsAndClassify 新闻分类
* @return 结果
*/
public int updateNewsAndClassify(NewsAndClassify newsAndClassify);
/**
* 批量删除新闻分类
*
* @param newIds 需要删除的新闻分类主键集合
* @return 结果
*/
public int deleteNewsAndClassifyByNewIds(Long[] newIds);
/**
* 删除新闻分类信息
*
* @param newId 新闻分类主键
* @return 结果
*/
public int deleteNewsAndClassifyByNewId(Long newId);
}

View File

@@ -0,0 +1,103 @@
package com.ruoyi.news.service;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.NewsClassify;
import java.util.List;
/**
* 新闻分类Service接口
*
* @author kerwincui
* @date 2022-04-07
*/
public interface INewsClassifyService
{
/**
* 查询新闻分类
*
* @param classifyId 新闻分类主键
* @return 新闻分类
*/
public NewsClassify selectNewsClassifyByClassifyId(Long classifyId);
/**
* 查询新闻分类列表
*
* @param newsClassify 新闻分类
* @return 新闻分类集合
*/
public List<NewsClassify> selectNewsClassifyList(NewsClassify newsClassify);
/**
* 新增新闻分类
*
* @param newsClassify 新闻分类
* @return 结果
*/
public int insertNewsClassify(NewsClassify newsClassify);
/**
* 修改新闻分类
*
* @param newsClassify 新闻分类
* @return 结果
*/
public int updateNewsClassify(NewsClassify newsClassify);
/**
* 批量删除新闻分类
*
* @param classifyIds 需要删除的新闻分类主键集合
* @return 结果
*/
public String deleteNewsClassifyByClassifyIds(Long[] classifyIds);
/**
* 删除新闻分类信息
*
* @param classifyId 新闻分类主键
* @return 结果
*/
public int deleteNewsClassifyByClassifyId(Long classifyId);
/**
* 查询分类列表
*
* @param newsClassify 分类信息
* @return 分类列表
*/
public List<NewsClassify> selectClassifyList(NewsClassify newsClassify);
/**
* 构建前端所需要下拉树结构
*
* @param newsClassify 分类列表
* @return 下拉树结构列表
*/
public List<TreeSelect> buildClassifyTreeSelect(List<NewsClassify> newsClassify);
/**
* 构建前端所需要树结构
*
* @param menus 分类列表
* @return 树结构列表
*/
public List<NewsClassify> buildClassifyTree(List<NewsClassify> menus);
/**
* 根据新闻ID查询分类树信息
*
* @param newsId 角色ID
* @return 选中分类列表
*/
public List<Integer> selectClassifyListByNewsId(Long newsId);
}

View File

@@ -0,0 +1,62 @@
package com.ruoyi.news.service;
import com.ruoyi.news.domain.News;
import java.util.List;
/**
* 新闻Service接口
*
* @author kerwincui
* @date 2022-04-07
*/
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);
}

View File

@@ -0,0 +1,106 @@
package com.ruoyi.news.service.impl;
import java.util.List;
import com.ruoyi.news.domain.NewsAndClassify;
import com.ruoyi.news.mapper.NewsAndClassifyMapper;
import com.ruoyi.news.service.INewsAndClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 新闻分类Service业务层处理
*
* @author kerwincui
* @date 2022-04-08
*/
@Service
public class NewsAndClassifyServiceImpl implements INewsAndClassifyService
{
@Autowired
private NewsAndClassifyMapper newsAndClassifyMapper;
/**
* 查询新闻分类
*
* @param newId 新闻分类主键
* @return 新闻分类
*/
@Override
public NewsAndClassify selectNewsAndClassifyByNewId(Long newId)
{
return newsAndClassifyMapper.selectNewsAndClassifyByNewId(newId);
}
/**
* 查询新闻分类
*
* @param classifyId 分类主键
* @return 新闻分类
*/
@Override
public NewsAndClassify selectNewsAndClassifyByClassifyId(Long classifyId) {
return null;
}
/**
* 查询新闻分类列表
*
* @param newsAndClassify 新闻分类
* @return 新闻分类
*/
@Override
public List<NewsAndClassify> selectNewsAndClassifyList(NewsAndClassify newsAndClassify)
{
return newsAndClassifyMapper.selectNewsAndClassifyList(newsAndClassify);
}
/**
* 新增新闻分类
*
* @param newsAndClassify 新闻分类
* @return 结果
*/
@Override
public int insertNewsAndClassify(NewsAndClassify newsAndClassify)
{
return newsAndClassifyMapper.insertNewsAndClassify(newsAndClassify);
}
/**
* 修改新闻分类
*
* @param newsAndClassify 新闻分类
* @return 结果
*/
@Override
public int updateNewsAndClassify(NewsAndClassify newsAndClassify)
{
return newsAndClassifyMapper.updateNewsAndClassify(newsAndClassify);
}
/**
* 批量删除新闻分类
*
* @param newIds 需要删除的新闻分类主键
* @return 结果
*/
@Override
public int deleteNewsAndClassifyByNewIds(Long[] newIds)
{
return newsAndClassifyMapper.deleteNewsAndClassifyByNewIds(newIds);
}
/**
* 删除新闻分类信息
*
* @param newId 新闻分类主键
* @return 结果
*/
@Override
public int deleteNewsAndClassifyByNewId(Long newId)
{
return newsAndClassifyMapper.deleteNewsAndClassifyByNewId(newId);
}
}

View File

@@ -0,0 +1,195 @@
package com.ruoyi.news.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.NewsClassify;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.news.domain.NewsAndClassify;
import com.ruoyi.news.mapper.NewsAndClassifyMapper;
import com.ruoyi.news.mapper.NewsClassifyMapper;
import com.ruoyi.news.service.INewsClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 新闻分类Service业务层处理
*
* @author kerwincui
* @date 2022-04-07
*/
@Service
public class NewsClassifyServiceImpl implements INewsClassifyService
{
@Autowired
private NewsClassifyMapper newsClassifyMapper;
@Autowired
private NewsAndClassifyMapper newsAndClassifyMapper;
/**
* 查询新闻分类
*
* @param classifyId 新闻分类主键
* @return 新闻分类
*/
@Override
public NewsClassify selectNewsClassifyByClassifyId(Long classifyId)
{
return newsClassifyMapper.selectNewsClassifyByClassifyId(classifyId);
}
/**
* 查询新闻分类列表
*
* @param newsClassify 新闻分类
* @return 新闻分类
*/
@Override
public List<NewsClassify> selectNewsClassifyList(NewsClassify newsClassify)
{
return newsClassifyMapper.selectNewsClassifyList(newsClassify);
}
/**
* 新增新闻分类
*
* @param newsClassify 新闻分类
* @return 结果
*/
@Override
public int insertNewsClassify(NewsClassify newsClassify)
{
newsClassify.setCreateTime(DateUtils.getNowDate());
return newsClassifyMapper.insertNewsClassify(newsClassify);
}
/**
* 修改新闻分类
*
* @param newsClassify 新闻分类
* @return 结果
*/
@Override
public int updateNewsClassify(NewsClassify newsClassify)
{
newsClassify.setUpdateTime(DateUtils.getNowDate());
return newsClassifyMapper.updateNewsClassify(newsClassify);
}
/**
* 批量删除新闻分类
*
* @param classifyIds 需要删除的新闻分类主键
* @return 结果
*/
@Override
public String deleteNewsClassifyByClassifyIds(Long[] classifyIds)
{
List<String> jsonObjectList = new ArrayList<>();
for (int i = 0; i < classifyIds.length; i++) {
NewsAndClassify newsAndClassify = newsAndClassifyMapper.selectNewsAndClassifyByClassifyId(classifyIds[i]);
if(newsAndClassify != null){
jsonObjectList.add("分类主键ID"+classifyIds[i]+" 存在新闻,请先删除新闻");
}else{
int count = newsClassifyMapper.deleteNewsClassifyByClassifyIds(classifyIds);
if(count > 1){
jsonObjectList.add("分类主键ID"+classifyIds[i]+" 删除成功");
}else{
jsonObjectList.add("分类主键ID"+classifyIds[i]+"删除失败");
}
}
}
return String.join(";",jsonObjectList);
}
/**
* 删除新闻分类信息
*
* @param classifyId 新闻分类主键
* @return 结果
*/
@Override
public int deleteNewsClassifyByClassifyId(Long classifyId)
{
return newsClassifyMapper.deleteNewsClassifyByClassifyId(classifyId);
}
/**
* 查询分类列表
*
* @param newsClassify 分类信息
* @return 分类列表
*/
@Override
public List<NewsClassify> selectClassifyList(NewsClassify newsClassify) {
return newsClassifyMapper.selectNewsClassifyList(newsClassify);
}
/**
* 构建前端所需要下拉树结构
*
* @param newsClassify 分类列表
* @return 下拉树结构列表
*/
@Override
public List<TreeSelect> buildClassifyTreeSelect(List<NewsClassify> newsClassify)
{
List<NewsClassify> menuTrees = buildClassifyTree(newsClassify);
return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
}
/**
* 构建前端所需要树结构
*
* @param newsClassify 分类列表
* @return 树结构列表
*/
@Override
public List<NewsClassify> buildClassifyTree(List<NewsClassify> newsClassify)
{
List<NewsClassify> returnList = new ArrayList<NewsClassify>();
for (Iterator<NewsClassify> iterator = newsClassify.iterator(); iterator.hasNext();)
{
NewsClassify classify = (NewsClassify) iterator.next();
// 如果是顶级节点, 遍历该父节点的所有子节点
returnList.add(classify);
}
if (returnList.isEmpty())
{
returnList = newsClassify;
}
return returnList;
}
/**
* 根据新闻ID查询分类树信息
*
* @param newsId 角色ID
* @return 选中分类列表
*/
@Override
public List<Integer> selectClassifyListByNewsId(Long newsId)
{
NewsAndClassify newsAndClassify = new NewsAndClassify();
newsAndClassify.setNewId(newsId);
List<Integer> classifyList = new ArrayList<>();
for (NewsAndClassify andClassify : newsAndClassifyMapper.selectNewsAndClassifyList(newsAndClassify)) {
classifyList.add(Math.toIntExact(andClassify.getClassifyId()));
}
return classifyList;
}
}

View File

@@ -0,0 +1,132 @@
package com.ruoyi.news.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.news.domain.News;
import com.ruoyi.news.domain.NewsAndClassify;
import com.ruoyi.news.mapper.NewsAndClassifyMapper;
import com.ruoyi.news.mapper.NewsMapper;
import com.ruoyi.news.service.INewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 新闻Service业务层处理
*
* @author kerwincui
* @date 2022-04-07
*/
@Service
public class NewsServiceImpl implements INewsService
{
@Autowired
private NewsMapper newsMapper;
@Autowired
private NewsAndClassifyMapper classifyMapper;
/**
* 查询新闻
*
* @param newsId 新闻主键
* @return 新闻
*/
@Override
public News selectNewsByNewsId(Long newsId)
{
return newsMapper.selectNewsByNewsId(newsId);
}
/**
* 查询新闻列表
*
* @param news 新闻
* @return 新闻
*/
@Override
public List<News> selectNewsList(News news)
{
if (news.getClassifyId() != null && news.getClassifyId().size() == 1 ){
Long classifyIds =news.getClassifyId().get(0);
news.setClassifyIds(classifyIds);
}
return newsMapper.selectNewsList(news);
}
/**
* 新增新闻
*
* @param news 新闻
* @return 结果
*/
@Override
public int insertNews(News news)
{
int i = newsMapper.insertNews(news);
//循环添加关联表
for (Long classifyId : news.getClassifyId()) {
NewsAndClassify newsAndClassify = new NewsAndClassify();
newsAndClassify.setNewId(news.getNewsId());
newsAndClassify.setClassifyId(classifyId);
classifyMapper.insertNewsAndClassify(newsAndClassify);
}
return i;
}
/**
* 修改新闻
*
* @param news 新闻
* @return 结果
*/
@Override
public int updateNews(News news)
{
int i = newsMapper.updateNews(news);
//清空绑定分类数据
classifyMapper.deleteNewsAndClassifyByNewId(news.getNewsId());
//循环添加关联表
if(news.getClassifyId() != null && news.getClassifyId().size() > 0){
for (Long classifyId : news.getClassifyId()) {
NewsAndClassify newsAndClassify = new NewsAndClassify();
newsAndClassify.setNewId(news.getNewsId());
newsAndClassify.setClassifyId(classifyId);
classifyMapper.insertNewsAndClassify(newsAndClassify);
}
}
return i;
}
/**
* 批量删除新闻
*
* @param newsIds 需要删除的新闻主键
* @return 结果
*/
@Override
public int deleteNewsByNewsIds(Long[] newsIds)
{
//循环删除绑定的新闻分类
for (int i = 0; i < newsIds.length ; i++) {
classifyMapper.deleteNewsAndClassifyByNewId(newsIds[i]);
}
return newsMapper.deleteNewsByNewsIds(newsIds);
}
/**
* 删除新闻信息
*
* @param newsId 新闻主键
* @return 结果
*/
@Override
public int deleteNewsByNewsId(Long newsId)
{
return newsMapper.deleteNewsByNewsId(newsId);
}
}

View File

@@ -0,0 +1,68 @@
<?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.news.mapper.NewsAndClassifyMapper">
<resultMap type="NewsAndClassify" id="NewsAndClassifyResult">
<result property="newId" column="new_id" />
<result property="classifyId" column="classify_id" />
</resultMap>
<sql id="selectNewsAndClassifyVo">
select new_id, classify_id from news_and_classify
</sql>
<select id="selectNewsAndClassifyList" parameterType="NewsAndClassify" resultMap="NewsAndClassifyResult">
<include refid="selectNewsAndClassifyVo"/>
<where>
<if test="newId != null "> and new_id = #{newId}</if>
<if test="classifyId != null "> and classify_id = #{classifyId}</if>
</where>
</select>
<select id="selectNewsAndClassifysByNewId" parameterType="Long" resultMap="NewsAndClassifyResult">
<include refid="selectNewsAndClassifyVo"/>
where new_id = #{newId}
</select>
<select id="selectNewsAndClassifyByNewId" parameterType="Long" resultMap="NewsAndClassifyResult">
<include refid="selectNewsAndClassifyVo"/>
where new_id = #{newId}
</select>
<select id="selectNewsAndClassifyByClassifyId" parameterType="Long" resultMap="NewsAndClassifyResult">
<include refid="selectNewsAndClassifyVo"/>
where classify_id = #{classifyId}
</select>
<insert id="insertNewsAndClassify" parameterType="NewsAndClassify">
insert into news_and_classify
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="newId != null">new_id,</if>
<if test="classifyId != null">classify_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="newId != null">#{newId},</if>
<if test="classifyId != null">#{classifyId},</if>
</trim>
</insert>
<update id="updateNewsAndClassify" parameterType="NewsAndClassify">
update news_and_classify
<trim prefix="SET" suffixOverrides=",">
<if test="classifyId != null">classify_id = #{classifyId},</if>
</trim>
where new_id = #{newId}
</update>
<delete id="deleteNewsAndClassifyByNewId" parameterType="Long">
delete from news_and_classify where new_id = #{newId}
</delete>
<delete id="deleteNewsAndClassifyByNewIds" parameterType="String">
delete from news_and_classify where new_id in
<foreach item="newId" collection="array" open="(" separator="," close=")">
#{newId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,86 @@
<?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.news.mapper.NewsClassifyMapper">
<resultMap type="NewsClassify" id="NewsClassifyResult">
<result property="classifyId" column="classify_id" />
<result property="classifyName" column="classify_name" />
<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" />
<result property="status" column="status" />
</resultMap>
<sql id="selectNewsClassifyVo">
select classify_id, classify_name, del_flag, create_by, create_time, update_by, update_time, remark, status from news_classify
</sql>
<select id="selectNewsClassifyList" parameterType="NewsClassify" resultMap="NewsClassifyResult">
<include refid="selectNewsClassifyVo"/>
<where>
<if test="classifyName != null and classifyName != ''"> and classify_name like concat('%', #{classifyName}, '%')</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
</select>
<select id="selectNewsClassifyByClassifyId" parameterType="Long" resultMap="NewsClassifyResult">
<include refid="selectNewsClassifyVo"/>
where classify_id = #{classifyId}
</select>
<insert id="insertNewsClassify" parameterType="NewsClassify" useGeneratedKeys="true" keyProperty="classifyId">
insert into news_classify
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="classifyName != null and classifyName != ''">classify_name,</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>
<if test="status != null">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="classifyName != null and classifyName != ''">#{classifyName},</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>
<if test="status != null">#{status},</if>
</trim>
</insert>
<update id="updateNewsClassify" parameterType="NewsClassify">
update news_classify
<trim prefix="SET" suffixOverrides=",">
<if test="classifyName != null and classifyName != ''">classify_name = #{classifyName},</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>
<if test="status != null">status = #{status},</if>
</trim>
where classify_id = #{classifyId}
</update>
<delete id="deleteNewsClassifyByClassifyId" parameterType="Long">
# delete from news_classify where classify_id = #{classifyId}
update news_classify set del_flag = '2' where classify_id = #{classifyId}
</delete>
<delete id="deleteNewsClassifyByClassifyIds" parameterType="String">
delete from news_classify where classify_id in
<foreach item="classifyId" collection="array" open="(" separator="," close=")">
#{classifyId}
</foreach>
</delete>
</mapper>

View File

@@ -0,0 +1,122 @@
<?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.news.mapper.NewsMapper">
<resultMap type="News" id="NewsResult">
<result property="newsId" column="news_id" />
<result property="newsName" column="news_name" />
<result property="newsContent" column="news_content" />
<result property="newsCover" column="news_cover" />
<result property="newsIsTop" column="news_is_top" />
<result property="newsIsBanner" column="news_is_banner" />
<!-- <result property="classifyId" column="classify_id" />-->
<!-- <result property="classifyName" column="classify_name" />-->
<result property="status" column="status" />
<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 nw.news_id, nw.news_name, nw.news_content, nw.news_cover, nw.news_is_top, nw.news_is_banner, nw.status, nw.del_flag,
nw.create_by, nw.create_time, nw.update_by, nw.update_time, nw.remark from news nw
left join news_and_classify nac on nw.news_id = nac.new_id
</sql>
<sql id="selectNewsVoInfo">
select news_id, news_name, news_content, news_cover, news_is_top, news_is_banner, status, 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="newsName != null and newsName != ''"> and nw.news_name like concat('%', #{newsName}, '%')</if>
<if test="newsContent != null and newsContent != ''"> and nw.news_content = #{newsContent}</if>
<if test="newsCover != null and newsCover != ''"> and nw.news_cover = #{newsCover}</if>
<if test="newsIsTop != null and newsIsTop != ''"> and nw.news_is_top = #{newsIsTop}</if>
<if test="newsIsBanner != null and newsIsBanner != ''"> and nw.news_is_banner = #{newsIsBanner}</if>
<if test="classifyIds != null "> and nac.classify_id = #{classifyIds}</if>
<!-- <if test="classifyName != null and classifyName != ''"> and classify_name like concat('%', #{classifyName}, '%')</if>-->
<if test="status != null and status != ''"> and nw.status = #{status}</if>
</where>
</select>
<select id="selectNewsByNewsId" parameterType="Long" resultMap="NewsResult">
<include refid="selectNewsVoInfo"/>
where news_id = #{newsId}
</select>
<insert id="insertNews" parameterType="News" useGeneratedKeys="true" keyProperty="newsId">
insert into news
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="newsName != null and newsName != ''">news_name,</if>
<if test="newsContent != null and newsContent != ''">news_content,</if>
<if test="newsCover != null and newsCover != ''">news_cover,</if>
<if test="newsIsTop != null and newsIsTop != ''">news_is_top,</if>
<if test="newsIsBanner != null and newsIsBanner != ''">news_is_banner,</if>
<!-- <if test="classifyId != null">classify_id,</if>-->
<!-- <if test="classifyName != null and classifyName != ''">classify_name,</if>-->
<if test="status != null">status,</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="newsName != null and newsName != ''">#{newsName},</if>
<if test="newsContent != null and newsContent != ''">#{newsContent},</if>
<if test="newsCover != null and newsCover != ''">#{newsCover},</if>
<if test="newsIsTop != null and newsIsTop != ''">#{newsIsTop},</if>
<if test="newsIsBanner != null and newsIsBanner != ''">#{newsIsBanner},</if>
<!-- <if test="classifyId != null">#{classifyId},</if>-->
<!-- <if test="classifyName != null and classifyName != ''">#{classifyName},</if>-->
<if test="status != null">#{status},</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="newsName != null and newsName != ''">news_name = #{newsName},</if>
<if test="newsContent != null and newsContent != ''">news_content = #{newsContent},</if>
<if test="newsCover != null and newsCover != ''">news_cover = #{newsCover},</if>
<if test="newsIsTop != null and newsIsTop != ''">news_is_top = #{newsIsTop},</if>
<if test="newsIsBanner != null and newsIsBanner != ''">news_is_banner = #{newsIsBanner},</if>
<!-- <if test="classifyId != null">classify_id = #{classifyId},</if>-->
<!-- <if test="classifyName != null and classifyName != ''">classify_name = #{classifyName},</if>-->
<if test="status != null">status = #{status},</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}
update news set del_flag = '2' 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>