From e4ce02aa890031531875c51bf0a57489026196b8 Mon Sep 17 00:00:00 2001 From: icanci Date: Wed, 13 Sep 2023 21:16:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BA=8B=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bic/biz/service/impl/NodeServiceImpl.java | 8 +++ .../loopstack/bic/biz/utils/FileUtils.java | 34 +++++++++++ .../style/default-edge-style-template.json | 31 ++++++++++ .../style/default-node-style-template.json | 59 +++++++++++++++++++ .../style/demo-edge-style-template.json | 31 ++++++++++ .../style/demo-node-style-template.json | 59 +++++++++++++++++++ views/pom.xml | 1 + .../vueboot/src/views/bic-burying/burying.vue | 2 +- .../views/bic-burying/dialog/burying-form.vue | 2 +- .../src/views/bic-config/dialog/node-form.vue | 2 +- .../views/bic-config/dialog/use-case-form.vue | 2 +- .../src/views/bic-config/node-config.vue | 2 +- .../src/views/bic-config/use-case-config.vue | 2 +- .../config/MongoTransactionConfiguration.java | 19 ++++++ 14 files changed, 248 insertions(+), 6 deletions(-) create mode 100644 biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/FileUtils.java create mode 100644 biz/src/main/resources/style/default-edge-style-template.json create mode 100644 biz/src/main/resources/style/default-node-style-template.json create mode 100644 biz/src/main/resources/style/demo-edge-style-template.json create mode 100644 biz/src/main/resources/style/demo-node-style-template.json create mode 100644 web/src/main/java/cn/icanci/loopstack/bic/web/config/MongoTransactionConfiguration.java diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeServiceImpl.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeServiceImpl.java index c92aaca..ccf25aa 100644 --- a/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeServiceImpl.java +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeServiceImpl.java @@ -6,6 +6,7 @@ import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import com.google.common.collect.Lists; @@ -34,11 +35,18 @@ public class NodeServiceImpl implements NodeService { } @Override + @Transactional(rollbackFor = Exception.class) public void save(NodeVO nodeVO) { // TODO 日志记录 + // TODO 事务插入 测试 if (doInsert(nodeVO)) { NodeDO insert = nodeMapper.vo2do(nodeVO); nodeDAO.insert(insert); + + // TODO + // 插入样式 + // 插入组件函数 + } else { nodeDAO.update(nodeMapper.vo2do(nodeVO)); } diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/FileUtils.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/FileUtils.java new file mode 100644 index 0000000..6df4e7b --- /dev/null +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/FileUtils.java @@ -0,0 +1,34 @@ +package cn.icanci.loopstack.bic.biz.utils; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.InputStream; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 09:33 + */ +public class FileUtils { + + /** + * queryMockFile + * + * @return queryMockFile + */ + protected String queryLocalFile(String fileName) { + String fr2Json = null; + try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) { + File file = new File(fileName); + InputStream inputStream = file.toURI().toURL().openConnection().getInputStream(); + byte[] buffer = new byte[1024]; + int len; + while ((len = inputStream.read(buffer)) != -1) { + byteArrayOutputStream.write(buffer, 0, len); + } + fr2Json = byteArrayOutputStream.toString(); + inputStream.close(); + } catch (Exception ignore) { + } + return fr2Json; + } +} diff --git a/biz/src/main/resources/style/default-edge-style-template.json b/biz/src/main/resources/style/default-edge-style-template.json new file mode 100644 index 0000000..0faeb86 --- /dev/null +++ b/biz/src/main/resources/style/default-edge-style-template.json @@ -0,0 +1,31 @@ +{ + "attrs": { + "line": { + "stroke": "#7c68fc", + "strokeWidth": 2 + } + }, + "router": "manhattan", + "connector": "normal", + "labels": [], + "consumerInfo": { + "attrs": { + "line": { + "stroke": "red", + "strokeWidth": 5 + } + }, + "labels": [ + { + "attrs": { + "label": { + "text": "${hoverName}" + } + }, + "position": { + "distance": 0.8 + } + } + ] + } +} \ No newline at end of file diff --git a/biz/src/main/resources/style/default-node-style-template.json b/biz/src/main/resources/style/default-node-style-template.json new file mode 100644 index 0000000..e0f6920 --- /dev/null +++ b/biz/src/main/resources/style/default-node-style-template.json @@ -0,0 +1,59 @@ +{ + "id": "${nodeId}", + "shape": "circle", + "width": 50, + "height": 50, + "attrs": { + "body": { + "fill": "#F39C12", + "stroke": "#000", + "rx": 16, + "ry": 16 + }, + "label": { + "text": "${nodeName}", + "fill": "#333", + "fontSize": 18, + "fontWeight": "bold", + "fontVariant": "small-caps" + } + }, + "ports": { + "groups": { + "in": { + "position": "left", + "attrs": { + "circle": { + "r": 2, + "magnet": true, + "stroke": "#31d0c6", + "strokeWidth": 2, + "fill": "#fff" + } + } + }, + "out": { + "position": "right", + "attrs": { + "circle": { + "r": 2, + "magnet": true, + "stroke": "#31d0c6", + "strokeWidth": 2, + "fill": "#fff" + } + } + } + }, + "items": [ + { + "id": "port-left", + "group": "in" + }, + { + "id": "port-right", + "group": "out" + } + ] + } +} \ No newline at end of file diff --git a/biz/src/main/resources/style/demo-edge-style-template.json b/biz/src/main/resources/style/demo-edge-style-template.json new file mode 100644 index 0000000..426101f --- /dev/null +++ b/biz/src/main/resources/style/demo-edge-style-template.json @@ -0,0 +1,31 @@ +{ + "attrs": { + "line": { + "stroke": "#7c68fc", + "strokeWidth": 2 + } + }, + "router": "manhattan", + "connector": "normal", + "labels": [], + "consumerInfo": { + "attrs": { + "line": { + "stroke": "red", + "strokeWidth": 5 + } + }, + "labels": [ + { + "attrs": { + "label": { + "text": "RPC调用" + } + }, + "position": { + "distance": 0.8 + } + } + ] + } +} \ No newline at end of file diff --git a/biz/src/main/resources/style/demo-node-style-template.json b/biz/src/main/resources/style/demo-node-style-template.json new file mode 100644 index 0000000..d86b322 --- /dev/null +++ b/biz/src/main/resources/style/demo-node-style-template.json @@ -0,0 +1,59 @@ +{ + "id": "${id}", + "shape": "circle", + "width": 50, + "height": 50, + "attrs": { + "body": { + "fill": "#F39C12", + "stroke": "#000", + "rx": 16, + "ry": 16 + }, + "label": { + "text": "下单", + "fill": "#333", + "fontSize": 18, + "fontWeight": "bold", + "fontVariant": "small-caps" + } + }, + "ports": { + "groups": { + "in": { + "position": "left", + "attrs": { + "circle": { + "r": 2, + "magnet": true, + "stroke": "#31d0c6", + "strokeWidth": 2, + "fill": "#fff" + } + } + }, + "out": { + "position": "right", + "attrs": { + "circle": { + "r": 2, + "magnet": true, + "stroke": "#31d0c6", + "strokeWidth": 2, + "fill": "#fff" + } + } + } + }, + "items": [ + { + "id": "port-left", + "group": "in" + }, + { + "id": "port-right", + "group": "out" + } + ] + } +} \ No newline at end of file diff --git a/views/pom.xml b/views/pom.xml index 713205d..62fca08 100644 --- a/views/pom.xml +++ b/views/pom.xml @@ -138,6 +138,7 @@ **/*.yml **/*.xml **/*.properties + **/*.json vueboot/** diff --git a/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue b/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue index f1924e8..58d0bc4 100644 --- a/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue +++ b/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue @@ -18,7 +18,7 @@ - + - + - + - + - + - + Date: Thu, 14 Sep 2023 00:20:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?node=20style=20=E6=A8=A1=E5=9D=97=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bic/biz/mapper/NodeStyleMapper.java | 15 ++ .../bic/biz/service/NodeStyleService.java | 31 +++ .../service/impl/NodeStyleServiceImpl.java | 92 +++++++++ .../bic/common/model/base/NodeStyleVO.java | 6 +- .../dal/mongo/daointerface/NodeStyleDAO.java | 26 +++ .../bic/dal/mongo/dateobject/NodeStyleDO.java | 19 ++ .../dal/mongo/mongo/MongoNodeStyleDAO.java | 93 +++++++++ .../vueboot/src/api/loadSelectorApi.js | 11 ++ .../resources/vueboot/src/api/nodeStyle.js | 34 ++++ .../vueboot/src/views/bic-burying/burying.vue | 38 +++- .../bic-config/dialog/node-style-form.vue | 165 ++++++++++++++++ .../views/bic-config/node-style-config.vue | 180 +++++++++++++++++- .../web/controller/NodeStyleController.java | 63 ++++++ .../bic/web/form/NodeStyleQueryForm.java | 13 ++ .../bic/web/mapper/NodeStyleWebMapper.java | 16 ++ .../loopstack/bic/web/model/NodeStyle.java | 19 ++ 16 files changed, 801 insertions(+), 20 deletions(-) create mode 100644 biz/src/main/java/cn/icanci/loopstack/bic/biz/mapper/NodeStyleMapper.java create mode 100644 biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java create mode 100644 biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java create mode 100644 dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/daointerface/NodeStyleDAO.java create mode 100644 dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/dateobject/NodeStyleDO.java create mode 100644 dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/mongo/MongoNodeStyleDAO.java create mode 100644 views/src/main/resources/vueboot/src/api/nodeStyle.js create mode 100644 views/src/main/resources/vueboot/src/views/bic-config/dialog/node-style-form.vue create mode 100644 web/src/main/java/cn/icanci/loopstack/bic/web/controller/NodeStyleController.java create mode 100644 web/src/main/java/cn/icanci/loopstack/bic/web/form/NodeStyleQueryForm.java create mode 100644 web/src/main/java/cn/icanci/loopstack/bic/web/mapper/NodeStyleWebMapper.java create mode 100644 web/src/main/java/cn/icanci/loopstack/bic/web/model/NodeStyle.java diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/mapper/NodeStyleMapper.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/mapper/NodeStyleMapper.java new file mode 100644 index 0000000..05ac401 --- /dev/null +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/mapper/NodeStyleMapper.java @@ -0,0 +1,15 @@ +package cn.icanci.loopstack.bic.biz.mapper; + +import org.mapstruct.Mapper; +import org.mapstruct.NullValueMappingStrategy; + +import cn.icanci.loopstack.bic.common.model.base.NodeStyleVO; +import cn.icanci.loopstack.bic.dal.mongo.dateobject.NodeStyleDO; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 23:10 + */ +@Mapper(componentModel = "spring", nullValueMappingStrategy = NullValueMappingStrategy.RETURN_NULL) +public interface NodeStyleMapper extends BaseMapper { +} diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java new file mode 100644 index 0000000..c202933 --- /dev/null +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java @@ -0,0 +1,31 @@ +package cn.icanci.loopstack.bic.biz.service; + +import java.util.List; + +import cn.icanci.loopstack.bic.common.model.TextValue; +import cn.icanci.loopstack.bic.common.model.base.NodeStyleVO; +import cn.icanci.loopstack.bic.dal.mongo.common.PageList; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 22:44 + */ +public interface NodeStyleService extends BaseService { + @Override + List queryAll(); + + @Override + void save(NodeStyleVO nodeStyleVO); + + @Override + NodeStyleVO queryById(String id); + + @Override + PageList queryPage(NodeStyleVO nodeStyleVO, int pageNum, int pageSize); + + NodeStyleVO queryBySystemUuidAndName(String systemUuid, String name); + + NodeStyleVO queryBySystemUuidAndKey(String systemUuid, String key); + + List loadSelector(String systemUuid); +} diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java new file mode 100644 index 0000000..cad4928 --- /dev/null +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java @@ -0,0 +1,92 @@ +package cn.icanci.loopstack.bic.biz.service.impl; + +import java.util.List; + +import javax.annotation.Resource; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import com.google.common.collect.Lists; + +import cn.icanci.loopstack.bic.biz.mapper.NodeStyleMapper; +import cn.icanci.loopstack.bic.biz.service.NodeStyleService; +import cn.icanci.loopstack.bic.common.model.TextValue; +import cn.icanci.loopstack.bic.common.model.base.NodeStyleVO; +import cn.icanci.loopstack.bic.dal.mongo.common.PageList; +import cn.icanci.loopstack.bic.dal.mongo.daointerface.NodeStyleDAO; +import cn.icanci.loopstack.bic.dal.mongo.dateobject.NodeStyleDO; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 22:45 + */ +@Service +public class NodeStyleServiceImpl implements NodeStyleService { + + @Resource + private NodeStyleDAO nodeStyleDAO; + @Resource + private NodeStyleMapper nodeStyleMapper; + + @Override + public List queryAll() { + return nodeStyleMapper.dos2vos(nodeStyleDAO.queryAll()); + } + + @Override + public void save(NodeStyleVO nodeStyleVO) { + // TODO 日志记录 + // TODO 更新视图 + if (doInsert(nodeStyleVO)) { + NodeStyleDO insert = nodeStyleMapper.vo2do(nodeStyleVO); + nodeStyleDAO.insert(insert); + } else { + nodeStyleDAO.update(nodeStyleMapper.vo2do(nodeStyleVO)); + } + } + + @Override + public NodeStyleVO queryById(String id) { + return nodeStyleMapper.do2vo(nodeStyleDAO.queryOneById(id)); + } + + @Override + public PageList queryPage(NodeStyleVO nodeStyleVO, int pageNum, int pageSize) { + PageList pageQuery = nodeStyleDAO.pageQuery(nodeStyleMapper.vo2do(nodeStyleVO), pageNum, pageSize); + return new PageList<>(nodeStyleMapper.dos2vos(pageQuery.getData()), pageQuery.getPaginator()); + + } + + @Override + public NodeStyleVO queryBySystemUuidAndName(String systemUuid, String name) { + return nodeStyleMapper.do2vo(nodeStyleDAO.queryBySystemUuidAndName(systemUuid, name)); + } + + @Override + public NodeStyleVO queryBySystemUuidAndKey(String systemUuid, String key) { + return nodeStyleMapper.do2vo(nodeStyleDAO.queryBySystemUuidAndKey(systemUuid, key)); + } + + @Override + public List loadSelector(String systemUuid) { + List nodeStyles = queryAll(); + List textValues = Lists.newArrayList(); + for (NodeStyleVO nodeStyle : nodeStyles) { + + if (!StringUtils.equals(systemUuid, nodeStyle.getSystemUuid())) { + continue; + } + + String label; + if (isDeleted(nodeStyle)) { + label = String.format(DELETED_FORMAT, nodeStyle.getNodeStyleName()); + } else { + label = String.format(NOT_DELETED_FORMAT, nodeStyle.getNodeStyleName()); + } + String value = nodeStyle.getUuid(); + textValues.add(new TextValue(label, value)); + } + return textValues; + } +} diff --git a/common/src/main/java/cn/icanci/loopstack/bic/common/model/base/NodeStyleVO.java b/common/src/main/java/cn/icanci/loopstack/bic/common/model/base/NodeStyleVO.java index dc5a398..10ec939 100644 --- a/common/src/main/java/cn/icanci/loopstack/bic/common/model/base/NodeStyleVO.java +++ b/common/src/main/java/cn/icanci/loopstack/bic/common/model/base/NodeStyleVO.java @@ -11,8 +11,12 @@ import lombok.Data; */ @Data public class NodeStyleVO extends BaseVO { + /** 系统边节点样式 */ + private String systemUuid; /** 节点样式名称 */ private String nodeStyleName; + /** 节点样式Key */ + private String nodeStyleKey; /** json格式的数据格式 */ - private String style; + private String nodeStyle; } diff --git a/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/daointerface/NodeStyleDAO.java b/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/daointerface/NodeStyleDAO.java new file mode 100644 index 0000000..42bd97d --- /dev/null +++ b/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/daointerface/NodeStyleDAO.java @@ -0,0 +1,26 @@ +package cn.icanci.loopstack.bic.dal.mongo.daointerface; + +import cn.icanci.loopstack.bic.dal.mongo.dateobject.NodeStyleDO; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 23:30 + */ +public interface NodeStyleDAO extends BaseDAO { + /** 文档对应的名字 */ + String COLLECTION_NAME = BASE_COLLECTION_NAME + "node-style"; + /** 文档对应的Class */ + Class COLLECTION_CLASS = NodeStyleDO.class; + + NodeStyleDO queryBySystemUuidAndName(String systemUuid, String name); + + NodeStyleDO queryBySystemUuidAndKey(String systemUuid, String key); + + /** 列 */ + interface NodeStyleColumn extends BaseColumn { + String SYSTEM_UUID = "systemUuid"; + String NODE_STYLE_NAME = "nodeStyleName"; + String NODE_STYLE_KEY = "nodeStyleKey"; + String NODE_STYLE = "nodeStyle"; + } +} diff --git a/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/dateobject/NodeStyleDO.java b/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/dateobject/NodeStyleDO.java new file mode 100644 index 0000000..2d99ed2 --- /dev/null +++ b/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/dateobject/NodeStyleDO.java @@ -0,0 +1,19 @@ +package cn.icanci.loopstack.bic.dal.mongo.dateobject; + +import lombok.Data; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 23:30 + */ +@Data +public class NodeStyleDO extends BaseDO { + /** 系统边节点样式 */ + private String systemUuid; + /** 节点样式名称 */ + private String nodeStyleName; + /** 节点样式Key */ + private String nodeStyleKey; + /** json格式的数据格式 */ + private String nodeStyle; +} diff --git a/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/mongo/MongoNodeStyleDAO.java b/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/mongo/MongoNodeStyleDAO.java new file mode 100644 index 0000000..8940655 --- /dev/null +++ b/dal/src/main/java/cn/icanci/loopstack/bic/dal/mongo/mongo/MongoNodeStyleDAO.java @@ -0,0 +1,93 @@ +package cn.icanci.loopstack.bic.dal.mongo.mongo; + +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.domain.Sort; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.stereotype.Service; + +import cn.icanci.loopstack.bic.dal.mongo.common.PageList; +import cn.icanci.loopstack.bic.dal.mongo.daointerface.NodeStyleDAO; +import cn.icanci.loopstack.bic.dal.mongo.dateobject.NodeStyleDO; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 23:32 + */ +@Service("nodeStyleDAO") +public class MongoNodeStyleDAO extends AbstractBaseDAO implements NodeStyleDAO { + @Override + public void insert(NodeStyleDO nodeStyleDO) { + super.insert(nodeStyleDO); + mongoTemplate.insert(nodeStyleDO, COLLECTION_NAME); + } + + @Override + public void update(NodeStyleDO nodeStyleDO) { + super.update(nodeStyleDO); + mongoTemplate.save(nodeStyleDO, COLLECTION_NAME); + } + + @Override + public List queryAll() { + Criteria criteria = Criteria.where(NodeStyleColumn.ENV).is(DEFAULT_ENV); + Query query = new Query(criteria); + return mongoTemplate.find(query, COLLECTION_CLASS, COLLECTION_NAME); + + } + + @Override + public PageList pageQuery(NodeStyleDO nodeStyleDO, int pageNum, int pageSize) { + Criteria criteria = Criteria.where(NodeStyleColumn.ENV).is(DEFAULT_ENV); + if (StringUtils.isNotBlank(nodeStyleDO.getNodeStyleName())) { + // 不分区大小写查询,其中操作符"i":表示不分区大小写 + criteria.and(NodeStyleColumn.NODE_STYLE_NAME).regex("^.*" + nodeStyleDO.getNodeStyleName() + ".*$", "i"); + } + if (StringUtils.isNotBlank(nodeStyleDO.getNodeStyleKey())) { + // 不分区大小写查询,其中操作符"i":表示不分区大小写 + criteria.and(NodeStyleColumn.NODE_STYLE_KEY).regex("^.*" + nodeStyleDO.getNodeStyleKey() + ".*$", "i"); + } + if (StringUtils.isNotBlank(nodeStyleDO.getSystemUuid())) { + criteria.and(NodeStyleColumn.SYSTEM_UUID).is(nodeStyleDO.getSystemUuid()); + } + Query query = new Query(criteria); + query.with(Sort.by(Sort.Direction.DESC, NodeStyleColumn.CREATE_TIME)); + return pageQuery(query, COLLECTION_CLASS, pageSize, pageNum, COLLECTION_NAME); + } + + @Override + public NodeStyleDO queryOneById(String _id) { + Criteria criteria = Criteria.where(NodeStyleColumn._ID).is(_id); + criteria.and(NodeStyleColumn.ENV).is(DEFAULT_ENV); + Query query = new Query(criteria); + return mongoTemplate.findOne(query, COLLECTION_CLASS, COLLECTION_NAME); + + } + + @Override + public Class getBaseColumn() { + return NodeStyleColumn.class; + } + + @Override + public NodeStyleDO queryBySystemUuidAndName(String systemUuid, String name) { + Criteria criteria = Criteria.where(NodeStyleColumn.NODE_STYLE_NAME).is(name); + criteria.and(NodeStyleColumn.ENV).is(DEFAULT_ENV); + criteria.and(NodeStyleColumn.SYSTEM_UUID).is(systemUuid); + Query query = new Query(criteria); + return mongoTemplate.findOne(query, COLLECTION_CLASS, COLLECTION_NAME); + + } + + @Override + public NodeStyleDO queryBySystemUuidAndKey(String systemUuid, String key) { + Criteria criteria = Criteria.where(NodeStyleColumn.NODE_STYLE_KEY).is(key); + criteria.and(NodeStyleColumn.ENV).is(DEFAULT_ENV); + criteria.and(NodeStyleColumn.SYSTEM_UUID).is(systemUuid); + Query query = new Query(criteria); + return mongoTemplate.findOne(query, COLLECTION_CLASS, COLLECTION_NAME); + + } +} diff --git a/views/src/main/resources/vueboot/src/api/loadSelectorApi.js b/views/src/main/resources/vueboot/src/api/loadSelectorApi.js index 0a71f94..37c6caa 100644 --- a/views/src/main/resources/vueboot/src/api/loadSelectorApi.js +++ b/views/src/main/resources/vueboot/src/api/loadSelectorApi.js @@ -78,6 +78,17 @@ export async function nodeSelector(systemUuid) { return [] } +export async function nodestyleSelector(systemUuid) { + let ret = await request({ + url: '/bicAdmin/nodeStyle/loadSelector/' + systemUuid, + method: 'get' + }) + if (ret.ok) { + return ret.data.textValues; + } + return [] +} + export function joiner(arr, join) { let res = "" if (!res && !join) { diff --git a/views/src/main/resources/vueboot/src/api/nodeStyle.js b/views/src/main/resources/vueboot/src/api/nodeStyle.js new file mode 100644 index 0000000..1638ce8 --- /dev/null +++ b/views/src/main/resources/vueboot/src/api/nodeStyle.js @@ -0,0 +1,34 @@ +import request from '@/utils/request' + +export async function nodeStylePageQuery(nodeStyle, paginator) { + return await request({ + url: '/bicAdmin/nodeStyle/query', + method: 'post', + data: { + 'nodeStyle': nodeStyle, + 'paginator': paginator + } + }) +} + +export async function nodeStyleSave(nodeStyle) { + return await request({ + url: '/bicAdmin/nodeStyle/save', + method: 'post', + data: nodeStyle + }) +} + +export async function remoteValidateNodeStyleName(systemUuid, name) { + return await request({ + url: '/bicAdmin/nodeStyle/validateName/' + systemUuid + '/' + name, + method: 'get', + }) +} + +export async function remoteValidatesNodeStyleKey(systemUuid, key) { + return await request({ + url: '/bicAdmin/nodeStyle/validateKey/' + systemUuid + '/' + key, + method: 'get', + }) +} diff --git a/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue b/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue index 58d0bc4..8413763 100644 --- a/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue +++ b/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue @@ -89,8 +89,11 @@ + + + + + diff --git a/views/src/main/resources/vueboot/src/views/bic-config/node-style-config.vue b/views/src/main/resources/vueboot/src/views/bic-config/node-style-config.vue index 52c7649..f704d62 100644 --- a/views/src/main/resources/vueboot/src/views/bic-config/node-style-config.vue +++ b/views/src/main/resources/vueboot/src/views/bic-config/node-style-config.vue @@ -1,24 +1,186 @@ diff --git a/web/src/main/java/cn/icanci/loopstack/bic/web/controller/NodeStyleController.java b/web/src/main/java/cn/icanci/loopstack/bic/web/controller/NodeStyleController.java new file mode 100644 index 0000000..6440688 --- /dev/null +++ b/web/src/main/java/cn/icanci/loopstack/bic/web/controller/NodeStyleController.java @@ -0,0 +1,63 @@ +package cn.icanci.loopstack.bic.web.controller; + +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.web.bind.annotation.*; + +import cn.icanci.loopstack.bic.biz.service.NodeStyleService; +import cn.icanci.loopstack.bic.common.model.TextValue; +import cn.icanci.loopstack.bic.common.model.base.NodeStyleVO; +import cn.icanci.loopstack.bic.common.result.R; +import cn.icanci.loopstack.bic.web.form.NodeStyleQueryForm; +import cn.icanci.loopstack.bic.web.mapper.NodeStyleWebMapper; +import cn.icanci.loopstack.bic.web.model.NodeStyle; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 22:23 + */ +@RestController +@RequestMapping("/bicAdmin/nodeStyle") +public class NodeStyleController { + + @Resource + private NodeStyleWebMapper nodeStyleWebMapper; + @Resource + private NodeStyleService nodeStyleService; + + // ================================ CRUD ================================ + @PostMapping("query") + public R query(@RequestBody NodeStyleQueryForm form) { + return R.builderOk() + .data("queryPage", nodeStyleService.queryPage(nodeStyleWebMapper.web2vo(form.getNodeStyle()), form.getPaginator().getCurrentPage(), form.getPaginator().getPageSize())) + .build(); + } + + @PostMapping("save") + public R save(@RequestBody NodeStyle nodeStyle) { + nodeStyleService.save(nodeStyleWebMapper.web2vo(nodeStyle)); + return R.builderOk().build(); + } + + @GetMapping("validateName/{systemUuid}/{name}") + public R validateName(@PathVariable("systemUuid") String systemUuid, @PathVariable("name") String name) { + NodeStyleVO nodeStyle = nodeStyleService.queryBySystemUuidAndName(systemUuid, name); + return R.builderOk().data("result", nodeStyle == null).build(); + } + + @GetMapping("validateKey/{systemUuid}/{key}") + public R validateKey(@PathVariable("systemUuid") String systemUuid, @PathVariable("key") String key) { + NodeStyleVO nodeStyle = nodeStyleService.queryBySystemUuidAndKey(systemUuid, key); + return R.builderOk().data("result", nodeStyle == null).build(); + } + // ================================ Load Selectors ================================ + + @GetMapping("loadSelector/{systemUuid}") + public R loadSelector(@PathVariable("systemUuid") String systemUuid) { + List textValues = nodeStyleService.loadSelector(systemUuid); + return R.builderOk().data("textValues", textValues).build(); + } + +} diff --git a/web/src/main/java/cn/icanci/loopstack/bic/web/form/NodeStyleQueryForm.java b/web/src/main/java/cn/icanci/loopstack/bic/web/form/NodeStyleQueryForm.java new file mode 100644 index 0000000..2ad5f3f --- /dev/null +++ b/web/src/main/java/cn/icanci/loopstack/bic/web/form/NodeStyleQueryForm.java @@ -0,0 +1,13 @@ +package cn.icanci.loopstack.bic.web.form; + +import cn.icanci.loopstack.bic.web.model.NodeStyle; +import lombok.Data; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/11 11:18 + */ +@Data +public class NodeStyleQueryForm extends BaseQueryForm { + private NodeStyle nodeStyle; +} diff --git a/web/src/main/java/cn/icanci/loopstack/bic/web/mapper/NodeStyleWebMapper.java b/web/src/main/java/cn/icanci/loopstack/bic/web/mapper/NodeStyleWebMapper.java new file mode 100644 index 0000000..d4d2879 --- /dev/null +++ b/web/src/main/java/cn/icanci/loopstack/bic/web/mapper/NodeStyleWebMapper.java @@ -0,0 +1,16 @@ +package cn.icanci.loopstack.bic.web.mapper; + +import org.mapstruct.Mapper; +import org.mapstruct.NullValueMappingStrategy; + +import cn.icanci.loopstack.bic.common.model.base.NodeStyleVO; +import cn.icanci.loopstack.bic.web.model.NodeStyle; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 22:26 + */ +@Mapper(componentModel = "spring", uses = {}, nullValueMappingStrategy = NullValueMappingStrategy.RETURN_NULL) +public interface NodeStyleWebMapper extends BaseWebMapper { + +} diff --git a/web/src/main/java/cn/icanci/loopstack/bic/web/model/NodeStyle.java b/web/src/main/java/cn/icanci/loopstack/bic/web/model/NodeStyle.java new file mode 100644 index 0000000..ad40875 --- /dev/null +++ b/web/src/main/java/cn/icanci/loopstack/bic/web/model/NodeStyle.java @@ -0,0 +1,19 @@ +package cn.icanci.loopstack.bic.web.model; + +import lombok.Data; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 22:05 + */ +@Data +public class NodeStyle extends Base { + /** 系统边节点样式 */ + private String systemUuid; + /** 节点样式名称 */ + private String nodeStyleName; + /** 节点样式Key */ + private String nodeStyleKey; + /** json格式的数据格式 */ + private String nodeStyle; +} -- Gitee From 68a17e6e4ad6c8d3f15757c30d45739bbc813fea Mon Sep 17 00:00:00 2001 From: icanci Date: Thu, 14 Sep 2023 20:31:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?bic=20#=20=E8=8A=82=E7=82=B9Style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bic/biz/service/NodeStyleService.java | 2 + .../service/impl/NodeStyleServiceImpl.java | 6 ++ .../loopstack/bic/biz/utils/FileUtils.java | 34 ---------- .../bic/biz/utils/TemplateFileUtils.java | 44 +++++++++++++ .../bic/biz/utils/TestFileUtils.java | 16 +++++ .../style/default-edge-style-template.json | 31 +++++++++ .../style/default-node-style-template.json | 59 +++++++++++++++++ .../style/demo-edge-style-template.json | 31 +++++++++ .../style/demo-node-style-template.json | 59 +++++++++++++++++ views/src/main/resources/vueboot/package.json | 1 + .../resources/vueboot/src/api/nodeStyle.js | 7 ++ views/src/main/resources/vueboot/src/main.js | 4 ++ .../bic-config/dialog/node-style-form.vue | 65 ++++++++++++++----- .../views/bic-config/node-style-config.vue | 45 ++++++------- .../web/controller/NodeStyleController.java | 6 ++ 15 files changed, 338 insertions(+), 72 deletions(-) delete mode 100644 biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/FileUtils.java create mode 100644 biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/TemplateFileUtils.java create mode 100644 biz/src/test/java/cn/icanci/loopstack/bic/biz/utils/TestFileUtils.java create mode 100644 biz/src/test/resources/style/default-edge-style-template.json create mode 100644 biz/src/test/resources/style/default-node-style-template.json create mode 100644 biz/src/test/resources/style/demo-edge-style-template.json create mode 100644 biz/src/test/resources/style/demo-node-style-template.json diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java index c202933..c791647 100644 --- a/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java @@ -28,4 +28,6 @@ public interface NodeStyleService extends BaseService { NodeStyleVO queryBySystemUuidAndKey(String systemUuid, String key); List loadSelector(String systemUuid); + + String loadDefaultStyle(); } diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java index cad4928..6137588 100644 --- a/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java @@ -11,6 +11,7 @@ import com.google.common.collect.Lists; import cn.icanci.loopstack.bic.biz.mapper.NodeStyleMapper; import cn.icanci.loopstack.bic.biz.service.NodeStyleService; +import cn.icanci.loopstack.bic.biz.utils.TemplateFileUtils; import cn.icanci.loopstack.bic.common.model.TextValue; import cn.icanci.loopstack.bic.common.model.base.NodeStyleVO; import cn.icanci.loopstack.bic.dal.mongo.common.PageList; @@ -89,4 +90,9 @@ public class NodeStyleServiceImpl implements NodeStyleService { } return textValues; } + + @Override + public String loadDefaultStyle() { + return TemplateFileUtils.queryDefaultNodeStyleTemplate(); + } } diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/FileUtils.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/FileUtils.java deleted file mode 100644 index 6df4e7b..0000000 --- a/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/FileUtils.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.icanci.loopstack.bic.biz.utils; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.InputStream; - -/** - * @author icanci - * @since 1.0 Created in 2023/09/13 09:33 - */ -public class FileUtils { - - /** - * queryMockFile - * - * @return queryMockFile - */ - protected String queryLocalFile(String fileName) { - String fr2Json = null; - try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) { - File file = new File(fileName); - InputStream inputStream = file.toURI().toURL().openConnection().getInputStream(); - byte[] buffer = new byte[1024]; - int len; - while ((len = inputStream.read(buffer)) != -1) { - byteArrayOutputStream.write(buffer, 0, len); - } - fr2Json = byteArrayOutputStream.toString(); - inputStream.close(); - } catch (Exception ignore) { - } - return fr2Json; - } -} diff --git a/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/TemplateFileUtils.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/TemplateFileUtils.java new file mode 100644 index 0000000..cb624b5 --- /dev/null +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/utils/TemplateFileUtils.java @@ -0,0 +1,44 @@ +package cn.icanci.loopstack.bic.biz.utils; + +import java.io.InputStream; +import org.springframework.core.io.ClassPathResource; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/13 09:33 + */ +public class TemplateFileUtils { + private static final String DEFAULT_NODE_STYLE_TEMPLATE = "style/default-node-style-template.json"; + private static final String DEFAULT_NODE_EDGE_TEMPLATE = "style/default-edge-style-template.json"; + + /** + * queryMockFile + * + * @return queryMockFile + */ + public static String queryLocalFile(String fileName) { + try { + ClassPathResource classPathResource = new ClassPathResource(fileName); + InputStream inputStream = classPathResource.getInputStream(); + StringBuilder sb = new StringBuilder(); + byte[] flash = new byte[1024 * 10]; + int len = -1; + while ((len = inputStream.read(flash)) != -1) { + String str = new String(flash, 0, len); + sb.append(str); + } + return sb.toString(); + } catch (Exception e) { + return null; + } + } + + public static String queryDefaultNodeStyleTemplate() { + return queryLocalFile(DEFAULT_NODE_STYLE_TEMPLATE); + } + + public static String queryDefaultEdgeStyleTemplate() { + return queryLocalFile(DEFAULT_NODE_EDGE_TEMPLATE); + } + +} diff --git a/biz/src/test/java/cn/icanci/loopstack/bic/biz/utils/TestFileUtils.java b/biz/src/test/java/cn/icanci/loopstack/bic/biz/utils/TestFileUtils.java new file mode 100644 index 0000000..6e7eddc --- /dev/null +++ b/biz/src/test/java/cn/icanci/loopstack/bic/biz/utils/TestFileUtils.java @@ -0,0 +1,16 @@ +package cn.icanci.loopstack.bic.biz.utils; + +import org.junit.Test; + +/** + * @author icanci + * @since 1.0 Created in 2023/09/14 19:22 + */ +public class TestFileUtils { + @Test + public void testQueryLocalFile() { + String fileName = "style/default-node-style-template.json"; + String fr2Json = TemplateFileUtils.queryLocalFile(fileName); + System.out.println(fr2Json); + } +} diff --git a/biz/src/test/resources/style/default-edge-style-template.json b/biz/src/test/resources/style/default-edge-style-template.json new file mode 100644 index 0000000..0faeb86 --- /dev/null +++ b/biz/src/test/resources/style/default-edge-style-template.json @@ -0,0 +1,31 @@ +{ + "attrs": { + "line": { + "stroke": "#7c68fc", + "strokeWidth": 2 + } + }, + "router": "manhattan", + "connector": "normal", + "labels": [], + "consumerInfo": { + "attrs": { + "line": { + "stroke": "red", + "strokeWidth": 5 + } + }, + "labels": [ + { + "attrs": { + "label": { + "text": "${hoverName}" + } + }, + "position": { + "distance": 0.8 + } + } + ] + } +} \ No newline at end of file diff --git a/biz/src/test/resources/style/default-node-style-template.json b/biz/src/test/resources/style/default-node-style-template.json new file mode 100644 index 0000000..e0f6920 --- /dev/null +++ b/biz/src/test/resources/style/default-node-style-template.json @@ -0,0 +1,59 @@ +{ + "id": "${nodeId}", + "shape": "circle", + "width": 50, + "height": 50, + "attrs": { + "body": { + "fill": "#F39C12", + "stroke": "#000", + "rx": 16, + "ry": 16 + }, + "label": { + "text": "${nodeName}", + "fill": "#333", + "fontSize": 18, + "fontWeight": "bold", + "fontVariant": "small-caps" + } + }, + "ports": { + "groups": { + "in": { + "position": "left", + "attrs": { + "circle": { + "r": 2, + "magnet": true, + "stroke": "#31d0c6", + "strokeWidth": 2, + "fill": "#fff" + } + } + }, + "out": { + "position": "right", + "attrs": { + "circle": { + "r": 2, + "magnet": true, + "stroke": "#31d0c6", + "strokeWidth": 2, + "fill": "#fff" + } + } + } + }, + "items": [ + { + "id": "port-left", + "group": "in" + }, + { + "id": "port-right", + "group": "out" + } + ] + } +} \ No newline at end of file diff --git a/biz/src/test/resources/style/demo-edge-style-template.json b/biz/src/test/resources/style/demo-edge-style-template.json new file mode 100644 index 0000000..426101f --- /dev/null +++ b/biz/src/test/resources/style/demo-edge-style-template.json @@ -0,0 +1,31 @@ +{ + "attrs": { + "line": { + "stroke": "#7c68fc", + "strokeWidth": 2 + } + }, + "router": "manhattan", + "connector": "normal", + "labels": [], + "consumerInfo": { + "attrs": { + "line": { + "stroke": "red", + "strokeWidth": 5 + } + }, + "labels": [ + { + "attrs": { + "label": { + "text": "RPC调用" + } + }, + "position": { + "distance": 0.8 + } + } + ] + } +} \ No newline at end of file diff --git a/biz/src/test/resources/style/demo-node-style-template.json b/biz/src/test/resources/style/demo-node-style-template.json new file mode 100644 index 0000000..d86b322 --- /dev/null +++ b/biz/src/test/resources/style/demo-node-style-template.json @@ -0,0 +1,59 @@ +{ + "id": "${id}", + "shape": "circle", + "width": 50, + "height": 50, + "attrs": { + "body": { + "fill": "#F39C12", + "stroke": "#000", + "rx": 16, + "ry": 16 + }, + "label": { + "text": "下单", + "fill": "#333", + "fontSize": 18, + "fontWeight": "bold", + "fontVariant": "small-caps" + } + }, + "ports": { + "groups": { + "in": { + "position": "left", + "attrs": { + "circle": { + "r": 2, + "magnet": true, + "stroke": "#31d0c6", + "strokeWidth": 2, + "fill": "#fff" + } + } + }, + "out": { + "position": "right", + "attrs": { + "circle": { + "r": 2, + "magnet": true, + "stroke": "#31d0c6", + "strokeWidth": 2, + "fill": "#fff" + } + } + } + }, + "items": [ + { + "id": "port-left", + "group": "in" + }, + { + "id": "port-right", + "group": "out" + } + ] + } +} \ No newline at end of file diff --git a/views/src/main/resources/vueboot/package.json b/views/src/main/resources/vueboot/package.json index fd5d43b..b08b57a 100644 --- a/views/src/main/resources/vueboot/package.json +++ b/views/src/main/resources/vueboot/package.json @@ -41,6 +41,7 @@ "script-loader": "0.7.2", "sortablejs": "1.8.4", "tui-editor": "1.3.3", + "v-jsoneditor": "^1.4.5", "vue": "2.6.10", "vue-count-to": "1.0.13", "vue-router": "3.0.2", diff --git a/views/src/main/resources/vueboot/src/api/nodeStyle.js b/views/src/main/resources/vueboot/src/api/nodeStyle.js index 1638ce8..a58af54 100644 --- a/views/src/main/resources/vueboot/src/api/nodeStyle.js +++ b/views/src/main/resources/vueboot/src/api/nodeStyle.js @@ -32,3 +32,10 @@ export async function remoteValidatesNodeStyleKey(systemUuid, key) { method: 'get', }) } + +export async function nodeStyleLoad() { + return await request({ + url: '/bicAdmin/nodeStyle/loadDefaultStyle', + method: 'get', + }) +} diff --git a/views/src/main/resources/vueboot/src/main.js b/views/src/main/resources/vueboot/src/main.js index 202d782..30cafc3 100644 --- a/views/src/main/resources/vueboot/src/main.js +++ b/views/src/main/resources/vueboot/src/main.js @@ -18,6 +18,10 @@ import './icons' // icon import './permission' // permission control import './utils/error-log' // error log +import VJsoneditor from 'v-jsoneditor'; + +Vue.component('v-jsoneditor', VJsoneditor); + import * as filters from './filters' // global filters import moment from "moment"; diff --git a/views/src/main/resources/vueboot/src/views/bic-config/dialog/node-style-form.vue b/views/src/main/resources/vueboot/src/views/bic-config/dialog/node-style-form.vue index aa65dbf..a3499a3 100644 --- a/views/src/main/resources/vueboot/src/views/bic-config/dialog/node-style-form.vue +++ b/views/src/main/resources/vueboot/src/views/bic-config/dialog/node-style-form.vue @@ -27,26 +27,27 @@ - + - - + + + + + 取 消 - 确 定 + 确 定