diff --git a/springboot/pom.xml b/springboot/pom.xml index bcd64af3..9e0a16de 100644 --- a/springboot/pom.xml +++ b/springboot/pom.xml @@ -204,6 +204,12 @@ com.wumei wumei-iot ${wumei.version} + + + + com.wumei + wumei-news + ${wumei.version} @@ -217,6 +223,7 @@ wumei-generator wumei-common wumei-iot + wumei-news pom diff --git a/springboot/wumei-admin/pom.xml b/springboot/wumei-admin/pom.xml index e84aba32..b1bddf26 100644 --- a/springboot/wumei-admin/pom.xml +++ b/springboot/wumei-admin/pom.xml @@ -65,6 +65,11 @@ com.wumei wumei-iot + + + + com.wumei + wumei-news diff --git a/springboot/wumei-admin/src/main/resources/application-druid.yml b/springboot/wumei-admin/src/main/resources/application-druid.yml index 2b667efc..b7a194ad 100644 --- a/springboot/wumei-admin/src/main/resources/application-druid.yml +++ b/springboot/wumei-admin/src/main/resources/application-druid.yml @@ -8,14 +8,14 @@ spring: master: url: jdbc:mysql://localhost/wumei-smart?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: wumei-smart + password: root # 从库数据源 slave: # 从数据源开关/默认关闭 enabled: false - url: - username: - password: + url: + username: + password: # 初始连接数 initialSize: 5 # 最小连接池数量 @@ -35,7 +35,7 @@ spring: testWhileIdle: true testOnBorrow: false testOnReturn: false - webStatFilter: + webStatFilter: enabled: true statViewServlet: enabled: true diff --git a/springboot/wumei-admin/src/main/resources/application.yml b/springboot/wumei-admin/src/main/resources/application.yml index 9d7079ea..20d6e3f7 100644 --- a/springboot/wumei-admin/src/main/resources/application.yml +++ b/springboot/wumei-admin/src/main/resources/application.yml @@ -9,7 +9,7 @@ ruoyi: # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/wumei-smart/uploadPath,Linux配置 /var/wumei-smart/java/uploadPath) - profile: /var/wumei-smart/java/uploadPath + profile: D:/wumei-smart/uploadPath # 获取ip地址开关 addressEnabled: true # 验证码类型 math 数组计算 char 字符验证 @@ -42,15 +42,15 @@ spring: messages: # 国际化资源文件路径 basename: i18n/messages - profiles: + profiles: active: druid # 文件上传 servlet: - multipart: - # 单个文件大小 - max-file-size: 10MB - # 设置总上传的文件大小 - max-request-size: 20MB + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB # 服务模块 devtools: restart: @@ -63,9 +63,9 @@ spring: # 端口,默认为6379 port: 6379 # 数据库索引 - database: 0 + database: 3 # 密码 - password: wumei-smart + #password: wumei-smart # 连接超时时间 timeout: 10s lettuce: @@ -94,30 +94,30 @@ spring: core-size: 10 # 最小连接数 max-size: 30 # 最大连接数 queue-capacity: 3000 # 最大容量 - + # token配置 token: - # 令牌自定义标识 - header: Authorization - # 令牌密钥 - secret: abcdefghijklwumeismartrstuvwxyz - # 令牌有效期(默认30分钟)1440为一天 - expireTime: 1440 - + # 令牌自定义标识 + header: Authorization + # 令牌密钥 + secret: abcdefghijklwumeismartrstuvwxyz + # 令牌有效期(默认30分钟)1440为一天 + expireTime: 1440 + # MyBatis配置 mybatis: - # 搜索指定包别名 - typeAliasesPackage: com.ruoyi.**.domain - # 配置mapper的扫描,找到所有的mapper.xml映射文件 - mapperLocations: classpath*:mapper/**/*Mapper.xml - # 加载全局的配置文件 - configLocation: classpath:mybatis/mybatis-config.xml + # 搜索指定包别名 + typeAliasesPackage: com.ruoyi.**.domain + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/**/*Mapper.xml + # 加载全局的配置文件 + configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 -pagehelper: +pagehelper: helperDialect: mysql supportMethodsArguments: true - params: count=countSql + params: count=countSql # Swagger配置 swagger: @@ -127,7 +127,7 @@ swagger: pathMapping: /dev-api # 防止XSS攻击 -xss: +xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) diff --git a/springboot/wumei-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java b/springboot/wumei-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java index bd835db9..eefa7881 100644 --- a/springboot/wumei-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java +++ b/springboot/wumei-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java @@ -4,12 +4,13 @@ import java.io.Serializable; import java.util.List; import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonInclude; +import com.ruoyi.common.core.domain.entity.NewsClassify; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysMenu; /** * Treeselect树结构实体类 - * + * * @author ruoyi */ public class TreeSelect implements Serializable @@ -26,9 +27,11 @@ public class TreeSelect implements Serializable @JsonInclude(JsonInclude.Include.NON_EMPTY) private List 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) diff --git a/springboot/wumei-common/src/main/java/com/ruoyi/common/core/domain/entity/NewsClassify.java b/springboot/wumei-common/src/main/java/com/ruoyi/common/core/domain/entity/NewsClassify.java new file mode 100644 index 00000000..226bef2d --- /dev/null +++ b/springboot/wumei-common/src/main/java/com/ruoyi/common/core/domain/entity/NewsClassify.java @@ -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(); + } +} diff --git a/springboot/wumei-news/pom.xml b/springboot/wumei-news/pom.xml new file mode 100644 index 00000000..62b880c1 --- /dev/null +++ b/springboot/wumei-news/pom.xml @@ -0,0 +1,27 @@ + + + + wumei + com.wumei + 3.8.0 + + 4.0.0 + + wumei-news + + + 新闻模块 + + + + + + com.wumei + wumei-common + + + + + \ No newline at end of file diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/controller/NewsClassifyController.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/controller/NewsClassifyController.java new file mode 100644 index 00000000..1437ba70 --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/controller/NewsClassifyController.java @@ -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 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 list = newsClassifyService.selectNewsClassifyList(newsClassify); + ExcelUtil util = new ExcelUtil(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 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 classifies = newsClassifyService.selectClassifyList(newsClassify); + AjaxResult ajax = AjaxResult.success(); + ajax.put("checkedKeys", newsClassifyService.selectClassifyListByNewsId(newsId)); + ajax.put("menus", newsClassifyService.buildClassifyTreeSelect(classifies)); + return ajax; + } + + +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/controller/NewsController.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/controller/NewsController.java new file mode 100644 index 00000000..2e187be9 --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/controller/NewsController.java @@ -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 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 list = newsService.selectNewsList(news); + ExcelUtil util = new ExcelUtil(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)); + } +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/domain/News.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/domain/News.java new file mode 100644 index 00000000..4f5c1ef0 --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/domain/News.java @@ -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 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 getClassifyId() { + return classifyId; + } + + public Long getClassifyIds() { + return classifyIds; + } + + public void setClassifyIds(Long classifyIds) { + this.classifyIds = classifyIds; + } + + public void setClassifyId(List 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(); + } +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/domain/NewsAndClassify.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/domain/NewsAndClassify.java new file mode 100644 index 00000000..8007a0ab --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/domain/NewsAndClassify.java @@ -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(); + } +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsAndClassifyMapper.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsAndClassifyMapper.java new file mode 100644 index 00000000..1e444b5d --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsAndClassifyMapper.java @@ -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 selectNewsAndClassifysByNewId(Long newId); + + + + + /** + * 查询新闻分类 + * + * @param classifyId 分类主键 + * @return 新闻分类 + */ + public NewsAndClassify selectNewsAndClassifyByClassifyId(Long classifyId); + + /** + * 查询新闻分类列表 + * + * @param newsAndClassify 新闻分类 + * @return 新闻分类集合 + */ + public List 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); +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsClassifyMapper.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsClassifyMapper.java new file mode 100644 index 00000000..f1c94e5c --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsClassifyMapper.java @@ -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 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); + + +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsMapper.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsMapper.java new file mode 100644 index 00000000..99c31f99 --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/mapper/NewsMapper.java @@ -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 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 结果 + */ + +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsAndClassifyService.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsAndClassifyService.java new file mode 100644 index 00000000..1b61c46b --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsAndClassifyService.java @@ -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 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); +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsClassifyService.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsClassifyService.java new file mode 100644 index 00000000..64663be2 --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsClassifyService.java @@ -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 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 selectClassifyList(NewsClassify newsClassify); + + + /** + * 构建前端所需要下拉树结构 + * + * @param newsClassify 分类列表 + * @return 下拉树结构列表 + */ + public List buildClassifyTreeSelect(List newsClassify); + + + /** + * 构建前端所需要树结构 + * + * @param menus 分类列表 + * @return 树结构列表 + */ + public List buildClassifyTree(List menus); + + + + + /** + * 根据新闻ID查询分类树信息 + * + * @param newsId 角色ID + * @return 选中分类列表 + */ + public List selectClassifyListByNewsId(Long newsId); + +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsService.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsService.java new file mode 100644 index 00000000..4d92d45c --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/INewsService.java @@ -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 selectNewsList(News news); + + /** + * 新增新闻 + * + * @param news 新闻 + * @return 结果 + */ + public int insertNews(News news); + + /** + * 修改新闻 + * + * @param news 新闻 + * @return 结果 + */ + public int updateNews(News news); + + /** + * 批量删除新闻 + * + * @param newsIds 需要删除的新闻主键集合 + * @return 结果 + */ + public int deleteNewsByNewsIds(Long[] newsIds); + + /** + * 删除新闻信息 + * + * @param newsId 新闻主键 + * @return 结果 + */ + public int deleteNewsByNewsId(Long newsId); +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsAndClassifyServiceImpl.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsAndClassifyServiceImpl.java new file mode 100644 index 00000000..765c63d0 --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsAndClassifyServiceImpl.java @@ -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 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); + } +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsClassifyServiceImpl.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsClassifyServiceImpl.java new file mode 100644 index 00000000..cdcd888e --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsClassifyServiceImpl.java @@ -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 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 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 selectClassifyList(NewsClassify newsClassify) { + return newsClassifyMapper.selectNewsClassifyList(newsClassify); + } + + /** + * 构建前端所需要下拉树结构 + * + * @param newsClassify 分类列表 + * @return 下拉树结构列表 + */ + @Override + public List buildClassifyTreeSelect(List newsClassify) + { + List menuTrees = buildClassifyTree(newsClassify); + return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + + /** + * 构建前端所需要树结构 + * + * @param newsClassify 分类列表 + * @return 树结构列表 + */ + @Override + public List buildClassifyTree(List newsClassify) + { + List returnList = new ArrayList(); + for (Iterator 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 selectClassifyListByNewsId(Long newsId) + { + NewsAndClassify newsAndClassify = new NewsAndClassify(); + newsAndClassify.setNewId(newsId); + List classifyList = new ArrayList<>(); + for (NewsAndClassify andClassify : newsAndClassifyMapper.selectNewsAndClassifyList(newsAndClassify)) { + classifyList.add(Math.toIntExact(andClassify.getClassifyId())); + } + + return classifyList; + } + + +} diff --git a/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsServiceImpl.java b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsServiceImpl.java new file mode 100644 index 00000000..77a1d475 --- /dev/null +++ b/springboot/wumei-news/src/main/java/com/ruoyi/news/service/impl/NewsServiceImpl.java @@ -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 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); + } +} diff --git a/springboot/wumei-news/src/main/resources/mapper/news/NewsAndClassifyMapper.xml b/springboot/wumei-news/src/main/resources/mapper/news/NewsAndClassifyMapper.xml new file mode 100644 index 00000000..0c383057 --- /dev/null +++ b/springboot/wumei-news/src/main/resources/mapper/news/NewsAndClassifyMapper.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + select new_id, classify_id from news_and_classify + + + + + + + + + + + insert into news_and_classify + + new_id, + classify_id, + + + #{newId}, + #{classifyId}, + + + + + update news_and_classify + + classify_id = #{classifyId}, + + where new_id = #{newId} + + + + delete from news_and_classify where new_id = #{newId} + + + + delete from news_and_classify where new_id in + + #{newId} + + + \ No newline at end of file diff --git a/springboot/wumei-news/src/main/resources/mapper/news/NewsClassifyMapper.xml b/springboot/wumei-news/src/main/resources/mapper/news/NewsClassifyMapper.xml new file mode 100644 index 00000000..19d9a6e7 --- /dev/null +++ b/springboot/wumei-news/src/main/resources/mapper/news/NewsClassifyMapper.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + select classify_id, classify_name, del_flag, create_by, create_time, update_by, update_time, remark, status from news_classify + + + + + + + + insert into news_classify + + classify_name, + del_flag, + create_by, + create_time, + update_by, + update_time, + remark, + status, + + + #{classifyName}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{status}, + + + + + update news_classify + + classify_name = #{classifyName}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + status = #{status}, + + where classify_id = #{classifyId} + + + +# delete from news_classify where classify_id = #{classifyId} + update news_classify set del_flag = '2' where classify_id = #{classifyId} + + + + delete from news_classify where classify_id in + + #{classifyId} + + + \ No newline at end of file diff --git a/springboot/wumei-news/src/main/resources/mapper/news/NewsMapper.xml b/springboot/wumei-news/src/main/resources/mapper/news/NewsMapper.xml new file mode 100644 index 00000000..c03ff802 --- /dev/null +++ b/springboot/wumei-news/src/main/resources/mapper/news/NewsMapper.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 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 + + + + + + + + insert into news + + news_name, + news_content, + news_cover, + news_is_top, + news_is_banner, + + + status, + del_flag, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{newsName}, + #{newsContent}, + #{newsCover}, + #{newsIsTop}, + #{newsIsBanner}, + + + #{status}, + #{delFlag}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update news + + news_name = #{newsName}, + news_content = #{newsContent}, + news_cover = #{newsCover}, + news_is_top = #{newsIsTop}, + news_is_banner = #{newsIsBanner}, + + + status = #{status}, + del_flag = #{delFlag}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where news_id = #{newsId} + + + +# delete from news where news_id = #{newsId} + update news set del_flag = '2' where news_id = #{newsId} + + + + delete from news where news_id in + + #{newsId} + + + \ No newline at end of file diff --git a/vue/package.json b/vue/package.json index 6fdb2180..8099d581 100644 --- a/vue/package.json +++ b/vue/package.json @@ -51,6 +51,8 @@ "mqtt": "^4.3.3", "nprogress": "0.2.0", "quill": "1.3.7", + "quill-image-drop-module": "^1.0.3", + "quill-image-resize-module": "^3.0.0", "screenfull": "5.0.2", "sortablejs": "1.10.2", "vue": "2.6.12", @@ -58,6 +60,7 @@ "vue-cropper": "0.5.5", "vue-json-viewer": "^2.2.21", "vue-meta": "2.4.0", + "vue-quill-editor": "^3.0.6", "vue-router": "3.4.9", "vuedraggable": "2.24.3", "vuex": "3.6.0" diff --git a/vue/src/api/news/classify.js b/vue/src/api/news/classify.js new file mode 100644 index 00000000..930436ba --- /dev/null +++ b/vue/src/api/news/classify.js @@ -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' + }) +} \ No newline at end of file diff --git a/vue/src/api/news/news.js b/vue/src/api/news/news.js new file mode 100644 index 00000000..2bf42409 --- /dev/null +++ b/vue/src/api/news/news.js @@ -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'} + }) +} + + + diff --git a/vue/src/components/Editor/index.vue b/vue/src/components/Editor/index.vue index 6bb5a18d..6f659479 100644 --- a/vue/src/components/Editor/index.vue +++ b/vue/src/components/Editor/index.vue @@ -23,6 +23,10 @@ import "quill/dist/quill.core.css"; import "quill/dist/quill.snow.css"; import "quill/dist/quill.bubble.css"; 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 { name: "Editor", @@ -71,6 +75,14 @@ export default { bounds: document.body, debug: "warn", modules: { + imageResize: { //图片缩放配置 + displayStyles: { + backgroundColor: "black", + border: "none", + color: "white" + }, + modules: ["Resize", "DisplaySize", "Toolbar"] + }, // 工具栏配置 toolbar: [ ["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线 diff --git a/vue/src/components/quill/course-rich-text.vue b/vue/src/components/quill/course-rich-text.vue new file mode 100644 index 00000000..b1e45c6a --- /dev/null +++ b/vue/src/components/quill/course-rich-text.vue @@ -0,0 +1,300 @@ + + + + + \ No newline at end of file diff --git a/vue/src/components/quill/quill-title.js b/vue/src/components/quill/quill-title.js new file mode 100644 index 00000000..18ea368a --- /dev/null +++ b/vue/src/components/quill/quill-title.js @@ -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]]; + } + }) + + +} \ No newline at end of file diff --git a/vue/src/views/news/classify/index.vue b/vue/src/views/news/classify/index.vue new file mode 100644 index 00000000..5eb9ba31 --- /dev/null +++ b/vue/src/views/news/classify/index.vue @@ -0,0 +1,290 @@ + + + diff --git a/vue/src/views/news/consult/index.vue b/vue/src/views/news/consult/index.vue new file mode 100644 index 00000000..bd6bb284 --- /dev/null +++ b/vue/src/views/news/consult/index.vue @@ -0,0 +1,508 @@ + + + diff --git a/vue/vue.config.js b/vue/vue.config.js index faba3cb1..90d3814e 100644 --- a/vue/vue.config.js +++ b/vue/vue.config.js @@ -8,6 +8,7 @@ function resolve(dir) { const name = process.env.VUE_APP_TITLE || '物美智能系统' // 网页标题 const port = process.env.port || process.env.npm_config_port || 80 // 端口 +const webpack = require('webpack') // vue.config.js 配置说明 //官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions @@ -54,6 +55,13 @@ module.exports = { '@': resolve('src') } }, + + plugins: [ + new webpack.ProvidePlugin({ + 'window.Quill': 'quill/dist/quill.js', + Quill: 'quill/dist/quill.js' + }) + ] }, chainWebpack(config) { config.plugins.delete('preload') // TODO: need test