mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 10:13:28 +08:00
修改一些细节
This commit is contained in:
parent
ae96037d2f
commit
78a0d8429a
@ -62,8 +62,10 @@ public class TestNodeController extends BaseController {
|
|||||||
@GetMapping("/listWithChildren")
|
@GetMapping("/listWithChildren")
|
||||||
public AjaxResult listWithChildren(String nodeName) {
|
public AjaxResult listWithChildren(String nodeName) {
|
||||||
List<TestNode> nodeList = iTestNodeService.queryListWithChildren(nodeName);
|
List<TestNode> nodeList = iTestNodeService.queryListWithChildren(nodeName);
|
||||||
|
|
||||||
if (nodeList == null) {
|
if (nodeList == null) {
|
||||||
return AjaxResult.error("查询无果");
|
List<TestNode> list = iTestNodeService.queryListWithSizhi(nodeName);
|
||||||
|
return AjaxResult.success(list);
|
||||||
} else {
|
} else {
|
||||||
return AjaxResult.success(nodeList);
|
return AjaxResult.success(nodeList);
|
||||||
}
|
}
|
||||||
@ -75,9 +77,9 @@ public class TestNodeController extends BaseController {
|
|||||||
@ApiOperation("查询节点维护列表")
|
@ApiOperation("查询节点维护列表")
|
||||||
@PreAuthorize("@ss.hasPermi('system:node:list')")
|
@PreAuthorize("@ss.hasPermi('system:node:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult<List<TestNodeVo>> list(@Validated TestNodeBo bo) {
|
public AjaxResult list(@Validated TestNode node) {
|
||||||
List<TestNodeVo> list = iTestNodeService.queryList(bo);
|
List<TestNode> list = iTestNodeService.queryLists(node);
|
||||||
return AjaxResult.success(list);
|
return (list != null) ? AjaxResult.success(list) : AjaxResult.error("查询无果");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -216,8 +216,8 @@ swagger:
|
|||||||
version: '版本号: ${ruoyi-vue-plus.version}'
|
version: '版本号: ${ruoyi-vue-plus.version}'
|
||||||
# 作者信息
|
# 作者信息
|
||||||
contact:
|
contact:
|
||||||
name: Lion Li
|
name: qianlan
|
||||||
email: crazylionli@163.com
|
email: 3220857484@qq.com
|
||||||
url: https://gitee.com/JavaLionLi/RuoYi-Vue-Plus
|
url: https://gitee.com/JavaLionLi/RuoYi-Vue-Plus
|
||||||
|
|
||||||
# 防止XSS攻击
|
# 防止XSS攻击
|
||||||
|
|||||||
@ -17,6 +17,13 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.75</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring框架基本的核心工具 -->
|
<!-- Spring框架基本的核心工具 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public class TestNode implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@TableId(value = "id")
|
@TableId(value = "id",type = IdType.INPUT)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -72,4 +72,19 @@ public interface ITestNodeService extends IServicePlus<TestNode, TestNodeVo> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AjaxResult<Void> addMultiple(Map map);
|
AjaxResult<Void> addMultiple(Map map);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 若数据库查询不到,则从第三方接口取得数据,并插入到数据库中
|
||||||
|
* @param nodeName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TestNode> queryListWithSizhi(String nodeName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查出维护列表
|
||||||
|
* @param node 前端传来的搜索条件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<TestNode> queryLists(TestNode node);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.utils.HttpRequestUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||||
@ -15,10 +18,7 @@ import com.ruoyi.system.domain.TestNode;
|
|||||||
import com.ruoyi.system.mapper.TestNodeMapper;
|
import com.ruoyi.system.mapper.TestNodeMapper;
|
||||||
import com.ruoyi.system.service.ITestNodeService;
|
import com.ruoyi.system.service.ITestNodeService;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节点维护Service业务层处理
|
* 节点维护Service业务层处理
|
||||||
@ -37,12 +37,12 @@ public class TestNodeServiceImpl extends ServicePlusImpl<TestNodeMapper, TestNod
|
|||||||
return getVoById(id);
|
return getVoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TestNodeVo> queryList(TestNodeBo bo) {
|
public List<TestNodeVo> queryList(TestNodeBo bo) {
|
||||||
return listVo(buildQueryWrapper(bo));
|
return listVo(buildQueryWrapper(bo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<TestNode> buildQueryWrapper(TestNodeBo bo) {
|
private LambdaQueryWrapper<TestNode> buildQueryWrapper(TestNodeBo bo) {
|
||||||
Map<String, Object> params = bo.getParams();
|
Map<String, Object> params = bo.getParams();
|
||||||
LambdaQueryWrapper<TestNode> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TestNode> lqw = Wrappers.lambdaQuery();
|
||||||
@ -54,6 +54,7 @@ public class TestNodeServiceImpl extends ServicePlusImpl<TestNodeMapper, TestNod
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertByBo(TestNodeBo bo) {
|
public Boolean insertByBo(TestNodeBo bo) {
|
||||||
|
bo.setId(RandomUtil.randomLong(100000000000000l));
|
||||||
TestNode add = BeanUtil.toBean(bo, TestNode.class);
|
TestNode add = BeanUtil.toBean(bo, TestNode.class);
|
||||||
validEntityBeforeSave(add);
|
validEntityBeforeSave(add);
|
||||||
return save(add);
|
return save(add);
|
||||||
@ -91,7 +92,13 @@ public class TestNodeServiceImpl extends ServicePlusImpl<TestNodeMapper, TestNod
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<TestNode> queryListWithChildren(String nodeName) {
|
public List<TestNode> queryListWithChildren(String nodeName) {
|
||||||
List<TestNode> nodeList = testNodeMapper.selectList(new QueryWrapper<TestNode>().like("name", nodeName));
|
List<TestNode> nodeList = null;
|
||||||
|
nodeList = testNodeMapper.selectList(new QueryWrapper<TestNode>()
|
||||||
|
.eq("name", nodeName).eq("pid", 0));
|
||||||
|
if (nodeList.size() == 0) {
|
||||||
|
nodeList = testNodeMapper.selectList(new QueryWrapper<TestNode>().like("name", nodeName));
|
||||||
|
}
|
||||||
|
|
||||||
if (nodeList.size() == 0) {
|
if (nodeList.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -141,6 +148,7 @@ public class TestNodeServiceImpl extends ServicePlusImpl<TestNodeMapper, TestNod
|
|||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < nameArray.length; i++) {
|
for (int i = 0; i < nameArray.length; i++) {
|
||||||
TestNode testNode = new TestNode();
|
TestNode testNode = new TestNode();
|
||||||
|
testNode.setId(RandomUtil.randomLong(100000000000000l));
|
||||||
testNode.setName(nameArray[i]);
|
testNode.setName(nameArray[i]);
|
||||||
testNode.setCategary(categaryArray[i]);
|
testNode.setCategary(categaryArray[i]);
|
||||||
testNode.setPid(pid);
|
testNode.setPid(pid);
|
||||||
@ -154,6 +162,7 @@ public class TestNodeServiceImpl extends ServicePlusImpl<TestNodeMapper, TestNod
|
|||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < nameArray.length; i++) {
|
for (int i = 0; i < nameArray.length; i++) {
|
||||||
TestNode testNode = new TestNode();
|
TestNode testNode = new TestNode();
|
||||||
|
testNode.setId(RandomUtil.randomLong(100000000000000l));
|
||||||
testNode.setName(nameArray[i]);
|
testNode.setName(nameArray[i]);
|
||||||
testNode.setPid(pid);
|
testNode.setPid(pid);
|
||||||
testNodeMapper.insert(testNode);
|
testNodeMapper.insert(testNode);
|
||||||
@ -166,4 +175,77 @@ public class TestNodeServiceImpl extends ServicePlusImpl<TestNodeMapper, TestNod
|
|||||||
return AjaxResult.error("添加失败");
|
return AjaxResult.error("添加失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 若数据库查询不到,则从第三方接口取得数据,并插入到数据库中
|
||||||
|
*
|
||||||
|
* @param nodeName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TestNode> queryListWithSizhi(String nodeName) {
|
||||||
|
long id = RandomUtil.randomLong(100000000000000l);
|
||||||
|
TestNode testNode = new TestNode();
|
||||||
|
testNode.setName(nodeName);
|
||||||
|
testNode.setId(id);
|
||||||
|
testNode.setPid(0l);
|
||||||
|
testNodeMapper.insert(testNode);
|
||||||
|
|
||||||
|
List<Object[]> list = HttpRequestUtils.testHutoolGet("https://api.ownthink.com/kg/knowledge?entity=", nodeName);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (Object[] strings : list) {
|
||||||
|
TestNode node = new TestNode();
|
||||||
|
node.setId(RandomUtil.randomLong(100000000000000l));
|
||||||
|
node.setName((String) strings[1]);
|
||||||
|
node.setCategary((String) strings[0]);
|
||||||
|
node.setPid(id);
|
||||||
|
testNodeMapper.insert(node);
|
||||||
|
count++;
|
||||||
|
if (count > 20) break;
|
||||||
|
}
|
||||||
|
return queryListWithChildren(nodeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查出维护列表
|
||||||
|
*
|
||||||
|
* @param node 前端传来的搜索条件
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<TestNode> queryLists(TestNode node) {
|
||||||
|
if (node.getName() == null && node.getCategary() == null && node.getPid() == null) {
|
||||||
|
return testNodeMapper.selectList(null);
|
||||||
|
}
|
||||||
|
Queue<Long> q = new LinkedList<>(); //初始化一个队列
|
||||||
|
LambdaQueryWrapper<TestNode> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.like(StrUtil.isNotBlank(node.getName()), TestNode::getName, node.getName());
|
||||||
|
lqw.eq(StrUtil.isNotBlank(node.getCategary()), TestNode::getCategary, node.getCategary());
|
||||||
|
lqw.eq(node.getPid() != null, TestNode::getPid, node.getPid());
|
||||||
|
List<TestNode> nodeList = testNodeMapper.selectList(lqw);
|
||||||
|
if (nodeList.size() == 0) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
for (TestNode testNode : nodeList) {
|
||||||
|
q.offer(testNode.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
//循环队列,bfs算法,查出所有子节点
|
||||||
|
while (!q.isEmpty()) {
|
||||||
|
for (int i = 0; i < q.size(); i++) {
|
||||||
|
Long cur = q.poll();
|
||||||
|
List<TestNode> nodeLists = testNodeMapper.selectList(new QueryWrapper<TestNode>().eq("pid", cur));
|
||||||
|
if (nodeLists.size() != 0) {
|
||||||
|
for (TestNode list : nodeLists) {
|
||||||
|
q.offer(list.getId());
|
||||||
|
nodeList.add(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,7 @@
|
|||||||
"vue": "2.6.12",
|
"vue": "2.6.12",
|
||||||
"vue-count-to": "1.0.13",
|
"vue-count-to": "1.0.13",
|
||||||
"vue-cropper": "0.5.5",
|
"vue-cropper": "0.5.5",
|
||||||
|
"vue-lazyload": "^1.3.3",
|
||||||
"vue-meta": "^2.4.0",
|
"vue-meta": "^2.4.0",
|
||||||
"vue-router": "3.4.9",
|
"vue-router": "3.4.9",
|
||||||
"vuedraggable": "2.24.3",
|
"vuedraggable": "2.24.3",
|
||||||
|
|||||||
@ -16,7 +16,15 @@ import './assets/icons' // icon
|
|||||||
import './permission' // permission control
|
import './permission' // permission control
|
||||||
import {getDicts} from "@/api/system/dict/data";
|
import {getDicts} from "@/api/system/dict/data";
|
||||||
import {getConfigKey} from "@/api/system/config";
|
import {getConfigKey} from "@/api/system/config";
|
||||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
|
import {
|
||||||
|
parseTime,
|
||||||
|
resetForm,
|
||||||
|
addDateRange,
|
||||||
|
selectDictLabel,
|
||||||
|
selectDictLabels,
|
||||||
|
download,
|
||||||
|
handleTree
|
||||||
|
} from "@/utils/ruoyi";
|
||||||
import Pagination from "@/components/Pagination";
|
import Pagination from "@/components/Pagination";
|
||||||
// 自定义表格工具组件
|
// 自定义表格工具组件
|
||||||
import RightToolbar from "@/components/RightToolbar"
|
import RightToolbar from "@/components/RightToolbar"
|
||||||
@ -30,6 +38,8 @@ import ImageUpload from "@/components/ImageUpload"
|
|||||||
import DictTag from '@/components/DictTag'
|
import DictTag from '@/components/DictTag'
|
||||||
// 头部标签组件
|
// 头部标签组件
|
||||||
import VueMeta from 'vue-meta'
|
import VueMeta from 'vue-meta'
|
||||||
|
// 图片懒加载
|
||||||
|
import VueLazyload from 'vue-lazyload'
|
||||||
|
|
||||||
// 全局方法挂载
|
// 全局方法挂载
|
||||||
Vue.prototype.getDicts = getDicts
|
Vue.prototype.getDicts = getDicts
|
||||||
@ -64,7 +74,10 @@ Vue.component('ImageUpload', ImageUpload)
|
|||||||
|
|
||||||
Vue.use(directive)
|
Vue.use(directive)
|
||||||
Vue.use(VueMeta)
|
Vue.use(VueMeta)
|
||||||
|
Vue.use(VueLazyload, {
|
||||||
|
loading: require('./assets/images/loading.gif'),//加载中图片,一定要有,不然会一直重复加载占位图
|
||||||
|
// error: require('img/error.png') //加载失败图片
|
||||||
|
})
|
||||||
/**
|
/**
|
||||||
* If you don't want to use mock-server
|
* If you don't want to use mock-server
|
||||||
* you want to use MockJs for mock api
|
* you want to use MockJs for mock api
|
||||||
|
|||||||
@ -184,7 +184,6 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
/** 查询节点维护列表 */
|
/** 查询节点维护列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
|
||||||
listNode(this.queryParams).then(response => {
|
listNode(this.queryParams).then(response => {
|
||||||
this.nodeList = this.handleTree(response.data, "id", "pid");
|
this.nodeList = this.handleTree(response.data, "id", "pid");
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user