From 3804b9ad389c06e0b2a58adeab79eedfb67c2264 Mon Sep 17 00:00:00 2001 From: qianlan <3220857484@qq.com> Date: Tue, 24 Aug 2021 13:51:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=8A=9F=E8=83=BD=E5=A4=A7?= =?UTF-8?q?=E8=87=B4=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/deploy.sh | 2 - docker/docker-compose.yml | 25 +- pom.xml | 5 +- .../qianlan/TestNodeController.java | 174 ++++--- .../src/main/resources/application-prod.yml | 2 +- .../src/main/resources/application.yml | 2 + ruoyi-system/pom.xml | 5 + .../com/ruoyi/system/domain/TestNode.java | 7 + .../ruoyi/system/mapper/TestNodeMapper.java | 10 +- .../system/service/ITestNodeService.java | 24 + .../service/impl/TestNodeServiceImpl.java | 177 +++++-- .../mapper/system/TestNodeMapper.xml | 23 +- ruoyi-system/src/test/java/testNode.java | 19 + ruoyi-ui/src/api/system/node.js | 29 +- ruoyi-ui/src/views/show/Charts.vue | 316 ++++++++++++ ruoyi-ui/src/views/show/Keywords.vue | 173 +++++++ ruoyi-ui/src/views/show/index.vue | 158 ++++++ ruoyi-ui/src/views/show/mock.js | 459 ++++++++++++++++++ .../src/views/system/node/index - 副本.vue | 293 +++++++++++ ruoyi-ui/src/views/system/node/index.vue | 128 +++-- sql/sys_menu.sql | 158 ++++++ sql/test_node.sql | 89 ++++ 22 files changed, 2113 insertions(+), 165 deletions(-) create mode 100644 ruoyi-system/src/test/java/testNode.java create mode 100644 ruoyi-ui/src/views/show/Charts.vue create mode 100644 ruoyi-ui/src/views/show/Keywords.vue create mode 100644 ruoyi-ui/src/views/show/index.vue create mode 100644 ruoyi-ui/src/views/show/mock.js create mode 100644 ruoyi-ui/src/views/system/node/index - 副本.vue create mode 100644 sql/sys_menu.sql create mode 100644 sql/test_node.sql diff --git a/docker/deploy.sh b/docker/deploy.sh index 79fb9ae5b..90fbbafcc 100644 --- a/docker/deploy.sh +++ b/docker/deploy.sh @@ -1,11 +1,9 @@ #!/bin/bash - #使用说明,用来提示输入参数 usage() { echo "Usage: sh 执行脚本.sh [port|mount|monitor|base|start|stop|stopall|rm|rmiNoneTag]" exit 1 } - #开启所需端口(生产环境不推荐开启) port(){ # mysql 端口 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index ac065c351..330202338 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -18,8 +18,6 @@ services: - /docker/mysql/data/:/var/lib/mysql/ # 配置挂载 - /docker/mysql/conf/:/etc/mysql/conf.d/ - # 主机本机时间文件映射 与本机时间同步 - - /etc/localtime:/etc/localtime:ro command: # 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配) --default-authentication-plugin=mysql_native_password @@ -37,6 +35,9 @@ services: # 如果需要指定版本 就把 latest 换成版本号 image: nginx:latest container_name: nginx-web + environment: + # 时区上海 + TZ: Asia/Shanghai ports: - 80:80 - 443:443 @@ -49,8 +50,6 @@ services: - /docker/nginx/html:/usr/share/nginx/html # 日志目录 - /docker/nginx/log:/var/log/nginx - # 主机本机时间文件映射 与本机时间同步 - - /etc/localtime:/etc/localtime:ro privileged: true restart: always networks: @@ -62,16 +61,13 @@ services: ports: - 6379:6379 environment: - # 设置环境变量 时区上海 编码UTF-8 + # 时区上海 TZ: Asia/Shanghai - LANG: en_US.UTF-8 volumes: # 配置文件 - /docker/redis/conf/redis.conf:/redis.conf:rw # 数据文件 - /docker/redis/data:/data:rw - # 主机本机时间文件映射 与本机时间同步 - - /etc/localtime:/etc/localtime:ro command: "redis-server --appendonly yes" privileged: true restart: always @@ -88,6 +84,8 @@ services: # 控制台端口 - 9001:9001 environment: + # 时区上海 + TZ: Asia/Shanghai # 管理后台用户名 MINIO_ACCESS_KEY: ruoyi # 管理后台密码,最小8个字符 @@ -97,8 +95,6 @@ services: - /docker/minio/data:/data # 映射配置目录 - /docker/minio/config:/root/.minio/ - # 主机本机时间文件映射 与本机时间同步 - - /etc/localtime:/etc/localtime:ro command: server --console-address ':9001' /data # 指定容器中的目录 /data privileged: true restart: always @@ -109,7 +105,8 @@ services: ruoyi-server1: image: "ruoyi/ruoyi-server:2.6.0" environment: - - TZ=Asia/Shanghai + # 时区上海 + TZ: Asia/Shanghai volumes: # 配置文件 - /docker/server1/logs/:/ruoyi/server/logs/ @@ -123,7 +120,8 @@ services: ruoyi-server2: image: "ruoyi/ruoyi-server:2.6.0" environment: - - TZ=Asia/Shanghai + # 时区上海 + TZ: Asia/Shanghai volumes: # 配置文件 - /docker/server2/logs/:/ruoyi/server/logs/ @@ -137,7 +135,8 @@ services: ruoyi-monitor-admin: image: "ruoyi/ruoyi-monitor-admin:2.6.0" environment: - - TZ=Asia/Shanghai + # 时区上海 + TZ: Asia/Shanghai privileged: true restart: always networks: diff --git a/pom.xml b/pom.xml index 7c31108c6..4ef56ec5b 100644 --- a/pom.xml +++ b/pom.xml @@ -40,8 +40,9 @@ 8.2.0 - localhost - http://${docker.registry.url}:2375 + 182.92.67.41 + https://${docker.registry.url}:2376 + D:\DevEnvironment\dockerTls ruoyi 1.2.2 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/qianlan/TestNodeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/qianlan/TestNodeController.java index 951f23cf3..7d8cd55e1 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/qianlan/TestNodeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/qianlan/TestNodeController.java @@ -2,9 +2,13 @@ package com.ruoyi.web.controller.qianlan; import java.util.List; import java.util.Arrays; +import java.util.Map; +import com.ruoyi.system.domain.TestNode; import lombok.RequiredArgsConstructor; + import javax.validation.constraints.*; + import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -36,76 +40,114 @@ import io.swagger.annotations.ApiOperation; @RequestMapping("/system/node") public class TestNodeController extends BaseController { - private final ITestNodeService iTestNodeService; + private final ITestNodeService iTestNodeService; - /** - * 查询节点维护列表 - */ - @ApiOperation("查询节点维护列表") - @PreAuthorize("@ss.hasPermi('system:node:list')") - @GetMapping("/list") - public AjaxResult> list(@Validated TestNodeBo bo) { - List list = iTestNodeService.queryList(bo); - return AjaxResult.success(list); - } + /** + * 获取根节点的名字用于前端页面展示 + * + * @return + */ + @ApiOperation("/查询根节点的名字") + @GetMapping("/listRootName") + public AjaxResult getTags() { + List list = iTestNodeService.getTags(); + return AjaxResult.success(list); + } - /** - * 导出节点维护列表 - */ - @ApiOperation("导出节点维护列表") - @PreAuthorize("@ss.hasPermi('system:node:export')") - @Log(title = "节点维护", businessType = BusinessType.EXPORT) - @GetMapping("/export") - public AjaxResult export(@Validated TestNodeBo bo) { - List list = iTestNodeService.queryList(bo); - ExcelUtil util = new ExcelUtil(TestNodeVo.class); - return util.exportExcel(list, "节点维护"); - } + /** + * 查询节点以children的方式展示 + */ + @ApiOperation("/查询节点以children形式展示") + //@PreAuthorize("@ss.hasPermi('system:node:list')") + @GetMapping("/listWithChildren") + public AjaxResult listWithChildren(String nodeName) { + List nodeList = iTestNodeService.queryListWithChildren(nodeName); + if (nodeList == null) { + return AjaxResult.error("查询无果"); + } else { + return AjaxResult.success(nodeList); + } + } - /** - * 获取节点维护详细信息 - */ - @ApiOperation("获取节点维护详细信息") - @PreAuthorize("@ss.hasPermi('system:node:query')") - @GetMapping("/{id}") - public AjaxResult getInfo(@NotNull(message = "主键不能为空") - @PathVariable("id") Long id) { - return AjaxResult.success(iTestNodeService.queryById(id)); - } + /** + * 查询节点维护列表 + */ + @ApiOperation("查询节点维护列表") + @PreAuthorize("@ss.hasPermi('system:node:list')") + @GetMapping("/list") + public AjaxResult> list(@Validated TestNodeBo bo) { + List list = iTestNodeService.queryList(bo); + return AjaxResult.success(list); + } - /** - * 新增节点维护 - */ - @ApiOperation("新增节点维护") - @PreAuthorize("@ss.hasPermi('system:node:add')") - @Log(title = "节点维护", businessType = BusinessType.INSERT) - @RepeatSubmit - @PostMapping() - public AjaxResult add(@Validated(AddGroup.class) @RequestBody TestNodeBo bo) { - return toAjax(iTestNodeService.insertByBo(bo) ? 1 : 0); - } + /** + * 导出节点维护列表 + */ + @ApiOperation("导出节点维护列表") + @PreAuthorize("@ss.hasPermi('system:node:export')") + @Log(title = "节点维护", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(@Validated TestNodeBo bo) { + List list = iTestNodeService.queryList(bo); + ExcelUtil util = new ExcelUtil(TestNodeVo.class); + return util.exportExcel(list, "节点维护"); + } - /** - * 修改节点维护 - */ - @ApiOperation("修改节点维护") - @PreAuthorize("@ss.hasPermi('system:node:edit')") - @Log(title = "节点维护", businessType = BusinessType.UPDATE) - @RepeatSubmit - @PutMapping() - public AjaxResult edit(@Validated(EditGroup.class) @RequestBody TestNodeBo bo) { - return toAjax(iTestNodeService.updateByBo(bo) ? 1 : 0); - } + /** + * 获取节点维护详细信息 + */ + @ApiOperation("获取节点维护详细信息") + @PreAuthorize("@ss.hasPermi('system:node:query')") + @GetMapping("/{id}") + public AjaxResult getInfo(@NotNull(message = "主键不能为空") + @PathVariable("id") Long id) { + return AjaxResult.success(iTestNodeService.queryById(id)); + } - /** - * 删除节点维护 - */ - @ApiOperation("删除节点维护") - @PreAuthorize("@ss.hasPermi('system:node:remove')") - @Log(title = "节点维护" , businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@NotEmpty(message = "主键不能为空") - @PathVariable Long[] ids) { - return toAjax(iTestNodeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); - } + /** + * 新增节点维护 + */ + @ApiOperation("新增节点维护") + @PreAuthorize("@ss.hasPermi('system:node:add')") + @Log(title = "节点维护", businessType = BusinessType.INSERT) + @RepeatSubmit + @PostMapping() + public AjaxResult add(@Validated(AddGroup.class) @RequestBody TestNodeBo bo) { + return toAjax(iTestNodeService.insertByBo(bo) ? 1 : 0); + } + + /** + * 新增多个节点维护 + */ + @ApiOperation("新增多个节点维护") + @Log(title = "节点维护", businessType = BusinessType.INSERT) + @RepeatSubmit + @PostMapping("/addMultiple") + public AjaxResult addMultiple(@RequestBody Map map) { + return iTestNodeService.addMultiple(map); + } + + /** + * 修改节点维护 + */ + @ApiOperation("修改节点维护") + @PreAuthorize("@ss.hasPermi('system:node:edit')") + @Log(title = "节点维护", businessType = BusinessType.UPDATE) + @RepeatSubmit + @PutMapping() + public AjaxResult edit(@Validated(EditGroup.class) @RequestBody TestNodeBo bo) { + return toAjax(iTestNodeService.updateByBo(bo) ? 1 : 0); + } + + /** + * 删除节点维护 + */ + @ApiOperation("删除节点维护") + @PreAuthorize("@ss.hasPermi('system:node:remove')") + @Log(title = "节点维护", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@NotEmpty(message = "主键不能为空") + @PathVariable Long[] ids) { + return toAjax(iTestNodeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0); + } } diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index 2640bc0eb..666022043 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -78,7 +78,7 @@ spring: # 数据库索引 database: 0 # 密码 - password: + password: 123456 # 连接超时时间 timeout: 10s # 是否开启ssl diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 4a52958a3..205b193dc 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -89,6 +89,8 @@ spring: jackson: # 日期格式化 date-format: yyyy-MM-dd HH:mm:ss + # 忽略null属性值,不传递 + default-property-inclusion: non_null serialization: # 格式化输出 indent_output: false diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index 3665c8054..b9f5603f6 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -22,6 +22,11 @@ com.ruoyi ruoyi-common + + junit + junit + test + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TestNode.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TestNode.java index 1653e8264..8774a110c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TestNode.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TestNode.java @@ -1,12 +1,14 @@ package com.ruoyi.system.domain; import com.baomidou.mybatisplus.annotation.*; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import java.io.Serializable; import java.util.Date; import java.math.BigDecimal; +import java.util.List; /** * 节点维护对象 test_node @@ -44,4 +46,9 @@ public class TestNode implements Serializable { */ private Long pid; + /** + * 子节点 + */ + @TableField(exist = false) + private List children; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TestNodeMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TestNodeMapper.java index 601a88a4b..1c17fe361 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TestNodeMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TestNodeMapper.java @@ -2,8 +2,8 @@ package com.ruoyi.system.mapper; import com.ruoyi.system.domain.TestNode; import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus; -import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache; -import org.apache.ibatis.annotations.CacheNamespace; + +import java.util.List; /** * 节点维护Mapper接口 @@ -13,4 +13,10 @@ import org.apache.ibatis.annotations.CacheNamespace; */ public interface TestNodeMapper extends BaseMapperPlus { + /** + * 查询节点以children的方式展示 + * @param nodeId 前端传来的节点名 + * @return 带children的节点list + */ + List queryListWithChildren(Long nodeId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITestNodeService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITestNodeService.java index 1157b9b3d..d684237cc 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITestNodeService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITestNodeService.java @@ -1,5 +1,6 @@ package com.ruoyi.system.service; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.domain.TestNode; import com.ruoyi.system.domain.vo.TestNodeVo; import com.ruoyi.system.domain.bo.TestNodeBo; @@ -7,6 +8,7 @@ import com.ruoyi.common.core.mybatisplus.core.IServicePlus; import java.util.Collection; import java.util.List; +import java.util.Map; /** * 节点维护Service接口 @@ -15,6 +17,8 @@ import java.util.List; * @date 2021-08-08 */ public interface ITestNodeService extends IServicePlus { + + /** * 查询单个 * @return @@ -48,4 +52,24 @@ public interface ITestNodeService extends IServicePlus { * @return */ Boolean deleteWithValidByIds(Collection ids, Boolean isValid); + + /** + * 查询节点以children的方式展示 + * @param nodeName 前端传来的节点名 + * @return 带children的节点list + */ + List queryListWithChildren(String nodeName); + + /** + * 获取根节点的名字用于前端页面展示 + * @return + */ + List getTags(); + + /** + * 添加多个节点 + * @param map + * @return + */ + AjaxResult addMultiple(Map map); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestNodeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestNodeServiceImpl.java index 61da9ca3f..f03e0147b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestNodeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TestNodeServiceImpl.java @@ -2,6 +2,9 @@ package com.ruoyi.system.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ruoyi.common.core.domain.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -12,6 +15,7 @@ import com.ruoyi.system.domain.TestNode; import com.ruoyi.system.mapper.TestNodeMapper; import com.ruoyi.system.service.ITestNodeService; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Collection; @@ -25,54 +29,141 @@ import java.util.Collection; @Service public class TestNodeServiceImpl extends ServicePlusImpl implements ITestNodeService { - @Override - public TestNodeVo queryById(Long id){ - return getVoById(id); - } + @Autowired + private TestNodeMapper testNodeMapper; + + @Override + public TestNodeVo queryById(Long id) { + return getVoById(id); + } - @Override - public List queryList(TestNodeBo bo) { - return listVo(buildQueryWrapper(bo)); - } + @Override + public List queryList(TestNodeBo bo) { + return listVo(buildQueryWrapper(bo)); + } - private LambdaQueryWrapper buildQueryWrapper(TestNodeBo bo) { - Map params = bo.getParams(); - LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); - lqw.like(StrUtil.isNotBlank(bo.getName()), TestNode::getName, bo.getName()); - lqw.eq(StrUtil.isNotBlank(bo.getCategary()), TestNode::getCategary, bo.getCategary()); - lqw.eq(bo.getPid() != null, TestNode::getPid, bo.getPid()); - return lqw; - } + private LambdaQueryWrapper buildQueryWrapper(TestNodeBo bo) { + Map params = bo.getParams(); + LambdaQueryWrapper lqw = Wrappers.lambdaQuery(); + lqw.like(StrUtil.isNotBlank(bo.getName()), TestNode::getName, bo.getName()); + lqw.eq(StrUtil.isNotBlank(bo.getCategary()), TestNode::getCategary, bo.getCategary()); + lqw.eq(bo.getPid() != null, TestNode::getPid, bo.getPid()); + return lqw; + } - @Override - public Boolean insertByBo(TestNodeBo bo) { - TestNode add = BeanUtil.toBean(bo, TestNode.class); - validEntityBeforeSave(add); - return save(add); - } + @Override + public Boolean insertByBo(TestNodeBo bo) { + TestNode add = BeanUtil.toBean(bo, TestNode.class); + validEntityBeforeSave(add); + return save(add); + } - @Override - public Boolean updateByBo(TestNodeBo bo) { - TestNode update = BeanUtil.toBean(bo, TestNode.class); - validEntityBeforeSave(update); - return updateById(update); - } + @Override + public Boolean updateByBo(TestNodeBo bo) { + TestNode update = BeanUtil.toBean(bo, TestNode.class); + validEntityBeforeSave(update); + return updateById(update); + } - /** - * 保存前的数据校验 - * - * @param entity 实体类数据 - */ - private void validEntityBeforeSave(TestNode entity){ - //TODO 做一些数据校验,如唯一约束 - } + /** + * 保存前的数据校验 + * + * @param entity 实体类数据 + */ + private void validEntityBeforeSave(TestNode entity) { + //TODO 做一些数据校验,如唯一约束 + } - @Override - public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { - if(isValid){ - //TODO 做一些业务上的校验,判断是否需要校验 - } - return removeByIds(ids); - } + @Override + public Boolean deleteWithValidByIds(Collection ids, Boolean isValid) { + if (isValid) { + //TODO 做一些业务上的校验,判断是否需要校验 + } + return removeByIds(ids); + } + + /** + * 查询节点以children的方式展示 + * + * @param nodeName 前端传来的节点名 + * @return 带children的节点list + */ + @Override + public List queryListWithChildren(String nodeName) { + List nodeList = testNodeMapper.selectList(new QueryWrapper().like("name", nodeName)); + if (nodeList.size() == 0) { + return null; + } + Long id = nodeList.get(0).getId(); + //获得根节点下的所有子节点 + List testNodeList = testNodeMapper.queryListWithChildren(id); + ArrayList nodeArrayList = new ArrayList<>(); + nodeList.get(0).setChildren(testNodeList); + nodeArrayList.add(nodeList.get(0)); + return nodeArrayList; + } + + /** + * 获取根节点的名字用于前端页面展示 + * + * @return + */ + @Override + public List getTags() { + List nodeList = testNodeMapper.selectList(new QueryWrapper().eq("pid", 0)); + ArrayList arrayList = new ArrayList(); + for (TestNode testNode : nodeList) { + arrayList.add(testNode.getName()); + } + return arrayList; + } + + /** + * 添加多个节点 + * + * @param map + * @return + */ + @Override + public AjaxResult addMultiple(Map map) { + int insert = 0; + int insert1 = 0; + String name = (String) map.get("name"); + String categary = (String) map.get("categary"); + + Long pid = ((Integer) map.get("pid")).longValue(); + String[] nameArray = name.split("#"); + if (StrUtil.isNotBlank(categary)) { + String[] categaryArray = categary.split("#"); + if (nameArray.length != categaryArray.length) { + return AjaxResult.error("输入数量不匹配,请重新提交"); + } else { + for (int i = 0; i < nameArray.length; i++) { + TestNode testNode = new TestNode(); + testNode.setName(nameArray[i]); + testNode.setCategary(categaryArray[i]); + testNode.setPid(pid); + if (categaryArray[i].trim().isEmpty()) { + testNode.setCategary(null); + } + testNodeMapper.insert(testNode); + insert++; + } + } + } else { + for (int i = 0; i < nameArray.length; i++) { + TestNode testNode = new TestNode(); + testNode.setName(nameArray[i]); + testNode.setPid(pid); + testNodeMapper.insert(testNode); + insert1++; + } + } + if (nameArray.length == insert || nameArray.length == insert1) { + return AjaxResult.success("添加成功"); + } else { + return AjaxResult.error("添加失败"); + } + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/TestNodeMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TestNodeMapper.xml index 9138ef0b0..9e6bb0c29 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TestNodeMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TestNodeMapper.xml @@ -1,7 +1,7 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> @@ -11,5 +11,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + - \ No newline at end of file + + + diff --git a/ruoyi-system/src/test/java/testNode.java b/ruoyi-system/src/test/java/testNode.java new file mode 100644 index 000000000..0bf349b8f --- /dev/null +++ b/ruoyi-system/src/test/java/testNode.java @@ -0,0 +1,19 @@ +import org.junit.Test; +/** + * @author qianlan + * @version 1.0 + * @date 2021/8/18 11:18 + */ +public class testNode { + + @Test + public void test1(){ + String name = "12,3,1,哲, ,90"; + String[] nameArray = name.split(","); + System.out.println(nameArray.length); + for (String s : nameArray) { + System.out.println(s); + } + } + +} diff --git a/ruoyi-ui/src/api/system/node.js b/ruoyi-ui/src/api/system/node.js index 30f22d1ff..0fa46d3db 100644 --- a/ruoyi-ui/src/api/system/node.js +++ b/ruoyi-ui/src/api/system/node.js @@ -1,5 +1,14 @@ import request from '@/utils/request' + +// 查询根节点名字 +export function listRootName() { + return request({ + url: '/system/node/listRootName', + method: 'get' + }) +} + // 查询节点维护列表 export function listNode(query) { return request({ @@ -9,6 +18,15 @@ export function listNode(query) { }) } +// 根据节点名称查询列表以children形式展示 +export function listNodeWithChildren(query) { + return request({ + url: '/system/node/listWithChildren', + method: 'get', + params: query + }) +} + // 查询节点维护详细 export function getNode(id) { return request({ @@ -26,6 +44,15 @@ export function addNode(data) { }) } +// 新增多个节点维护 +export function addMultipleNode(data) { + return request({ + url: '/system/node/addMultiple', + method: 'post', + data: data + }) +} + // 修改节点维护 export function updateNode(data) { return request({ @@ -50,4 +77,4 @@ export function exportNode(query) { method: 'get', params: query }) -} \ No newline at end of file +} diff --git a/ruoyi-ui/src/views/show/Charts.vue b/ruoyi-ui/src/views/show/Charts.vue new file mode 100644 index 000000000..709ac25c3 --- /dev/null +++ b/ruoyi-ui/src/views/show/Charts.vue @@ -0,0 +1,316 @@ + + + diff --git a/ruoyi-ui/src/views/show/Keywords.vue b/ruoyi-ui/src/views/show/Keywords.vue new file mode 100644 index 000000000..c85dd9275 --- /dev/null +++ b/ruoyi-ui/src/views/show/Keywords.vue @@ -0,0 +1,173 @@ + + + diff --git a/ruoyi-ui/src/views/show/index.vue b/ruoyi-ui/src/views/show/index.vue new file mode 100644 index 000000000..bcff8594a --- /dev/null +++ b/ruoyi-ui/src/views/show/index.vue @@ -0,0 +1,158 @@ + + + diff --git a/ruoyi-ui/src/views/show/mock.js b/ruoyi-ui/src/views/show/mock.js new file mode 100644 index 000000000..394e1c662 --- /dev/null +++ b/ruoyi-ui/src/views/show/mock.js @@ -0,0 +1,459 @@ +/** + * 图谱数据源 + */ +export const data = [ + { + id: 10000, + name: '盗墓笔记重启[南派三叔所著小说]', + categary: '百科', + children: [ + { + id: 2, + name: '盗墓笔记重启', + categary: '中文名称', + }, + { + id: 3, + name: '南派三叔', + categary: '作者', + children: [ + { + id: 301, + name: '企业家', + categary: '职业', + children: [ + { + id: 30101, + name: '冒险家,创新者', + categary: '特征', + }, + { + id: 30102, + name: '掌控者,领导者', + categary: '企业角色', + }, + { + id: 30103, + name: 'entrepreneur', + categary: '外文名', + } + ] + }, + { + id: 302, + name: '南派三叔', + categary: '别名', + }, + { + id: 303, + name: '浙江省嘉兴市嘉善县', + categary: '出生地', + }, + { + id: 304, + name: '第七届中国作家富豪榜最佳冒险小说奖', + categary: '主要成就', + } + ], + }, + { + id: 4, + name: '悬疑', + categary: '类型', + }, + { + id: 5, + name: '悬疑', + categary: '连载状态', + }, + { + id: 6, + name: '连载平台', + categary: '个人微信公众号和互联网上', + }, + { + id: 7, + name: '最新章节', + categary: '重启·极海听雷第两百二十四章结局了', + }, + { + id: 8, + name: '小说主角', + categary: '吴邪、胖子、张起灵', + }, + { + id: 9, + name: '连载状态', + categary: '连载中', + } + ] + }, + { + id: 20000, + name: '人工智能', + categary: '百科', + children: [{ + "id": 1599811251651, + "name": "人工智能", + "categary": "中文名", + "children": [{ + "id": 1599811494936, + "name": "YaoMing", + "categary": "外文名" + }, { + "id": 1599811494937, + "name": "明王", + "categary": "别名" + }, { + "id": 1599811494938, + "name": "移动长城", + "categary": "别名" + }, { + "id": 1599811494939, + "name": "小巨人", + "categary": "别名" + }, { + "id": 1599811494930, + "name": "大姚", + "categary": "别名" + }, { + "id": 1599811494931, + "name": "中国", + "categary": "国籍" + }, { + "id": 1599811494932, + "name": "汉族", + "categary": "民族" + }] + }, { + "id": 1599811251652, + "name": "ARTIFICIALINTELLIGENCE", + "categary": "外文名" + }, { + "id": 1599811251653, + "name": "AI", + "categary": "简称" + }, { + "id": 1599811251654, + "name": "1956年", + "categary": "提出时间" + }, { + "id": 1599811251655, + "name": "DARTMOUTH学会", + "categary": "提出地点" + }, { + "id": 1599811251656, + "name": "雨果·德·加里斯的著作", + "categary": "名称来源" + }] + }, + { + id: 30000, + name: '姚明[亚洲篮球联合会主席、中国篮球协会主席]', + categary: '百科', + children: [{ + "id": 1599811494936, + "name": "YaoMing", + "categary": "外文名" + }, { + "id": 1599811494937, + "name": "明王", + "categary": "别名" + }, { + "id": 1599811494938, + "name": "移动长城", + "categary": "别名" + }, { + "id": 1599811494939, + "name": "小巨人", + "categary": "别名" + }, { + "id": 1599811494930, + "name": "大姚", + "categary": "别名" + }, { + "id": 1599811494931, + "name": "中国", + "categary": "国籍" + }, { + "id": 1599811494932, + "name": "汉族", + "categary": "民族" + }] + }, + { + id: 40000, + name: '知识图谱', + categary: '百科', + children: [{ + "id": 1599813559392, + "name": "知识图谱", + "categary": "中文名" + }, { + "id": 1599813559393, + "name": "KnowledgeGraph/Vault", + "categary": "外文名" + }, { + "id": 1599813559394, + "name": "科学知识图谱", + "categary": "也称" + }, { + "id": 1599813559395, + "name": "理论与方法与计量学引文分析", + "categary": "应用" + }] + }, + { + id: 50000, + name: '刘德华[中国香港男演员、歌手、制片人、填词人]', + categary: '百科', + children: [{ + "id": 1599813694131, + "name": "AndyLau,LauTakWah", + "categary": "外文名" + }, { + "id": 1599813694132, + "name": "华仔,华Dee,华哥等", + "categary": "别名" + }, { + "id": 1599813694133, + "name": "中国", + "categary": "国籍" + }, { + "id": 1599813694134, + "name": "汉族", + "categary": "民族" + }, { + "id": 1599813694135, + "name": "天秤座", + "categary": "星座" + }, { + "id": 1599813694136, + "name": "AB型", + "categary": "血型" + }, { + "id": 1599813694137, + "name": "174cm", + "categary": "身高" + }, { + "id": 1599813694138, + "name": "63kg", + "categary": "体重" + }] + }, + { + id: 60000, + name: '番茄[茄科茄属植物]', + categary: '百科', + children: [{ + "id": 1599813839207, + "name": "Solanumlycopersicum", + "categary": "拉丁学名" + }, { + "id": 1599813839208, + "name": "蕃柿、西红柿、洋柿子", + "categary": "别称" + }, { + "id": 1599813839209, + "name": "植物界", + "categary": "界" + }, { + "id": 1599813839210, + "name": "被子植物门", + "categary": "门" + }, { + "id": 1599813839211, + "name": "双子叶植物纲", + "categary": "纲" + }, { + "id": 1599813839212, + "name": "合瓣花亚纲", + "categary": "亚纲" + }, { + "id": 1599813839213, + "name": "管状花目", + "categary": "目" + }, { + "id": 1599813839214, + "name": "茄科", + "categary": "科" + }] + }, + { + id: 70000, + name: '周杰伦', + categary: '百科', + children: [{ + "id": 1599813927218, + "name": "JayChou", + "categary": "外文名" + }, { + "id": 1599813927219, + "name": "周董", + "categary": "别名" + }, { + "id": 1599813927220, + "name": "中国", + "categary": "国籍" + }, { + "id": 1599813927221, + "name": "汉族", + "categary": "民族" + }, { + "id": 1599813927222, + "name": "摩羯座", + "categary": "星座" + }, { + "id": 1599813927223, + "name": "O型", + "categary": "血型" + }, { + "id": 1599813927224, + "name": "175cm", + "categary": "身高" + }, { + "id": 1599813927225, + "name": "台湾省新北市", + "categary": "出生地" + }] + }, + { + id: 80000, + name: '苏州大学', + categary: '百科', + children: [{ + "id": 1599813971854, + "name": "SoochowUniversity", + "categary": "外文名" + }, { + "id": 1599813971855, + "name": "苏大", + "categary": "简称" + }, { + "id": 1599813971856, + "name": "1900年5月18日(清光绪二十六年)", + "categary": "创办时间" + }, { + "id": 1599813971857, + "name": "公立大学", + "categary": "类别" + }, { + "id": 1599813971858, + "name": "综合类", + "categary": "类型" + }, { + "id": 1599813971859, + "name": "211工程", + "categary": "属性" + }, { + "id": 1599813971860, + "name": "省部共建大学", + "categary": "属性" + }, { + "id": 1599813971861, + "name": "卓越工程师教育培养计划", + "categary": "属性" + }] + }, + { + id: 90000, + name: '机器人[自动执行工作的机器装置]', + categary: '百科', + children: [{ + "id": 1599814026913, + "name": "Robot", + "categary": "外文名" + }, { + "id": 1599814026914, + "name": "自动执行工作的机器装置", + "categary": "定义" + }, { + "id": 1599814026915, + "name": "人工智能技术", + "categary": "技术" + }, { + "id": 1599814026916, + "name": "微型计算机", + "categary": "驱动装置" + }, { + "id": 1599814026917, + "name": "电能", + "categary": "驱动能源" + }] + } + +] + +/** + * 模糊查询大类 + * @param {*} name + */ +export const search = (name) => { + return new Promise((resolve, reject) => { + let result = [] + let list = data.filter(item => item.name.indexOf(name) >= 0) + if (list && list.length > 0) { + result = list || [] + } + if (result.length > 0) { + resolve(result) + } else { + reject() + } + }) +} + +/** + * 点击节点展开 + * @param {*} id + */ +export const expendNodes = (id) => { + return new Promise((resolve, reject) => { + let totalList = [] + //拆除来所有的children到第一层 + data.forEach(item => { + getDeepChildrens(totalList, item, 0) + }) + + let list = [] + for (let item of totalList) { + if (item.parentId.toString() === id) { + const {children, ...reset} = item + list.push({ + ...reset + }) + } + } + if (list.length > 0) { + resolve(list) + } else { + reject() + } + + }) +} + +/** + * 递归数组,把所有children都拆出来到第一层 + * @param {*} list + * @param {*} item + */ +function getDeepChildrens(list, item, parentId) { + const {children, ...reset} = item + list.push( + { + ...reset, + parentId, + } + ) + if (children && children.length > 0) { + children.forEach(child => { + getDeepChildrens(list, child, item.id) + }) + } +} + +/** + * 分类数据 + */ +export const categarys = ["人工智能", "知识图谱", "姚明", "刘德华", "机器人", "周杰伦", "苏州大学", "番茄", "盗墓笔记", "机器人", "人工智能", "知识图谱", "姚明", "刘德华", "机器人", "人工智能", "知识图谱", "姚明", "刘德华", "机器人", "人工智能", "知识图谱", "姚明", "刘德华", "机器人", "人工智能", "知识图谱", "姚明", "刘德华", "机器人"] diff --git a/ruoyi-ui/src/views/system/node/index - 副本.vue b/ruoyi-ui/src/views/system/node/index - 副本.vue new file mode 100644 index 000000000..4891d5388 --- /dev/null +++ b/ruoyi-ui/src/views/system/node/index - 副本.vue @@ -0,0 +1,293 @@ + + + diff --git a/ruoyi-ui/src/views/system/node/index.vue b/ruoyi-ui/src/views/system/node/index.vue index 4353de078..622422883 100644 --- a/ruoyi-ui/src/views/system/node/index.vue +++ b/ruoyi-ui/src/views/system/node/index.vue @@ -13,6 +13,7 @@ - 搜索 + 搜索 重置 @@ -43,7 +44,8 @@ size="mini" @click="handleAdd" v-hasPermi="['system:node:add']" - >新增 + >新增 + @@ -52,13 +54,12 @@ v-loading="loading" :data="nodeList" row-key="id" - default-expand-all :tree-props="{children: 'children', hasChildren: 'hasChildren'}" > - - - - + + + + @@ -90,13 +102,13 @@ - + - + - + + + + + + + + + + + + + + + + +