From f3e529c6b3f6f0e9d13d4ef8c0ccde55371545b7 Mon Sep 17 00:00:00 2001 From: "hechao.zhu" Date: Thu, 12 Oct 2023 19:25:05 +0800 Subject: [PATCH 1/7] =?UTF-8?q?cms=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cms/controller/CmsArticleController.java | 188 ++++++++++++++++ .../cms/controller/CmsColumnController.java | 163 ++++++++++++++ .../modules/demo/cms/entity/CmsArticle.java | 113 ++++++++++ .../modules/demo/cms/entity/CmsColumn.java | 86 +++++++ .../demo/cms/mapper/CmsArticleMapper.java | 17 ++ .../demo/cms/mapper/CmsColumnMapper.java | 17 ++ .../demo/cms/mapper/xml/CmsColumnMapper.xml | 5 + .../demo/cms/service/ICmsArticleService.java | 14 ++ .../demo/cms/service/ICmsColumnService.java | 14 ++ .../service/impl/CmsArticleServiceImpl.java | 18 ++ .../service/impl/CmsColumnServiceImpl.java | 19 ++ .../src/main/resources/application-dev.yml | 10 +- .../views/cms/admin/articel/CmsArticle.api.ts | 64 ++++++ .../cms/admin/articel/CmsArticle.data.ts | 143 ++++++++++++ .../cms/admin/articel/CmsArticleList.vue | 213 ++++++++++++++++++ .../admin/articel/CmsArticle_menu_insert.sql | 26 +++ .../articel/components/CmsArticleForm.vue | 70 ++++++ .../articel/components/CmsArticleModal.vue | 66 ++++++ .../views/cms/admin/column/CmsColumn.api.ts | 64 ++++++ .../views/cms/admin/column/CmsColumn.data.ts | 87 +++++++ .../views/cms/admin/column/CmsColumnList.vue | 186 +++++++++++++++ .../admin/column/CmsColumn_menu_insert.sql | 26 +++ .../admin/column/components/CmsColumnForm.vue | 70 ++++++ .../column/components/CmsColumnModal.vue | 66 ++++++ 24 files changed, 1740 insertions(+), 5 deletions(-) create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsArticle.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsArticleMapper.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsArticleService.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsArticleServiceImpl.java create mode 100644 jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.data.ts create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle_menu_insert.sql create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleForm.vue create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleModal.vue create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn_menu_insert.sql create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnForm.vue create mode 100644 jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnModal.vue diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java new file mode 100644 index 00000000..f9f20716 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java @@ -0,0 +1,188 @@ +package org.jeecg.modules.demo.cms.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.system.vo.LoginUser; +import org.jeecg.modules.demo.cms.entity.CmsArticle; +import org.jeecg.modules.demo.cms.entity.CmsColumn; +import org.jeecg.modules.demo.cms.service.ICmsArticleService; +import org.jeecg.modules.demo.cms.service.ICmsColumnService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; +import java.util.Date; + +/** + * @Description: 文章 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +@Api(tags = "文章") +@RestController +@RequestMapping("/cms/cmsArticle") +@Slf4j +public class CmsArticleController extends JeecgController { + @Autowired + private ICmsArticleService cmsArticleService; + @Autowired + private ICmsColumnService cmsColumnService; + + /** + * 分页列表查询 + * + * @param cmsArticle + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "文章-分页列表查询") + @ApiOperation(value = "文章-分页列表查询", notes = "文章-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList(CmsArticle cmsArticle, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(cmsArticle, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = cmsArticleService.page(page, queryWrapper); + return Result.OK(pageList); + } + + /** + * 添加 + * + * @param cmsArticle + * @return + */ + @AutoLog(value = "文章-添加") + @ApiOperation(value = "文章-添加", notes = "文章-添加") +// @RequiresPermissions("cms:cms_article:add") + @PostMapping(value = "/add") + public Result add(@RequestBody CmsArticle cmsArticle) { + LoginUser principal = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + cmsArticle.setCreateBy(principal.getUsername()); + CmsColumn cmsColumn = cmsColumnService.getById(cmsArticle.getColumnId()); + cmsArticle.setColumnName(cmsColumn.getName()); + if (StringUtils.equals("1", cmsArticle.getStatus())) { + cmsArticle.setPublishTime(new Date()); + } + cmsArticleService.save(cmsArticle); + return Result.OK("添加成功!"); + } + + @ApiOperation(value = "文章管理-发布/取消发布", notes = "文章管理-发布/取消发布") + @PostMapping(value = "/operationStatus") + public Result operationStatus(@RequestBody CmsArticle cmsArticle) { + if (StringUtils.equals("1", cmsArticle.getStatus())) { + cmsArticle.setPublishTime(new Date()); + } + + cmsArticleService.updateById(cmsArticle); + return Result.OK("操作成功!"); + } + + /** + * 编辑 + * + * @param cmsArticle + * @return + */ + @AutoLog(value = "文章-编辑") + @ApiOperation(value = "文章-编辑", notes = "文章-编辑") +// @RequiresPermissions("cms:cms_article:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) + public Result edit(@RequestBody CmsArticle cmsArticle) { + cmsArticleService.updateById(cmsArticle); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "文章-通过id删除") + @ApiOperation(value = "文章-通过id删除", notes = "文章-通过id删除") +// @RequiresPermissions("cms:cms_article:delete") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name = "id", required = true) String id) { + cmsArticleService.removeById(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "文章-批量删除") + @ApiOperation(value = "文章-批量删除", notes = "文章-批量删除") +// @RequiresPermissions("cms:cms_article:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + this.cmsArticleService.removeByIds(Arrays.asList(ids.split(","))); + return Result.OK("批量删除成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + //@AutoLog(value = "文章-通过id查询") + @ApiOperation(value = "文章-通过id查询", notes = "文章-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name = "id", required = true) String id) { + CmsArticle cmsArticle = cmsArticleService.getById(id); + if (cmsArticle == null) { + return Result.error("未找到对应数据"); + } + return Result.OK(cmsArticle); + } + + /** + * 导出excel + * + * @param request + * @param cmsArticle + */ +// @RequiresPermissions("cms:cms_article:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, CmsArticle cmsArticle) { + return super.exportXls(request, cmsArticle, CmsArticle.class, "文章"); + } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ +// @RequiresPermissions("cms:cms_article:importExcel") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, CmsArticle.class); + } + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java new file mode 100644 index 00000000..8fe5ded4 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java @@ -0,0 +1,163 @@ +package org.jeecg.modules.demo.cms.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.common.system.base.controller.JeecgController; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.modules.demo.cms.entity.CmsColumn; +import org.jeecg.modules.demo.cms.service.ICmsColumnService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; + +/** + * @Description: cms栏目 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +@Api(tags = "cms栏目") +@RestController +@RequestMapping("/cms/cmsColumn") +@Slf4j +public class CmsColumnController extends JeecgController { + + @Autowired + private ICmsColumnService cmsColumnService; + + /** + * 分页列表查询 + * + * @param cmsColumn + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "cms栏目-分页列表查询") + @ApiOperation(value = "cms栏目-分页列表查询", notes = "cms栏目-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList(CmsColumn cmsColumn, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(cmsColumn, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = cmsColumnService.page(page, queryWrapper); + return Result.OK(pageList); + } + + /** + * 添加 + * + * @param cmsColumn + * @return + */ + @AutoLog(value = "cms栏目-添加") + @ApiOperation(value = "cms栏目-添加", notes = "cms栏目-添加") +// @RequiresPermissions("cms:cms_column:add") + @PostMapping(value = "/add") + public Result add(@RequestBody CmsColumn cmsColumn) { + cmsColumnService.save(cmsColumn); + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param cmsColumn + * @return + */ + @AutoLog(value = "cms栏目-编辑") + @ApiOperation(value = "cms栏目-编辑", notes = "cms栏目-编辑") +// @RequiresPermissions("cms:cms_column:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) + public Result edit(@RequestBody CmsColumn cmsColumn) { + cmsColumnService.updateById(cmsColumn); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "cms栏目-通过id删除") + @ApiOperation(value = "cms栏目-通过id删除", notes = "cms栏目-通过id删除") +// @RequiresPermissions("cms:cms_column:delete") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name = "id", required = true) String id) { + cmsColumnService.removeById(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "cms栏目-批量删除") + @ApiOperation(value = "cms栏目-批量删除", notes = "cms栏目-批量删除") +// @RequiresPermissions("cms:cms_column:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + this.cmsColumnService.removeByIds(Arrays.asList(ids.split(","))); + return Result.OK("批量删除成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + //@AutoLog(value = "cms栏目-通过id查询") + @ApiOperation(value = "cms栏目-通过id查询", notes = "cms栏目-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name = "id", required = true) String id) { + CmsColumn cmsColumn = cmsColumnService.getById(id); + if (cmsColumn == null) { + return Result.error("未找到对应数据"); + } + return Result.OK(cmsColumn); + } + + /** + * 导出excel + * + * @param request + * @param cmsColumn + */ +// @RequiresPermissions("cms:cms_column:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, CmsColumn cmsColumn) { + return super.exportXls(request, cmsColumn, CmsColumn.class, "cms栏目"); + } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ +// @RequiresPermissions("cms:cms_column:importExcel") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, CmsColumn.class); + } + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsArticle.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsArticle.java new file mode 100644 index 00000000..80877bee --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsArticle.java @@ -0,0 +1,113 @@ +package org.jeecg.modules.demo.cms.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.jeecg.common.aspect.annotation.Dict; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Description: 文章 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +@Data +@TableName("cms_article") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "cms_article对象", description = "文章") +public class CmsArticle implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键") + private String id; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + @Dict(dictTable = "sys_user", dicCode = "username", dicText = "realname") + private String createBy; + /** + * 创建日期 + */ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建日期") + private Date createTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String updateBy; + /** + * 更新日期 + */ + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新日期") + private Date updateTime; + /** + * 文章标题 + */ + @Excel(name = "文章标题", width = 15) + @ApiModelProperty(value = "文章标题") + private String title; + + @Excel(name = "状态", width = 15) + @ApiModelProperty(value = "状态") + @Dict(dicCode = "captain_code") + private String status; + /** + * 文章内容 + */ + @Excel(name = "文章内容", width = 15) + @ApiModelProperty(value = "文章内容") + private String content; + /** + * 所属栏目 + */ + @Excel(name = "所属栏目", width = 15) + @ApiModelProperty(value = "所属栏目") + private String columnId; + /** + * 所属栏目名称 + */ + @Excel(name = "所属栏目名称", width = 15) + @ApiModelProperty(value = "所属栏目名称") + private String columnName; + /** + * 来源 + */ + @Excel(name = "来源", width = 15) + @ApiModelProperty(value = "来源") + private String source; + /** + * 发布时间 + */ + @Excel(name = "发布时间", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "发布时间") + private Date publishTime; + /** + * 源url + */ + @Excel(name = "源url", width = 15) + @ApiModelProperty(value = "源url") + private String originUrl; +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java new file mode 100644 index 00000000..ecd51b30 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java @@ -0,0 +1,86 @@ +package org.jeecg.modules.demo.cms.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; +import org.jeecgframework.poi.excel.annotation.Excel; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Description: cms栏目 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +@Data +@TableName("cms_column") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "cms_column对象", description = "cms栏目") +public class CmsColumn implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键") + private String id; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private String createBy; + /** + * 创建日期 + */ + @ApiModelProperty(value = "创建日期") + private Date createTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String updateBy; + /** + * 更新日期 + */ + @ApiModelProperty(value = "更新日期") + private Date updateTime; + /** + * 排序 + */ + @Excel(name = "排序", width = 15) + @ApiModelProperty(value = "排序") + private Integer sort; + /** + * 显示 + */ + @Excel(name = "显示", width = 15) + @ApiModelProperty(value = "显示") + private String isShow; + /** + * 名称 + */ + @Excel(name = "名称", width = 15) + @ApiModelProperty(value = "名称") + private String name; + /** + * 父级节点 + */ + @Excel(name = "父级节点", width = 15) + @ApiModelProperty(value = "父级节点") + private String pid; + /** + * 是否有子节点 + */ + @Excel(name = "是否有子节点", width = 15) + @ApiModelProperty(value = "是否有子节点") + private String hasChild; +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsArticleMapper.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsArticleMapper.java new file mode 100644 index 00000000..46e40794 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsArticleMapper.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.demo.cms.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.demo.cms.entity.CmsArticle; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: 文章 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +public interface CmsArticleMapper extends BaseMapper { + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java new file mode 100644 index 00000000..ab4b3391 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.demo.cms.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.demo.cms.entity.CmsColumn; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: cms栏目 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +public interface CmsColumnMapper extends BaseMapper { + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml new file mode 100644 index 00000000..58e0e128 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsArticleService.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsArticleService.java new file mode 100644 index 00000000..235e3316 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsArticleService.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.demo.cms.service; + +import org.jeecg.modules.demo.cms.entity.CmsArticle; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @Description: 文章 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +public interface ICmsArticleService extends IService { + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java new file mode 100644 index 00000000..de79b344 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.demo.cms.service; + +import org.jeecg.modules.demo.cms.entity.CmsColumn; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * @Description: cms栏目 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +public interface ICmsColumnService extends IService { + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsArticleServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsArticleServiceImpl.java new file mode 100644 index 00000000..9d369c3c --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsArticleServiceImpl.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.demo.cms.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.demo.cms.entity.CmsArticle; +import org.jeecg.modules.demo.cms.mapper.CmsArticleMapper; +import org.jeecg.modules.demo.cms.service.ICmsArticleService; +import org.springframework.stereotype.Service; + +/** + * @Description: 文章 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +@Service +public class CmsArticleServiceImpl extends ServiceImpl implements ICmsArticleService { + +} diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java new file mode 100644 index 00000000..944b3597 --- /dev/null +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.demo.cms.service.impl; + +import org.jeecg.modules.demo.cms.entity.CmsColumn; +import org.jeecg.modules.demo.cms.mapper.CmsColumnMapper; +import org.jeecg.modules.demo.cms.service.ICmsColumnService; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** + * @Description: cms栏目 + * @Author: jeecg-boot + * @Date: 2023-10-11 + * @Version: V1.0 + */ +@Service +public class CmsColumnServiceImpl extends ServiceImpl implements ICmsColumnService { + +} diff --git a/jeecg-boot-master/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml b/jeecg-boot-master/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml index 608c539f..3b8786a6 100644 --- a/jeecg-boot-master/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml +++ b/jeecg-boot-master/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml @@ -131,9 +131,9 @@ spring: connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: master: - url: jdbc:mysql://localhost:3306/comp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai + url: jdbc:mysql://182.92.169.222:3306/comp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai username: root - password: 123456 + password: ycwl2022. driver-class-name: com.mysql.cj.jdbc.Driver # 多数据源配置 #multi-datasource1: @@ -143,10 +143,10 @@ spring: #driver-class-name: com.mysql.cj.jdbc.Driver #redis 配置 redis: - database: 0 - host: 127.0.0.1 + database: 2 + host: 182.92.169.222 port: 6379 - password: '' + password: 'redis@ycwl2022.' #mybatis plus 设置 mybatis-plus: mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts new file mode 100644 index 00000000..b22c34cd --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts @@ -0,0 +1,64 @@ +import {defHttp} from '/@/utils/http/axios'; +import { useMessage } from "/@/hooks/web/useMessage"; + +const { createConfirm } = useMessage(); + +enum Api { + list = '/cms/cmsArticle/list', + save='/cms/cmsArticle/add', + edit='/cms/cmsArticle/edit', + deleteOne = '/cms/cmsArticle/delete', + deleteBatch = '/cms/cmsArticle/deleteBatch', + importExcel = '/cms/cmsArticle/importExcel', + exportXls = '/cms/cmsArticle/exportXls', +} +/** + * 导出api + * @param params + */ +export const getExportUrl = Api.exportXls; +/** + * 导入api + */ +export const getImportUrl = Api.importExcel; +/** + * 列表接口 + * @param params + */ +export const list = (params) => + defHttp.get({url: Api.list, params}); + +/** + * 删除单个 + */ +export const deleteOne = (params,handleSuccess) => { + return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); +} +/** + * 批量删除 + * @param params + */ +export const batchDelete = (params, handleSuccess) => { + createConfirm({ + iconType: 'warning', + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); + } + }); +} +/** + * 保存或者更新 + * @param params + */ +export const saveOrUpdate = (params, isUpdate) => { + let url = isUpdate ? Api.edit : Api.save; + return defHttp.post({url: url, params}); +} diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.data.ts b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.data.ts new file mode 100644 index 00000000..6d891f67 --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.data.ts @@ -0,0 +1,143 @@ +import {BasicColumn} from '/@/components/Table'; +import {FormSchema} from '/@/components/Table'; +// import { rules} from '/@/utils/helper/validator'; +// import { render } from '/@/utils/common/renderUtils'; +//列表数据 +export const columns: BasicColumn[] = [ + { + title: '所属栏目', + align: "center", + dataIndex: 'columnName' + }, + { + title: '文章标题', + align: "center", + dataIndex: 'title', + // slots: {customRender: 'htmlSlot'}, + }, + { + title: '作者', + align: "center", + dataIndex: 'createBy_dictText' + }, + { + title: '来源', + align: "center", + dataIndex: 'source' + }, + { + title: '状态', + align: "center", + dataIndex: 'status_dictText' + }, + { + title: '发布时间', + align: "center", + dataIndex: 'publishTime' + }, + // { + // title: '源url', + // align: "center", + // dataIndex: 'originUrl' + // }, +]; +//查询数据 +export const searchFormSchema: FormSchema[] = [ + { + label: "所属栏目", + field: 'columnId', + component: 'JDictSelectTag', + componentProps: { + dictCode: "cms_column,name,id" + }, + colProps: {span: 6}, + }, + { + label: "文章标题", + field: 'title', + component: 'Input', + colProps: {span: 6}, + }, + { + label: "是否发布", + field: 'status', + component: 'JDictSelectTag', + componentProps: { + dictCode: "captain_code" + }, + colProps: {span: 3}, + }, +]; +//表单数据 +export const formSchema: FormSchema[] = [ + { + label: '文章标题', + field: 'title', + component: 'Input', + dynamicRules: ({model, schema}) => { + return [ + {required: true, message: '请输入文章标题!'}, + ]; + }, + }, + { + label: '所属栏目', + field: 'columnId', + component: 'JDictSelectTag', + componentProps: { + dictCode: "cms_column,name,id" + + }, + dynamicRules: ({model, schema}) => { + return [ + {required: true, message: '请输入所属栏目!'}, + ]; + }, + }, + { + label: '文章内容', + field: 'content', + component: 'JEditor', + }, + // { + // label: '所属栏目名称', + // field: 'columnName', + // component: 'Input', + // }, + { + label: '发布时间', + field: 'publishTime', + component: 'DatePicker', + componentProps: { + showTime: true, + valueFormat: 'YYYY-MM-DD HH:mm:ss' + }, + }, + { + label: '来源', + field: 'source', + component: 'Input', + }, + { + label: '源url', + field: 'originUrl', + component: 'Input', + }, + // TODO 主键隐藏字段,目前写死为ID + { + label: '', + field: 'id', + component: 'Input', + show: false + }, +]; + + +/** + * 流程表单调用这个方法获取formSchema + * @param param + */ +export function getBpmFormSchema(_formData): FormSchema[] { + // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema + return formSchema; +} diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue new file mode 100644 index 00000000..65959e75 --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue @@ -0,0 +1,213 @@ + + + + + diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle_menu_insert.sql b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle_menu_insert.sql new file mode 100644 index 00000000..0e34975e --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle_menu_insert.sql @@ -0,0 +1,26 @@ +-- 注意:该页面对应的前台目录为views/cms文件夹下 +-- 如果你想更改到其他目录,请修改sql中component字段对应的值 + + +INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external) +VALUES ('2023101212013790550', NULL, '文章', '/cms/cmsArticleList', 'cms/CmsArticleList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0); + +-- 权限控制sql +-- 新增 +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023101212013790551', '2023101212013790550', '添加文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0); +-- 编辑 +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023101212013790552', '2023101212013790550', '编辑文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0); +-- 删除 +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023101212013790553', '2023101212013790550', '删除文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0); +-- 批量删除 +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023101212013790554', '2023101212013790550', '批量删除文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0); +-- 导出excel +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023101212013790555', '2023101212013790550', '导出excel_文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0); +-- 导入excel +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023101212013790556', '2023101212013790550', '导入excel_文章', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_article:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 12:01:55', NULL, NULL, 0, 0, '1', 0); diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleForm.vue b/jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleForm.vue new file mode 100644 index 00000000..aeab99d9 --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleForm.vue @@ -0,0 +1,70 @@ + + + diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleModal.vue b/jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleModal.vue new file mode 100644 index 00000000..d338f6ec --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/components/CmsArticleModal.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts new file mode 100644 index 00000000..e3bd0a62 --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts @@ -0,0 +1,64 @@ +import {defHttp} from '/@/utils/http/axios'; +import { useMessage } from "/@/hooks/web/useMessage"; + +const { createConfirm } = useMessage(); + +enum Api { + list = '/cms/cmsColumn/list', + save='/cms/cmsColumn/add', + edit='/cms/cmsColumn/edit', + deleteOne = '/cms/cmsColumn/delete', + deleteBatch = '/cms/cmsColumn/deleteBatch', + importExcel = '/cms/cmsColumn/importExcel', + exportXls = '/cms/cmsColumn/exportXls', +} +/** + * 导出api + * @param params + */ +export const getExportUrl = Api.exportXls; +/** + * 导入api + */ +export const getImportUrl = Api.importExcel; +/** + * 列表接口 + * @param params + */ +export const list = (params) => + defHttp.get({url: Api.list, params}); + +/** + * 删除单个 + */ +export const deleteOne = (params,handleSuccess) => { + return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); +} +/** + * 批量删除 + * @param params + */ +export const batchDelete = (params, handleSuccess) => { + createConfirm({ + iconType: 'warning', + title: '确认删除', + content: '是否删除选中数据', + okText: '确认', + cancelText: '取消', + onOk: () => { + return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); + } + }); +} +/** + * 保存或者更新 + * @param params + */ +export const saveOrUpdate = (params, isUpdate) => { + let url = isUpdate ? Api.edit : Api.save; + return defHttp.post({url: url, params}); +} diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts new file mode 100644 index 00000000..40fa2d80 --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts @@ -0,0 +1,87 @@ +import {BasicColumn} from '/@/components/Table'; +import {FormSchema} from '/@/components/Table'; +import { rules} from '/@/utils/helper/validator'; +import { render } from '/@/utils/common/renderUtils'; +//列表数据 +export const columns: BasicColumn[] = [ + { + title: '栏目名称', + align:"center", + dataIndex: 'name' + }, + { + title: '父级节点', + align:"center", + dataIndex: 'pid' + }, + { + title: '是否有子节点', + align:"center", + dataIndex: 'hasChild' + }, + { + title: '排序', + align:"center", + dataIndex: 'sort' + }, +]; +//查询数据 +export const searchFormSchema: FormSchema[] = [ + { + label: "栏目名称", + field: 'name', + component: 'Input', + colProps: {span: 6}, + }, +]; +//表单数据 +export const formSchema: FormSchema[] = [ + { + label: '栏目名称', + field: 'name', + component: 'Input', + dynamicRules: ({model,schema}) => { + return [ + { required: true, message: '请输入栏目名称!'}, + ]; + }, + }, + { + label: '父级节点', + field: 'pid', + component: 'Input', + }, + { + label: '是否有子节点', + field: 'hasChild', + component: 'Input', + }, + { + label: '排序', + field: 'sort', + component: 'InputNumber', + dynamicRules: ({model,schema}) => { + return [ + { required: true, message: '请输入排序!'}, + ]; + }, + }, + // TODO 主键隐藏字段,目前写死为ID + { + label: '', + field: 'id', + component: 'Input', + show: false + }, +]; + + + +/** +* 流程表单调用这个方法获取formSchema +* @param param +*/ +export function getBpmFormSchema(_formData): FormSchema[]{ + // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema + return formSchema; +} diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue new file mode 100644 index 00000000..50c67877 --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue @@ -0,0 +1,186 @@ + + + + + diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn_menu_insert.sql b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn_menu_insert.sql new file mode 100644 index 00000000..23ffe5f8 --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn_menu_insert.sql @@ -0,0 +1,26 @@ +-- -- 注意:该页面对应的前台目录为views/cms文件夹下 +-- -- 如果你想更改到其他目录,请修改sql中component字段对应的值 +-- +-- +-- INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external) +-- VALUES ('2023101208468620390', NULL, 'cms栏目', '/cms/cmsColumnList', 'cms/CmsColumnList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0); +-- +-- -- 权限控制sql +-- -- 新增 +-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +-- VALUES ('2023101208468620391', '2023101208468620390', '添加cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0); +-- -- 编辑 +-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +-- VALUES ('2023101208468620392', '2023101208468620390', '编辑cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0); +-- -- 删除 +-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +-- VALUES ('2023101208468620393', '2023101208468620390', '删除cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0); +-- -- 批量删除 +-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +-- VALUES ('2023101208468620394', '2023101208468620390', '批量删除cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0); +-- -- 导出excel +-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +-- VALUES ('2023101208468620395', '2023101208468620390', '导出excel_cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0); +-- -- 导入excel +-- INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +-- VALUES ('2023101208468620396', '2023101208468620390', '导入excel_cms栏目', NULL, NULL, 0, NULL, NULL, 2, 'cms:cms_column:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-10-12 08:46:39', NULL, NULL, 0, 0, '1', 0); diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnForm.vue b/jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnForm.vue new file mode 100644 index 00000000..4ebd2ca9 --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnForm.vue @@ -0,0 +1,70 @@ + + + diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnModal.vue b/jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnModal.vue new file mode 100644 index 00000000..1df76bae --- /dev/null +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/components/CmsColumnModal.vue @@ -0,0 +1,66 @@ + + + + + From 35805f42f675eee7b12d745268f5254ae2b0f44b Mon Sep 17 00:00:00 2001 From: "hechao.zhu" Date: Fri, 13 Oct 2023 10:45:40 +0800 Subject: [PATCH 2/7] =?UTF-8?q?cms=20=E6=96=87=E7=AB=A0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/cms/admin/articel/CmsArticle.api.ts | 6 + .../cms/admin/articel/CmsArticleList.vue | 317 +++++++++--------- 2 files changed, 158 insertions(+), 165 deletions(-) diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts index b22c34cd..a386a46b 100644 --- a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts @@ -11,6 +11,7 @@ enum Api { deleteBatch = '/cms/cmsArticle/deleteBatch', importExcel = '/cms/cmsArticle/importExcel', exportXls = '/cms/cmsArticle/exportXls', + operationStatus = '/cms/cmsArticle/operationStatus', } /** * 导出api @@ -21,6 +22,11 @@ export const getExportUrl = Api.exportXls; * 导入api */ export const getImportUrl = Api.importExcel; + + +export const updateStatus = (params) => defHttp.post({url: Api.operationStatus, params}); + + /** * 列表接口 * @param params diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue index 65959e75..9493afc2 100644 --- a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue @@ -1,70 +1,32 @@ From 1422736b7e572d0c1333caf85dd7de0644d25d1d Mon Sep 17 00:00:00 2001 From: zhc077 <565291854> Date: Fri, 13 Oct 2023 13:09:58 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/cms/admin/articel/CmsArticle.api.ts | 2 - .../cms/admin/articel/CmsArticleList.vue | 326 ++++++++++-------- 2 files changed, 186 insertions(+), 142 deletions(-) diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts index a386a46b..2ea07967 100644 --- a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticle.api.ts @@ -23,10 +23,8 @@ export const getExportUrl = Api.exportXls; */ export const getImportUrl = Api.importExcel; - export const updateStatus = (params) => defHttp.post({url: Api.operationStatus, params}); - /** * 列表接口 * @param params diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue index 9493afc2..3b4ad49c 100644 --- a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue @@ -8,11 +8,53 @@ 导出 + From 303f10c000b062eb3eeb31ab945ebbcbf0584d8e Mon Sep 17 00:00:00 2001 From: "hechao.zhu" Date: Fri, 13 Oct 2023 16:11:34 +0800 Subject: [PATCH 4/7] =?UTF-8?q?cms=20=E6=96=87=E7=AB=A0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/cms/controller/CmsArticleController.java | 10 ++++++++-- .../views/cms/admin/articel/CmsArticleList.vue | 15 +++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java index f9f20716..8a9abd1a 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsArticleController.java @@ -19,6 +19,7 @@ import org.jeecg.modules.demo.cms.entity.CmsColumn; import org.jeecg.modules.demo.cms.service.ICmsArticleService; import org.jeecg.modules.demo.cms.service.ICmsColumnService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; @@ -80,9 +81,10 @@ public class CmsArticleController extends JeecgController edit(@RequestBody CmsArticle cmsArticle) { + CmsColumn cmsColumn = cmsColumnService.getById(cmsArticle.getColumnId()); + if (!ObjectUtils.isEmpty(cmsColumn)) { + cmsArticle.setColumnName(cmsColumn.getName()); + } cmsArticleService.updateById(cmsArticle); return Result.OK("编辑成功!"); } diff --git a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue index 3b4ad49c..986a66ab 100644 --- a/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue +++ b/jeecgboot-vue3-master/src/views/cms/admin/articel/CmsArticleList.vue @@ -93,6 +93,7 @@ import { } from './CmsArticle.api'; // import {updateStatus} from './CmsArticle.api'; import {Update} from "/@/views/topic/Topic.api"; +import {defHttp} from "/@/utils/http/axios"; // import { downloadFile } from '/@/utils/common/renderUtils'; const checkedKeys = ref>([]); //注册model @@ -150,9 +151,11 @@ function handleEdit(record: Recordable) { }); } -function update2(record: Recordable, isopen) { - record.isopen = isopen; +function update2(record: Recordable, val) { + record.status = val; updateStatus(record) + //第2种方法 + // defHttp.post({ url: '/cms/cmsArticle/operationStatus', params: record }); reload() } @@ -206,15 +209,15 @@ function getTableAction(record) { } ]; if (record.status == "1") { - actions.unshift({ + actions.unshift({ label: '取消发布', - onClick: update2.bind(null, record, "0"), + onClick: update2.bind(null,record, "0"), }); } if (record.status == "0") { - actions.unshift({ + actions.unshift({ label: '发布', - onClick: update2.bind("1", record, "1"), + onClick: update2.bind(null,record, "1"), }); } return actions; From 0ce0bab975ab34fa02f9b8a05afbf29d532efbfa Mon Sep 17 00:00:00 2001 From: "hechao.zhu" Date: Sat, 14 Oct 2023 17:54:21 +0800 Subject: [PATCH 5/7] =?UTF-8?q?cms=E6=A0=8F=E7=9B=AE=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cms/controller/CmsColumnController.java | 181 ++++++++++++- .../modules/demo/cms/entity/CmsColumn.java | 3 + .../demo/cms/mapper/CmsColumnMapper.java | 19 ++ .../demo/cms/mapper/xml/CmsColumnMapper.xml | 19 ++ .../demo/cms/service/ICmsColumnService.java | 40 ++- .../service/impl/CmsColumnServiceImpl.java | 189 +++++++++++++- .../views/cms/admin/column/CmsColumn.api.ts | 32 ++- .../views/cms/admin/column/CmsColumn.data.ts | 56 ++-- .../views/cms/admin/column/CmsColumnList.vue | 243 ++++++++++++++---- .../admin/column/components/CmsColumnForm.vue | 4 +- .../column/components/CmsColumnModal.vue | 106 +++++--- 11 files changed, 776 insertions(+), 116 deletions(-) diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java index 8fe5ded4..c0e183ea 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/controller/CmsColumnController.java @@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.commons.lang.StringUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.system.vo.SelectTreeModel; +import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.demo.cms.entity.CmsColumn; import org.jeecg.modules.demo.cms.service.ICmsColumnService; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +22,7 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Arrays; +import java.util.List; /** * @Description: cms栏目 @@ -58,6 +61,168 @@ public class CmsColumnController extends JeecgController> rootList(CmsColumn CmsColumn, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { +// String hasQuery = req.getParameter("hasQuery"); +// if (hasQuery != null && "true".equals(hasQuery)) { +// QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(CmsColumn, req.getParameterMap()); +// List list = cmsColumnService.queryTreeListNoPage(queryWrapper); +// IPage pageList = new Page<>(1, 10, list.size()); +// pageList.setRecords(list); +// return Result.OK(pageList); +// } else { +// String parentId = CmsColumn.getPid(); +// if (oConvertUtils.isEmpty(parentId)) { +// parentId = "0"; +// } +// CmsColumn.setPid(null); +// QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(CmsColumn, req.getParameterMap()); +// // 使用 eq 防止模糊查询 +// queryWrapper.eq("pid", parentId); +// Page page = new Page(pageNo, pageSize); +// IPage pageList = cmsColumnService.page(page, queryWrapper); +// for (CmsColumn CmsColumn1 : pageList.getRecords()) { +// if (CmsColumn1.getPid().equals("0")) +// CmsColumn1.setPid("无上级"); +// } +// +// return Result.OK(pageList); +// } + + if (oConvertUtils.isEmpty(CmsColumn.getPid())) { + CmsColumn.setPid("0"); + } + Result> result = new Result<>(); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(CmsColumn, req.getParameterMap()); + String name = CmsColumn.getName(); + if (StringUtils.isBlank(name)) { + queryWrapper.eq("pid", CmsColumn.getPid()); + } + Page page = new Page(pageNo, pageSize); + IPage pageList = cmsColumnService.page(page, queryWrapper); + result.setSuccess(true); + result.setResult(pageList); + return result; + } + + /** + * 【vue3专用】加载节点的子数据 + * + * @param pid + * @return + */ + @RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET) + public Result> loadTreeChildren(@RequestParam(name = "pid") String pid) { + Result> result = new Result<>(); + try { + List ls = cmsColumnService.queryListByPid(pid); + result.setResult(ls); + result.setSuccess(true); + } catch (Exception e) { + e.printStackTrace(); + result.setMessage(e.getMessage()); + result.setSuccess(false); + } + return result; + } + + /** + * 【vue3专用】加载一级节点/如果是同步 则所有数据 + * + * @param async + * @param pcode + * @return + */ + @RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET) + public Result> loadTreeRoot(@RequestParam(name = "async") Boolean async, + @RequestParam(name = "pcode") String pcode) { + Result> result = new Result<>(); + try { + List ls = cmsColumnService.queryListByCode(pcode); + if (!async) { + loadAllChildren(ls); + } + result.setResult(ls); + result.setSuccess(true); + } catch (Exception e) { + e.printStackTrace(); + result.setMessage(e.getMessage()); + result.setSuccess(false); + } + return result; + } + + /** + * 【vue3专用】递归求子节点 同步加载用到 + * + * @param ls + */ + private void loadAllChildren(List ls) { + for (SelectTreeModel tsm : ls) { + List temp = cmsColumnService.queryListByPid(tsm.getKey()); + if (temp != null && temp.size() > 0) { + tsm.setChildren(temp); + loadAllChildren(temp); + } + } + } + + /** + * 获取子数据 + * + * @param CmsColumn + * @param req + * @return + */ + //@AutoLog(value = "基础能力设置-获取子数据") + @ApiOperation(value = "基础能力设置-获取子数据", notes = "基础能力设置-获取子数据") + @GetMapping(value = "/childList") + public Result> queryPageList(CmsColumn CmsColumn, HttpServletRequest req) { + Result> result = new Result(); + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(CmsColumn, req.getParameterMap()); + List list = cmsColumnService.list(queryWrapper); + result.setSuccess(true); + result.setResult(list); + return result; + } + + /** + * 批量查询子节点 + * + * @param parentIds 父ID(多个采用半角逗号分割) + * @param parentIds + * @return + */ + //@AutoLog(value = "基础能力设置-批量获取子数据") + @ApiOperation(value = "基础能力设置-批量获取子数据", notes = "基础能力设置-批量获取子数据") + @GetMapping("/getChildListBatch") + public Result getChildListBatch(@RequestParam("parentIds") String parentIds) { + try { + QueryWrapper queryWrapper = new QueryWrapper<>(); + List parentIdList = Arrays.asList(parentIds.split(",")); + queryWrapper.in("pid", parentIdList); + List list = cmsColumnService.list(queryWrapper); + IPage pageList = new Page<>(1, 10, list.size()); + pageList.setRecords(list); + return Result.OK(pageList); + } catch (Exception e) { + log.error(e.getMessage(), e); + return Result.error("批量查询子节点失败:" + e.getMessage()); + } + } + /** * 添加 * @@ -96,11 +261,17 @@ public class CmsColumnController extends JeecgController delete(@RequestParam(name = "id", required = true) String id) { - cmsColumnService.removeById(id); - return Result.OK("删除成功!"); + public Result delete(@RequestParam(name = "id", required = true) String id) { + Result result = new Result(); + CmsColumn sysCategory = cmsColumnService.getById(id); + if (sysCategory == null) { + result.error500("未找到对应实体"); + } else { + this.cmsColumnService.delete(id); + result.success("删除成功!"); + } + return result; } /** diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java index ecd51b30..29858f6b 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/entity/CmsColumn.java @@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import org.jeecg.common.aspect.annotation.Dict; import org.jeecgframework.poi.excel.annotation.Excel; import java.io.Serializable; @@ -64,6 +65,7 @@ public class CmsColumn implements Serializable { */ @Excel(name = "显示", width = 15) @ApiModelProperty(value = "显示") + @Dict(dicCode = "captain_code") private String isShow; /** * 名称 @@ -82,5 +84,6 @@ public class CmsColumn implements Serializable { */ @Excel(name = "是否有子节点", width = 15) @ApiModelProperty(value = "是否有子节点") + @Dict(dicCode = "captain_code") private String hasChild; } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java index ab4b3391..5cc99d3c 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/CmsColumnMapper.java @@ -1,8 +1,10 @@ package org.jeecg.modules.demo.cms.mapper; import java.util.List; +import java.util.Map; import org.apache.ibatis.annotations.Param; +import org.jeecg.common.system.vo.SelectTreeModel; import org.jeecg.modules.demo.cms.entity.CmsColumn; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -14,4 +16,21 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface CmsColumnMapper extends BaseMapper { + /** + * 编辑节点状态 + * @param id + * @param status + */ + void updateTreeNodeStatus(@Param("id") String id,@Param("status") String status); + + /** + * 【vue3专用】根据父级ID查询树节点数据 + * + * @param pid + * @param query + * @return + */ + List queryListByPid(@Param("pid") String pid, @Param("query") Map query); + + } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml index 58e0e128..7a686fb5 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/mapper/xml/CmsColumnMapper.xml @@ -2,4 +2,23 @@ + + + + update has_child set has_child = #{status} where id = #{id} + + \ No newline at end of file diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java index de79b344..6ca389bb 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/ICmsColumnService.java @@ -1,7 +1,11 @@ package org.jeecg.modules.demo.cms.service; -import org.jeecg.modules.demo.cms.entity.CmsColumn; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.common.system.vo.SelectTreeModel; +import org.jeecg.modules.demo.cms.entity.CmsColumn; + +import java.util.List; /** * @Description: cms栏目 @@ -11,4 +15,38 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface ICmsColumnService extends IService { + /**根节点父ID的值*/ + public static final String ROOT_PID_VALUE = "0"; + + /**树节点有子节点状态值*/ + public static final String HASCHILD = "1"; + + /**树节点无子节点状态值*/ + public static final String NOCHILD = "0"; + + /** + * 查询所有数据,无分页 + * + * @param queryWrapper + * @return List + */ + List queryTreeListNoPage(QueryWrapper queryWrapper); + + /** + * 【vue3专用】根据父级编码加载分类字典的数据 + * + * @param parentCode + * @return + */ + List queryListByCode(String parentCode); + + /** + * 【vue3专用】根据pid查询子节点集合 + * + * @param pid + * @return + */ + List queryListByPid(String pid); + + void delete(String id); } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java index 944b3597..70f33ffd 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/cms/service/impl/CmsColumnServiceImpl.java @@ -1,19 +1,204 @@ package org.jeecg.modules.demo.cms.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.common.constant.SymbolConstant; +import org.jeecg.common.exception.JeecgBootException; +import org.jeecg.common.system.vo.SelectTreeModel; +import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.demo.cms.entity.CmsColumn; import org.jeecg.modules.demo.cms.mapper.CmsColumnMapper; import org.jeecg.modules.demo.cms.service.ICmsColumnService; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; /** * @Description: cms栏目 * @Author: jeecg-boot - * @Date: 2023-10-11 + * @Date: 2023-10-11 * @Version: V1.0 */ @Service public class CmsColumnServiceImpl extends ServiceImpl implements ICmsColumnService { + @Override + public List queryTreeListNoPage(QueryWrapper queryWrapper) { + List dataList = baseMapper.selectList(queryWrapper); + List mapList = new ArrayList<>(); + for (CmsColumn data : dataList) { + String pidVal = data.getPid(); + //递归查询子节点的根节点 + if (pidVal != null && !ICmsColumnService.NOCHILD.equals(pidVal)) { + CmsColumn rootVal = this.getTreeRoot(pidVal); + if (rootVal != null && !mapList.contains(rootVal)) { + mapList.add(rootVal); + } + } else { + if (!mapList.contains(data)) { + mapList.add(data); + } + } + } + return mapList; + } + + @Override + public List queryListByCode(String parentCode) { + String pid = ROOT_PID_VALUE; + if (oConvertUtils.isNotEmpty(parentCode)) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CmsColumn::getPid, parentCode); + List list = baseMapper.selectList(queryWrapper); + if (list == null || list.size() == 0) { + throw new JeecgBootException("该编码【" + parentCode + "】不存在,请核实!"); + } + if (list.size() > 1) { + throw new JeecgBootException("该编码【" + parentCode + "】存在多个,请核实!"); + } + pid = list.get(0).getId(); + } + return baseMapper.queryListByPid(pid, null); + + } + + @Override + public List queryListByPid(String pid) { + if (oConvertUtils.isEmpty(pid)) { + pid = ROOT_PID_VALUE; + } + return baseMapper.queryListByPid(pid, null); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String ids) { + String allIds = this.queryTreeChildIds(ids); + String pids = this.queryTreePids(ids); + //1.删除时将节点下所有子节点一并删除 + this.baseMapper.deleteBatchIds(Arrays.asList(allIds.split(","))); + //2.将父节点中已经没有下级的节点,修改为没有子节点 + if (oConvertUtils.isNotEmpty(pids)) { + LambdaUpdateWrapper updateWrapper = new UpdateWrapper() + .lambda() + .in(CmsColumn::getId, Arrays.asList(pids.split(","))) + .set(CmsColumn::getHasChild, "0"); + this.update(updateWrapper); + } + } + + /** + * 查询需修改标识的父节点ids + * + * @param ids + * @return + */ + private String queryTreePids(String ids) { + StringBuffer sb = new StringBuffer(); + //获取id数组 + String[] idArr = ids.split(","); + for (String id : idArr) { + if (id != null) { + CmsColumn category = this.baseMapper.selectById(id); + //根据id查询pid值 + String metaPid = category.getPid(); + //查询此节点上一级是否还有其他子节点 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CmsColumn::getPid, metaPid); + queryWrapper.notIn(CmsColumn::getId, Arrays.asList(idArr)); + List dataList = this.baseMapper.selectList(queryWrapper); + boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(metaPid) + && !sb.toString().contains(metaPid); + if (flag) { + //如果当前节点原本有子节点 现在木有了,更新状态 + sb.append(metaPid).append(","); + } + } + } + if (sb.toString().endsWith(SymbolConstant.COMMA)) { + sb = sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } + + /** + * 根据所传pid查询旧的父级节点的子节点并修改相应状态值 + * + * @param pid + */ + private void updateOldParentNode(String pid) { + if (!ICmsColumnService.ROOT_PID_VALUE.equals(pid)) { + Long count = baseMapper.selectCount(new QueryWrapper().eq("pid", pid)); + if (count == null || count <= 1) { +// baseMapper.updateTreeNodeStatus(pid, ICmsColumnService.NOCHILD); + this.lambdaUpdate().set(CmsColumn::getPid, ICmsColumnService.NOCHILD) + .eq(CmsColumn::getPid, pid).update(); + } + } + } + + /** + * 递归查询节点的根节点 + * + * @param pidVal + * @return + */ + private CmsColumn getTreeRoot(String pidVal) { + CmsColumn data = baseMapper.selectById(pidVal); + if (data != null && !ICmsColumnService.ROOT_PID_VALUE.equals(data.getPid())) { + return this.getTreeRoot(data.getPid()); + } else { + return data; + } + } + + /** + * 根据id查询所有子节点id + * + * @param ids + * @return + */ + private String queryTreeChildIds(String ids) { + //获取id数组 + String[] idArr = ids.split(","); + StringBuffer sb = new StringBuffer(); + for (String pidVal : idArr) { + if (pidVal != null) { + if (!sb.toString().contains(pidVal)) { + if (sb.toString().length() > 0) { + sb.append(","); + } + sb.append(pidVal); + this.getTreeChildIds(pidVal, sb); + } + } + } + return sb.toString(); + } + + /** + * 递归查询所有子节点 + * + * @param pidVal + * @param sb + * @return + */ + private StringBuffer getTreeChildIds(String pidVal, StringBuffer sb) { + List dataList = baseMapper.selectList(new QueryWrapper().eq("pid", pidVal)); + if (dataList != null && dataList.size() > 0) { + for (CmsColumn tree : dataList) { + if (!sb.toString().contains(tree.getId())) { + sb.append(",").append(tree.getId()); + } + this.getTreeChildIds(tree.getId(), sb); + } + } + return sb; + } } diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts index e3bd0a62..be0f65bd 100644 --- a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.api.ts @@ -4,13 +4,16 @@ import { useMessage } from "/@/hooks/web/useMessage"; const { createConfirm } = useMessage(); enum Api { - list = '/cms/cmsColumn/list', + list = '/cms/cmsColumn/rootList', save='/cms/cmsColumn/add', edit='/cms/cmsColumn/edit', deleteOne = '/cms/cmsColumn/delete', deleteBatch = '/cms/cmsColumn/deleteBatch', importExcel = '/cms/cmsColumn/importExcel', exportXls = '/cms/cmsColumn/exportXls', + loadTreeData = '/cms/cmsColumn/loadTreeRoot', + getChildList = '/cms/cmsColumn/childList', + getChildListBatch = '/cms/cmsColumn/getChildListBatch', } /** * 导出api @@ -58,7 +61,32 @@ export const batchDelete = (params, handleSuccess) => { * 保存或者更新 * @param params */ -export const saveOrUpdate = (params, isUpdate) => { +// export const saveOrUpdate = (params, isUpdate) => { +// let url = isUpdate ? Api.edit : Api.save; +// return defHttp.post({url: url, params}); +// } + +export const saveOrUpdateDict = (params, isUpdate) => { let url = isUpdate ? Api.edit : Api.save; return defHttp.post({url: url, params}); } + +/** + * 查询全部树形节点数据 + * @param params + */ +export const loadTreeData = (params) => + defHttp.get({url: Api.loadTreeData,params}); +/** + * 查询子节点数据 + * @param params + */ +export const getChildList = (params) => + defHttp.get({url: Api.getChildList, params}); +/** + * 批量查询子节点数据 + * @param params + */ +export const getChildListBatch = (params) => + defHttp.get({url: Api.getChildListBatch, params},{isTransformResponse:false}); + diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts index 40fa2d80..cff4b5c0 100644 --- a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumn.data.ts @@ -4,20 +4,21 @@ import { rules} from '/@/utils/helper/validator'; import { render } from '/@/utils/common/renderUtils'; //列表数据 export const columns: BasicColumn[] = [ + // { + // title: '父级节点', + // align:"center", + // dataIndex: 'pid' + // }, { title: '栏目名称', - align:"center", - dataIndex: 'name' - }, - { - title: '父级节点', - align:"center", - dataIndex: 'pid' + align:"left", + dataIndex: 'name', + width: 350, }, { - title: '是否有子节点', + title: '显示', align:"center", - dataIndex: 'hasChild' + dataIndex: 'isShow_dictText' }, { title: '排序', @@ -36,6 +37,18 @@ export const searchFormSchema: FormSchema[] = [ ]; //表单数据 export const formSchema: FormSchema[] = [ + { + label: '父级节点', + field: 'pid', + component: 'JTreeSelect', + componentProps: { + dict: 'cms_column,name,id', + pidField: 'pid', + pidValue: '0', + hasChildField: 'has_child', + }, + dynamicDisabled: true, + }, { label: '栏目名称', field: 'name', @@ -46,15 +59,24 @@ export const formSchema: FormSchema[] = [ ]; }, }, + // { + // label: '是否有子节点', + // field: 'hasChild', + // component: 'Input', + // }, + { - label: '父级节点', - field: 'pid', - component: 'Input', - }, - { - label: '是否有子节点', - field: 'hasChild', - component: 'Input', + label: '显示', + field: 'isShow', + component: 'RadioGroup', + componentProps: { + //options里面由一个一个的radio组成,支持disabled + options: [ + { label: '是', value: 1, }, + { label: '否', value: 0 }, + ], + defaultValue:1, + }, }, { label: '排序', diff --git a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue index 50c67877..6013f3c7 100644 --- a/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue +++ b/jeecgboot-vue3-master/src/views/cms/admin/column/CmsColumnList.vue @@ -1,17 +1,20 @@