mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-06 00:27:32 +08:00
新增新闻模块(新闻分类和新闻资讯),采取多对一的模式,前端富文本新增三个依赖(支持图片拖放与缩放)
This commit is contained in:
@@ -204,6 +204,12 @@
|
|||||||
<groupId>com.wumei</groupId>
|
<groupId>com.wumei</groupId>
|
||||||
<artifactId>wumei-iot</artifactId>
|
<artifactId>wumei-iot</artifactId>
|
||||||
<version>${wumei.version}</version>
|
<version>${wumei.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 新闻模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.wumei</groupId>
|
||||||
|
<artifactId>wumei-news</artifactId>
|
||||||
|
<version>${wumei.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@@ -217,6 +223,7 @@
|
|||||||
<module>wumei-generator</module>
|
<module>wumei-generator</module>
|
||||||
<module>wumei-common</module>
|
<module>wumei-common</module>
|
||||||
<module>wumei-iot</module>
|
<module>wumei-iot</module>
|
||||||
|
<module>wumei-news</module>
|
||||||
</modules>
|
</modules>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
@@ -65,6 +65,11 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.wumei</groupId>
|
<groupId>com.wumei</groupId>
|
||||||
<artifactId>wumei-iot</artifactId>
|
<artifactId>wumei-iot</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 新闻模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.wumei</groupId>
|
||||||
|
<artifactId>wumei-news</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@@ -8,7 +8,7 @@ spring:
|
|||||||
master:
|
master:
|
||||||
url: jdbc:mysql://localhost/wumei-smart?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
url: jdbc:mysql://localhost/wumei-smart?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||||
username: root
|
username: root
|
||||||
password: wumei-smart
|
password: root
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
# 从数据源开关/默认关闭
|
# 从数据源开关/默认关闭
|
||||||
|
@@ -9,7 +9,7 @@ ruoyi:
|
|||||||
# 实例演示开关
|
# 实例演示开关
|
||||||
demoEnabled: true
|
demoEnabled: true
|
||||||
# 文件路径 示例( Windows配置D:/wumei-smart/uploadPath,Linux配置 /var/wumei-smart/java/uploadPath)
|
# 文件路径 示例( Windows配置D:/wumei-smart/uploadPath,Linux配置 /var/wumei-smart/java/uploadPath)
|
||||||
profile: /var/wumei-smart/java/uploadPath
|
profile: D:/wumei-smart/uploadPath
|
||||||
# 获取ip地址开关
|
# 获取ip地址开关
|
||||||
addressEnabled: true
|
addressEnabled: true
|
||||||
# 验证码类型 math 数组计算 char 字符验证
|
# 验证码类型 math 数组计算 char 字符验证
|
||||||
@@ -63,9 +63,9 @@ spring:
|
|||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 0
|
database: 3
|
||||||
# 密码
|
# 密码
|
||||||
password: wumei-smart
|
#password: wumei-smart
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
lettuce:
|
lettuce:
|
||||||
|
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
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.SysDept;
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
|
|
||||||
@@ -26,9 +27,11 @@ public class TreeSelect implements Serializable
|
|||||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||||
private List<TreeSelect> children;
|
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)
|
public TreeSelect(SysDept dept)
|
||||||
|
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
27
springboot/wumei-news/pom.xml
Normal file
27
springboot/wumei-news/pom.xml
Normal 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>
|
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -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));
|
||||||
|
}
|
||||||
|
}
|
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
@@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -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 结果
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
@@ -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);
|
||||||
|
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -51,6 +51,8 @@
|
|||||||
"mqtt": "^4.3.3",
|
"mqtt": "^4.3.3",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"quill": "1.3.7",
|
"quill": "1.3.7",
|
||||||
|
"quill-image-drop-module": "^1.0.3",
|
||||||
|
"quill-image-resize-module": "^3.0.0",
|
||||||
"screenfull": "5.0.2",
|
"screenfull": "5.0.2",
|
||||||
"sortablejs": "1.10.2",
|
"sortablejs": "1.10.2",
|
||||||
"vue": "2.6.12",
|
"vue": "2.6.12",
|
||||||
@@ -58,6 +60,7 @@
|
|||||||
"vue-cropper": "0.5.5",
|
"vue-cropper": "0.5.5",
|
||||||
"vue-json-viewer": "^2.2.21",
|
"vue-json-viewer": "^2.2.21",
|
||||||
"vue-meta": "2.4.0",
|
"vue-meta": "2.4.0",
|
||||||
|
"vue-quill-editor": "^3.0.6",
|
||||||
"vue-router": "3.4.9",
|
"vue-router": "3.4.9",
|
||||||
"vuedraggable": "2.24.3",
|
"vuedraggable": "2.24.3",
|
||||||
"vuex": "3.6.0"
|
"vuex": "3.6.0"
|
||||||
|
61
vue/src/api/news/classify.js
Normal file
61
vue/src/api/news/classify.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询新闻分类列表
|
||||||
|
export function listClassify(query) {
|
||||||
|
return request({
|
||||||
|
url: '/news/classify/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询新闻分类详细
|
||||||
|
export function getClassify(classifyId) {
|
||||||
|
return request({
|
||||||
|
url: '/news/classify/' + classifyId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增新闻分类
|
||||||
|
export function addClassify(data) {
|
||||||
|
return request({
|
||||||
|
url: '/news/classify',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改新闻分类
|
||||||
|
export function updateClassify(data) {
|
||||||
|
return request({
|
||||||
|
url: '/news/classify',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除新闻分类
|
||||||
|
export function delClassify(classifyId) {
|
||||||
|
return request({
|
||||||
|
url: '/news/classify/' + classifyId,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 查询菜单下拉树结构
|
||||||
|
export function treeselect() {
|
||||||
|
return request({
|
||||||
|
url: '/news/classify/treeselect',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据角色ID查询菜单下拉树结构
|
||||||
|
export function classifyNewsTreeselect(newsId) {
|
||||||
|
return request({
|
||||||
|
url: '/news/classify/newsClassifyTreeselect/' + newsId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
57
vue/src/api/news/news.js
Normal file
57
vue/src/api/news/news.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询新闻列表
|
||||||
|
export function listNews(query) {
|
||||||
|
return request({
|
||||||
|
url: '/news/news/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询新闻详细
|
||||||
|
export function getNews(newsId) {
|
||||||
|
return request({
|
||||||
|
url: '/news/news/' + newsId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增新闻
|
||||||
|
export function addNews(data) {
|
||||||
|
return request({
|
||||||
|
url: '/news/news',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改新闻
|
||||||
|
export function updateNews(data) {
|
||||||
|
return request({
|
||||||
|
url: '/news/news',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除新闻
|
||||||
|
export function delNews(newsId) {
|
||||||
|
return request({
|
||||||
|
url: '/news/news/' + newsId,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除新闻
|
||||||
|
export function uploadBasketPic(parameter) {
|
||||||
|
return request({
|
||||||
|
url: "/common/upload",
|
||||||
|
method: 'post',
|
||||||
|
data: parameter,
|
||||||
|
headers: {'content-type': 'multipart/form-data'}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -23,6 +23,10 @@ import "quill/dist/quill.core.css";
|
|||||||
import "quill/dist/quill.snow.css";
|
import "quill/dist/quill.snow.css";
|
||||||
import "quill/dist/quill.bubble.css";
|
import "quill/dist/quill.bubble.css";
|
||||||
import { getToken } from "@/utils/auth";
|
import { getToken } from "@/utils/auth";
|
||||||
|
import resizeImage from 'quill-image-resize-module' // 图片缩放组件引用
|
||||||
|
import { ImageDrop } from 'quill-image-drop-module'; // 图片拖动组件引用
|
||||||
|
Quill.register('modules/imageDrop', ImageDrop); // 注册
|
||||||
|
Quill.register('modules/resizeImage ', resizeImage ) // 注册
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Editor",
|
name: "Editor",
|
||||||
@@ -71,6 +75,14 @@ export default {
|
|||||||
bounds: document.body,
|
bounds: document.body,
|
||||||
debug: "warn",
|
debug: "warn",
|
||||||
modules: {
|
modules: {
|
||||||
|
imageResize: { //图片缩放配置
|
||||||
|
displayStyles: {
|
||||||
|
backgroundColor: "black",
|
||||||
|
border: "none",
|
||||||
|
color: "white"
|
||||||
|
},
|
||||||
|
modules: ["Resize", "DisplaySize", "Toolbar"]
|
||||||
|
},
|
||||||
// 工具栏配置
|
// 工具栏配置
|
||||||
toolbar: [
|
toolbar: [
|
||||||
["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
|
["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
|
||||||
|
300
vue/src/components/quill/course-rich-text.vue
Normal file
300
vue/src/components/quill/course-rich-text.vue
Normal file
@@ -0,0 +1,300 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div style="margin-bottom: 50px;">
|
||||||
|
<quill-editor
|
||||||
|
:content="content"
|
||||||
|
ref="myQuillEditor"
|
||||||
|
:options="editorOption"
|
||||||
|
@focus="onEditorFocus($event)"
|
||||||
|
@blur="onEditorBlur($event)"
|
||||||
|
@change="onEditorChange($event)"
|
||||||
|
class="editor"
|
||||||
|
></quill-editor>
|
||||||
|
|
||||||
|
<!--自定义图片上传,写一个form表单,然后form表单中隐藏一个input标签,type为file属性.当我们的自定义图片处理函数被点击时,进行触发打开文件选择框,选择文件后触发uploadImg方法,
|
||||||
|
最后调用图片上传的接口,返回图片在服务器的地址之后,回显于当前富文本中 -->
|
||||||
|
<form action method="post" enctype="multipart/form-data" id="uploadFormMulti">
|
||||||
|
<input
|
||||||
|
style="display: none"
|
||||||
|
:id="uniqueId"
|
||||||
|
type="file"
|
||||||
|
name="file"
|
||||||
|
multiple
|
||||||
|
accept="image/jpg, image/jpeg, image/png, image/gif"
|
||||||
|
@change="uploadImg('uploadFormMulti')"
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
//引入quill样式
|
||||||
|
import "quill/dist/quill.core.css";
|
||||||
|
import "quill/dist/quill.snow.css";
|
||||||
|
import "quill/dist/quill.bubble.css";
|
||||||
|
//引入quillEditor编辑器模块,引入Quill模块
|
||||||
|
import {quillEditor, Quill} from "vue-quill-editor";
|
||||||
|
//引入图片缩放插件,需要依赖Quill模块
|
||||||
|
import ImageResize from 'quill-image-resize-module'
|
||||||
|
//引入图片拖拽插件,需要依赖Quill模块
|
||||||
|
import {ImageDrop} from "quill-image-drop-module"
|
||||||
|
//注册插件
|
||||||
|
Quill.register('modules/imageResize', ImageResize)
|
||||||
|
Quill.register('modules/imageDrop', ImageDrop)
|
||||||
|
//按钮多为图标显示,用户使用起来不能清楚明白功能按钮的作用,给工具栏按钮添加鼠标停留提示的交互
|
||||||
|
import {addQuillTitle} from './quill-title.js'
|
||||||
|
// //自定义上传图片api
|
||||||
|
import { uploadBasketPic } from "@/api/news/news";
|
||||||
|
|
||||||
|
// 工具栏配置
|
||||||
|
const toolbarOptions = [
|
||||||
|
["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线 -----['bold', 'italic', 'underline', 'strike']
|
||||||
|
["blockquote", "code-block"], // 引用 代码块-----['blockquote', 'code-block']
|
||||||
|
[{header: 1}, {header: 2}], // 1、2 级标题-----[{ header: 1 }, { header: 2 }]
|
||||||
|
[{list: "ordered"}, {list: "bullet"}], // 有序、无序列表-----[{ list: 'ordered' }, { list: 'bullet' }]
|
||||||
|
[{script: "sub"}, {script: "super"}], // 上标/下标-----[{ script: 'sub' }, { script: 'super' }]
|
||||||
|
[{indent: "-1"}, {indent: "+1"}], // 缩进-----[{ indent: '-1' }, { indent: '+1' }]
|
||||||
|
[{direction: "rtl"}], // 文本方向-----[{'direction': 'rtl'}]
|
||||||
|
[{size: ["small", false, "large", "huge"]}], // 字体大小-----[{ size: ['small', false, 'large', 'huge'] }]
|
||||||
|
[{header: [1, 2, 3, 4, 5, 6, false]}], // 标题-----[{ header: [1, 2, 3, 4, 5, 6, false] }]
|
||||||
|
[{color: []}, {background: []}], // 字体颜色、字体背景颜色-----[{ color: [] }, { background: [] }]
|
||||||
|
[{font: []}], // 字体种类-----[{ font: [] }]
|
||||||
|
[{align: []}], // 对齐方式-----[{ align: [] }]
|
||||||
|
["clean"], // 清除文本格式-----['clean']
|
||||||
|
["image", "video", 'link'] // 链接、图片、视频-----['link', 'image', 'video']
|
||||||
|
];
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
quillEditor
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
//接收父组件的参数
|
||||||
|
value: null,
|
||||||
|
},
|
||||||
|
mixins: [],
|
||||||
|
computed: {
|
||||||
|
//当前富文本实例
|
||||||
|
editor() {
|
||||||
|
return this.$refs.myQuillEditor.quill;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
value(val = '') {
|
||||||
|
//监听父组件参数变化,回显到富文本框
|
||||||
|
this.content = val;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
|
||||||
|
content: this.value || '',
|
||||||
|
uniqueId: "uniqueId",
|
||||||
|
editorOption: { // 富文本编辑器配置
|
||||||
|
modules: { //模块配置
|
||||||
|
toolbar: toolbarOptions, //设置工具栏
|
||||||
|
imageResize: { //图片缩放配置
|
||||||
|
displayStyles: {
|
||||||
|
backgroundColor: "black",
|
||||||
|
border: "none",
|
||||||
|
color: "white"
|
||||||
|
},
|
||||||
|
modules: ["Resize", "DisplaySize", "Toolbar"]
|
||||||
|
},
|
||||||
|
imageDrop: false, //图片拖拽配置,false为开启拖拽,true关闭拖拽1
|
||||||
|
},
|
||||||
|
theme: "snow", //主题配置
|
||||||
|
placeholder: "请输入正文"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 准备富文本编辑器
|
||||||
|
onEditorReady(quill) {
|
||||||
|
|
||||||
|
},
|
||||||
|
// 富文本编辑器 失去焦点事件
|
||||||
|
onEditorBlur(quill) {
|
||||||
|
|
||||||
|
},
|
||||||
|
// 富文本编辑器 获得焦点事件
|
||||||
|
onEditorFocus(quill) {
|
||||||
|
|
||||||
|
},
|
||||||
|
// 富文本编辑器 内容改变事件
|
||||||
|
onEditorChange({quill, html, text}) {
|
||||||
|
//将内容提交给父组件的change事件
|
||||||
|
this.$emit('change', html)
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//自定义上传图片方法
|
||||||
|
uploadImg: async function () {
|
||||||
|
let _this = this;
|
||||||
|
//构造formData对象
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append("file", document.getElementById(_this.uniqueId).files[0]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
//调用上传文件接口
|
||||||
|
uploadBasketPic(formData).then(res => {
|
||||||
|
debugger;
|
||||||
|
//返回上传文件的地址
|
||||||
|
let url = res.url;
|
||||||
|
if (url != null && url.length > 0) {
|
||||||
|
let Range = _this.editor.getSelection();
|
||||||
|
url = url.indexOf("http") !== -1 ? url : "http:" + url;
|
||||||
|
//上传文件成功之后在富文本中回显(显示)
|
||||||
|
_this.editor.insertEmbed(
|
||||||
|
Range != null ? Range.index : 0,
|
||||||
|
"image",
|
||||||
|
url
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
_this.$message.warning("图片上传失败");
|
||||||
|
}
|
||||||
|
//成功之后,将文件的文本框的value置空
|
||||||
|
document.getElementById(_this.uniqueId).value = "";
|
||||||
|
});
|
||||||
|
} catch ({message: msg}) {
|
||||||
|
document.getElementById(_this.uniqueId).value = "";
|
||||||
|
_this.$message.warning(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
let _this = this;
|
||||||
|
|
||||||
|
//构造一个工具栏图片按钮被点击时的处理函数
|
||||||
|
let imgHandler = async function (image) {
|
||||||
|
if (image) {
|
||||||
|
let fileInput = document.getElementById(_this.uniqueId); //获取隐藏的file文本ID对应document对象
|
||||||
|
fileInput.click(); //触发document对象的点击事件
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//将处理函数绑定到工具栏的image图标上
|
||||||
|
_this.editor.getModule("toolbar").addHandler("image", imgHandler);
|
||||||
|
this.$nextTick(() => {
|
||||||
|
//为工具栏的所有图标按钮添加鼠标悬停时的文字提示
|
||||||
|
addQuillTitle();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/*.editor 自定义的样式,可以自己控制富文本窗体大小*/
|
||||||
|
.editor {
|
||||||
|
line-height: normal !important;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*以下样式是为了给工具栏汉化处理*/
|
||||||
|
.ql-snow .ql-tooltip[data-mode="link"]::before {
|
||||||
|
content: "请输入链接地址:";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-tooltip.ql-editing a.ql-action::after {
|
||||||
|
border-right: 0px;
|
||||||
|
content: "保存";
|
||||||
|
padding-right: 0px;
|
||||||
|
}
|
||||||
|
.ql-snow .ql-tooltip[data-mode="video"]::before {
|
||||||
|
content: "请输入视频地址:";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-size .ql-picker-label::before,
|
||||||
|
.ql-snow .ql-picker.ql-size .ql-picker-item::before {
|
||||||
|
content: "14px";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="small"]::before {
|
||||||
|
content: "10px";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="large"]::before {
|
||||||
|
content: "18px";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before {
|
||||||
|
content: "32px";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-label::before,
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-item::before {
|
||||||
|
content: "文本";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before {
|
||||||
|
content: "标题1";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before {
|
||||||
|
content: "标题2";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before {
|
||||||
|
content: "标题3";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="4"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="4"]::before {
|
||||||
|
content: "标题4";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="5"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="5"]::before {
|
||||||
|
content: "标题5";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="6"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="6"]::before {
|
||||||
|
content: "标题6";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-font .ql-picker-label::before,
|
||||||
|
.ql-snow .ql-picker.ql-font .ql-picker-item::before {
|
||||||
|
content: "标准字体";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="serif"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="serif"]::before {
|
||||||
|
content: "衬线字体";
|
||||||
|
}
|
||||||
|
|
||||||
|
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="monospace"]::before,
|
||||||
|
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before {
|
||||||
|
content: "等宽字体";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="Microsoft YaHei"]::before,*/
|
||||||
|
/*.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="Microsoft YaHei"]::before {*/
|
||||||
|
/* content: '微软雅黑';*/
|
||||||
|
/*}*/
|
||||||
|
/*.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="SimSun"]::before,*/
|
||||||
|
/*.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="SimSun"]::before {*/
|
||||||
|
/* content: "宋体";*/
|
||||||
|
/*}*/
|
||||||
|
/*.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="SimHei"]::before,*/
|
||||||
|
/*.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="SimHei"]::before {*/
|
||||||
|
/* content: "黑体";*/
|
||||||
|
/*}*/
|
||||||
|
/*.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="KaiTi"]::before,*/
|
||||||
|
/*.ql-snow .ql-picker.ql-font .ql-picker-item[data-value="KaiTi"]::before {*/
|
||||||
|
/* content: "楷体";*/
|
||||||
|
/*}*/
|
||||||
|
</style>
|
58
vue/src/components/quill/quill-title.js
Normal file
58
vue/src/components/quill/quill-title.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
const titleConfig = {
|
||||||
|
'ql-bold': '加粗',
|
||||||
|
'ql-color': '字体颜色',
|
||||||
|
'ql-font': '字体',
|
||||||
|
'ql-code': '插入代码',
|
||||||
|
'ql-italic': '斜体',
|
||||||
|
'ql-link': '选中文字,添加链接',
|
||||||
|
'ql-background': '背景颜色',
|
||||||
|
'ql-size': '字体大小',
|
||||||
|
'ql-strike': '删除线',
|
||||||
|
'ql-script': '上标/下标',
|
||||||
|
'ql-underline': '下划线',
|
||||||
|
'ql-blockquote': '引用',
|
||||||
|
'ql-header': '标题',
|
||||||
|
'ql-indent': '缩进',
|
||||||
|
'ql-list': '列表',
|
||||||
|
'ql-align': '文本对齐',
|
||||||
|
'ql-direction': '文本方向',
|
||||||
|
'ql-code-block': '代码块',
|
||||||
|
'ql-formula': '公式',
|
||||||
|
'ql-image': '图片',
|
||||||
|
'ql-video': '视频',
|
||||||
|
'ql-clean': '清除字体样式'
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addQuillTitle() {
|
||||||
|
|
||||||
|
const oToolBar = document.querySelector('.ql-toolbar'),
|
||||||
|
aButton = oToolBar.querySelectorAll('button'),
|
||||||
|
aSelect = oToolBar.querySelectorAll('select'),
|
||||||
|
aSpan = oToolBar.querySelectorAll('span')
|
||||||
|
aButton.forEach(function (item) {
|
||||||
|
if (item.className === 'ql-script') {
|
||||||
|
item.value === 'sub' ? item.title = '下标' : item.title = '上标'
|
||||||
|
} else if (item.className === 'ql-indent') {
|
||||||
|
item.value === '+1' ? item.title = '向右缩进' : item.title = '向左缩进'
|
||||||
|
} else if (item.className === 'ql-list') {
|
||||||
|
item.value === 'ordered' ? item.title = '有序列表' : item.title = '无序列表'
|
||||||
|
} else if (item.className === 'ql-header') {
|
||||||
|
item.value === '1' ? item.title = '标题H1' : item.title = '标题H2';
|
||||||
|
} else {
|
||||||
|
item.title = titleConfig[item.classList[0]];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
aSelect.forEach(function (item) {
|
||||||
|
item.parentNode.title = titleConfig[item.classList[0]]
|
||||||
|
})
|
||||||
|
|
||||||
|
aSpan.forEach((item) => {
|
||||||
|
if (item.classList[0] === 'ql-color') {
|
||||||
|
item.title = titleConfig[item.classList[0]];
|
||||||
|
} else if (item.classList[0] === 'ql-background') {
|
||||||
|
item.title = titleConfig[item.classList[0]];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
290
vue/src/views/news/classify/index.vue
Normal file
290
vue/src/views/news/classify/index.vue
Normal file
@@ -0,0 +1,290 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="分类名字" prop="classifyName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.classifyName"
|
||||||
|
placeholder="请输入分类名字"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="分类状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择分类状态" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.iot_is_enable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['iot:classify:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['iot:classify:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['iot:classify:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['iot:classify:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="classifyList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="分类ID" align="center" prop="classifyId" />
|
||||||
|
<el-table-column label="分类名字" align="center" prop="classifyName" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="分类状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<dict-tag :options="dict.type.iot_is_enable" :value="scope.row.status"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['iot:classify:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['iot:classify:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改新闻分类对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="分类名字" prop="classifyName">
|
||||||
|
<el-input v-model="form.classifyName" placeholder="请输入分类名字" />
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="删除标志" prop="delFlag">
|
||||||
|
<el-input v-model="form.delFlag" placeholder="请输入删除标志" />
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="分类状态" prop="status">
|
||||||
|
<el-select v-model="form.status" placeholder="请选择分类状态">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.iot_is_enable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listClassify, getClassify, delClassify, addClassify, updateClassify } from "@/api/news/classify";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
dicts: ['iot_is_enable'],
|
||||||
|
name: "Classify",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 新闻分类表格数据
|
||||||
|
classifyList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
classifyName: null,
|
||||||
|
status: null
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
classifyName: [
|
||||||
|
{ required: true, message: "分类名字不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询新闻分类列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listClassify(this.queryParams).then(response => {
|
||||||
|
this.classifyList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
classifyId: null,
|
||||||
|
classifyName: null,
|
||||||
|
delFlag: null,
|
||||||
|
createBy: null,
|
||||||
|
createTime: null,
|
||||||
|
updateBy: null,
|
||||||
|
updateTime: null,
|
||||||
|
remark: null,
|
||||||
|
status: "0"
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.classifyId)
|
||||||
|
this.single = selection.length!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加新闻分类";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const classifyId = row.classifyId || this.ids
|
||||||
|
getClassify(classifyId).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改新闻分类";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.classifyId != null) {
|
||||||
|
updateClassify(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addClassify(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const classifyIds = row.classifyId || this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除新闻分类编号为"' + classifyIds + '"的数据项?').then(function() {
|
||||||
|
return delClassify(classifyIds);
|
||||||
|
}).then((res) => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess(res.msg);
|
||||||
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('iot/classify/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `classify_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
508
vue/src/views/news/consult/index.vue
Normal file
508
vue/src/views/news/consult/index.vue
Normal file
@@ -0,0 +1,508 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="新闻标题" prop="newsName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.newsName"
|
||||||
|
placeholder="请输入新闻标题"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="新闻封面" prop="newsCover">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.newsCover"
|
||||||
|
placeholder="请输入新闻封面"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="是否置顶" prop="newsIsTop">
|
||||||
|
<el-select v-model="queryParams.newsIsTop" placeholder="请选择是否置顶(0-置顶 1-置顶)" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.iot_yes_no"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否banner" prop="newsIsBanner">
|
||||||
|
<el-select v-model="queryParams.newsIsBanner" placeholder="请选择是否banner(0-是banner 1-不是banner)" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.iot_yes_no"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="分类ID" prop="classifyId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.classifyId"
|
||||||
|
placeholder="请输入分类ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="分类名称" prop="classifyName">
|
||||||
|
<el-select v-model="queryParams.classifyId" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="classifyin in classifyinfo"
|
||||||
|
:key="classifyin.id"
|
||||||
|
:label="classifyin.label"
|
||||||
|
:value="classifyin.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="新闻状态" prop="status">
|
||||||
|
<el-select v-model="queryParams.status" placeholder="请选择新闻状态" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.iot_is_enable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['iot:news:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['iot:news:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['iot:news:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['iot:news:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="newsList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="新闻ID" align="center" prop="newsId" />
|
||||||
|
<el-table-column label="新闻标题" align="center" prop="newsName" />
|
||||||
|
<!-- <el-table-column label="新闻内容" align="center" prop="newsContent" /> -->
|
||||||
|
<el-table-column label="新闻封面" align="center" prop="newsCover" >
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<img :src="scope.row.newsCover"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="是否置顶" align="center" prop="newsIsTop">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.newsIsTop"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="是否banner" align="center" prop="newsIsBanner">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<dict-tag :options="dict.type.iot_yes_no" :value="scope.row.newsIsBanner"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- <el-table-column label="分类ID" align="center" prop="classifyId" />
|
||||||
|
<el-table-column label="分类名称" align="center" prop="classifyName" /> -->
|
||||||
|
<el-table-column label="新闻状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<dict-tag :options="dict.type.iot_is_enable" :value="scope.row.status"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['iot:news:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['iot:news:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改新闻对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="新闻标题" prop="newsName">
|
||||||
|
<el-input v-model="form.newsName" placeholder="请输入新闻标题" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="新闻内容">
|
||||||
|
<editor v-model="form.newsContent" :min-height="192"/>
|
||||||
|
<!-- <my-quill-editor v-model="form.newsContent"/> -->
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="新闻封面">
|
||||||
|
<imageUpload ref="image-upload" :value="form.newsCover" :limit="1" :fileSize="1" @input="getImagePath($event)"></imageUpload>
|
||||||
|
<!-- <el-upload v-model="form.newsCover" :min-height="192" /> -->
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否置顶" prop="newsIsTop">
|
||||||
|
<el-select v-model="form.newsIsTop" placeholder="请选择是否置顶(0-置顶 1-置顶)">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.iot_yes_no"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否banner" prop="newsIsBanner">
|
||||||
|
<el-select v-model="form.newsIsBanner" placeholder="请选择是否banner(0-是banner 1-不是banner)">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.iot_yes_no"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="新闻状态" prop="status">
|
||||||
|
<el-select v-model="form.status" placeholder="请选择新闻状态">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in dict.type.iot_is_enable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="分类ID" prop="classifyId">
|
||||||
|
<el-input v-model="form.classifyId" placeholder="请输入分类ID" />
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="分类">
|
||||||
|
<el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'classify')">全选/全不选</el-checkbox>
|
||||||
|
<el-tree
|
||||||
|
class="tree-border"
|
||||||
|
:data="classifyOptions"
|
||||||
|
show-checkbox
|
||||||
|
ref="classify"
|
||||||
|
node-key="id"
|
||||||
|
:check-strictly="!form.menuCheckStrictly"
|
||||||
|
empty-text="加载中,请稍候"
|
||||||
|
:props="defaultProps"
|
||||||
|
></el-tree>
|
||||||
|
</el-form-item>
|
||||||
|
<!-- <el-form-item label="删除标志" prop="delFlag">
|
||||||
|
<el-input v-model="form.delFlag" placeholder="请输入删除标志" />
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listNews, getNews, delNews, addNews, updateNews } from "@/api/news/news";
|
||||||
|
import imageUpload from "../../../components/ImageUpload/index"
|
||||||
|
import {treeselect,classifyNewsTreeselect } from "@/api/news/classify";
|
||||||
|
import MyQuillEditor from '../../../components/quill/course-rich-text'
|
||||||
|
export default {
|
||||||
|
name: "News",
|
||||||
|
dicts: ['iot_yes_no', 'iot_yes_no', 'iot_is_enable'],
|
||||||
|
components: {
|
||||||
|
imageUpload,
|
||||||
|
MyQuillEditor
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 新闻表格数据
|
||||||
|
newsList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 列表
|
||||||
|
classifyOptions: [],
|
||||||
|
classifyinfo: [],
|
||||||
|
menuCheckStrictly: true,
|
||||||
|
menuNodeAll: false,
|
||||||
|
defaultProps: {
|
||||||
|
children: "children",
|
||||||
|
label: "label"
|
||||||
|
},
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
newsName: null,
|
||||||
|
newsContent: null,
|
||||||
|
newsCover: null,
|
||||||
|
newsIsTop: null,
|
||||||
|
newsIsBanner: null,
|
||||||
|
classifyId: null,
|
||||||
|
// classifyName: null,
|
||||||
|
status: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
newsName: [
|
||||||
|
{ required: true, message: "新闻标题不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
newsContent: [
|
||||||
|
{ required: true, message: "新闻内容不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
newsCover: [
|
||||||
|
{ required: true, message: "新闻封面不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
newsIsTop: [
|
||||||
|
{ required: true, message: "是否置顶(0-置顶 1-置顶)不能为空", trigger: "change" }
|
||||||
|
],
|
||||||
|
newsIsBanner: [
|
||||||
|
{ required: true, message: "是否banner(0-是banner 1-不是banner)不能为空", trigger: "change" }
|
||||||
|
],
|
||||||
|
// classifyId: [
|
||||||
|
// { required: true, message: "分类ID不能为空", trigger: "blur" }
|
||||||
|
// ],
|
||||||
|
// classifyName: [
|
||||||
|
// { required: true, message: "分类名称不能为空", trigger: "blur" }
|
||||||
|
// ],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询新闻列表 */
|
||||||
|
getList() {
|
||||||
|
this.getClassifyTreeselects();
|
||||||
|
this.loading = true;
|
||||||
|
listNews(this.queryParams).then(response => {
|
||||||
|
this.newsList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.menuNodeAll = false;
|
||||||
|
if (this.$refs.classify != undefined) {
|
||||||
|
this.$refs.classify.setCheckedKeys([]);
|
||||||
|
}
|
||||||
|
this.form = {
|
||||||
|
newsId: null,
|
||||||
|
newsName: null,
|
||||||
|
newsContent: null,
|
||||||
|
newsCover: null,
|
||||||
|
newsIsTop: null,
|
||||||
|
newsIsBanner: null,
|
||||||
|
classifyId: null,
|
||||||
|
classifyName: null,
|
||||||
|
status: null,
|
||||||
|
delFlag: null,
|
||||||
|
createBy: null,
|
||||||
|
createTime: null,
|
||||||
|
updateBy: null,
|
||||||
|
updateTime: null,
|
||||||
|
remark: null
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.queryParams.classifyId = [];
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.newsId)
|
||||||
|
this.single = selection.length!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.getClassifyTreeselect();
|
||||||
|
this.form.newsContent = null;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加新闻";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const newsId = row.newsId || this.ids
|
||||||
|
const roleMenu = this.getClassifyNewTreeselect(newsId);
|
||||||
|
getNews(newsId).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
roleMenu.then(res => {
|
||||||
|
debugger;
|
||||||
|
let checkedKeys = res.checkedKeys
|
||||||
|
checkedKeys.forEach((v) => {
|
||||||
|
this.$nextTick(()=>{
|
||||||
|
this.$refs.classify.setChecked(v, true ,false);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.title = "修改新闻";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
let classifyIds = [];
|
||||||
|
this.classifyOptions.forEach(classify => {
|
||||||
|
classifyIds.push(classify.id)
|
||||||
|
});
|
||||||
|
this.form.classifyId = classifyIds;
|
||||||
|
if (this.form.newsId != null) {
|
||||||
|
updateNews(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let classifyIds = [];
|
||||||
|
this.classifyOptions.forEach(classify => {
|
||||||
|
classifyIds.push(classify.id)
|
||||||
|
});
|
||||||
|
this.form.classifyId = classifyIds;
|
||||||
|
addNews(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const newsIds = row.newsId || this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除新闻编号为"' + newsIds + '"的数据项?').then(function() {
|
||||||
|
return delNews(newsIds);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('iot/news/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `news_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
/**获取上传图片的路径 */
|
||||||
|
getImagePath(data) {
|
||||||
|
debugger;
|
||||||
|
this.form.newsCover = data;
|
||||||
|
},
|
||||||
|
/** 查询分类树结构 */
|
||||||
|
getClassifyTreeselect() {
|
||||||
|
treeselect().then(response => {
|
||||||
|
this.classifyOptions = response.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 查询分类树结构 */
|
||||||
|
getClassifyTreeselects() {
|
||||||
|
treeselect().then(response => {
|
||||||
|
this.classifyinfo = response.data;
|
||||||
|
console.log(this.classifyinfo)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 树权限(全选/全不选)
|
||||||
|
handleCheckedTreeNodeAll(value, type) {
|
||||||
|
if (type == 'classify') {
|
||||||
|
this.$refs.classify.setCheckedNodes(value ? this.classifyOptions: []);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 根据角色ID查询菜单树结构 */
|
||||||
|
getClassifyNewTreeselect(newsId) {
|
||||||
|
return classifyNewsTreeselect(newsId).then(response => {
|
||||||
|
this.classifyOptions = response.menus;
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@@ -8,6 +8,7 @@ function resolve(dir) {
|
|||||||
const name = process.env.VUE_APP_TITLE || '物美智能系统' // 网页标题
|
const name = process.env.VUE_APP_TITLE || '物美智能系统' // 网页标题
|
||||||
|
|
||||||
const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
||||||
|
const webpack = require('webpack')
|
||||||
|
|
||||||
// vue.config.js 配置说明
|
// vue.config.js 配置说明
|
||||||
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
|
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
|
||||||
@@ -54,6 +55,13 @@ module.exports = {
|
|||||||
'@': resolve('src')
|
'@': resolve('src')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
plugins: [
|
||||||
|
new webpack.ProvidePlugin({
|
||||||
|
'window.Quill': 'quill/dist/quill.js',
|
||||||
|
Quill: 'quill/dist/quill.js'
|
||||||
|
})
|
||||||
|
]
|
||||||
},
|
},
|
||||||
chainWebpack(config) {
|
chainWebpack(config) {
|
||||||
config.plugins.delete('preload') // TODO: need test
|
config.plugins.delete('preload') // TODO: need test
|
||||||
|
Reference in New Issue
Block a user