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 0000000000000000000000000000000000000000..05ac401a07b74d1a6f3a2c6bc84a745dda138ded --- /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 0000000000000000000000000000000000000000..c79164786f6d2c96351f1dd869b178d398fd617a --- /dev/null +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/NodeStyleService.java @@ -0,0 +1,33 @@ +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); + + String loadDefaultStyle(); +} 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 c92aacaf1e1e174b405dd2f5b7f218c013d60ea7..ccf25aa7bf5182c07efe909b686787ea36790176 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/service/impl/NodeStyleServiceImpl.java b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..61375881f0efc01f86287373ca067d3f703d1597 --- /dev/null +++ b/biz/src/main/java/cn/icanci/loopstack/bic/biz/service/impl/NodeStyleServiceImpl.java @@ -0,0 +1,98 @@ +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.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; +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; + } + + @Override + public String loadDefaultStyle() { + return TemplateFileUtils.queryDefaultNodeStyleTemplate(); + } +} 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 0000000000000000000000000000000000000000..cb624b53eab13c49b21915d237f04767c925ffad --- /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/main/resources/style/default-edge-style-template.json b/biz/src/main/resources/style/default-edge-style-template.json new file mode 100644 index 0000000000000000000000000000000000000000..0faeb86f2d79383aced5ac21e88e72a9ad1e03ed --- /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 0000000000000000000000000000000000000000..e0f6920bb7ea306db03e0e876b555d0065ae50a5 --- /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 0000000000000000000000000000000000000000..426101f2fc76dd4bf6a13b751a721bb70afd120e --- /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 0000000000000000000000000000000000000000..d86b32208cc6f4fcb8e6e07ecd92316ade2750cf --- /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/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 0000000000000000000000000000000000000000..6e7eddcc86a18ef5bca3529ffc20bf7ecc9d014f --- /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 0000000000000000000000000000000000000000..0faeb86f2d79383aced5ac21e88e72a9ad1e03ed --- /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 0000000000000000000000000000000000000000..e0f6920bb7ea306db03e0e876b555d0065ae50a5 --- /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 0000000000000000000000000000000000000000..426101f2fc76dd4bf6a13b751a721bb70afd120e --- /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 0000000000000000000000000000000000000000..d86b32208cc6f4fcb8e6e07ecd92316ade2750cf --- /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/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 dc5a398cd34384a5514d56b54e25ac8245c3e298..10ec939bcdbe9d5c54d089b3eb74522faf669329 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 0000000000000000000000000000000000000000..42bd97d0bfd904193e8c7b52be98b04ce0a5a7bb --- /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 0000000000000000000000000000000000000000..2d99ed2ec3479458d2246cfe509219e5093dd4cb --- /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 0000000000000000000000000000000000000000..894065512e2f454f1c1853cea2a8f29152753c2c --- /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/pom.xml b/views/pom.xml index 713205d8b3e2e2b40272124b5eb97df9171a01e5..62fca0879e9c9385c106643072038f53d3374203 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/package.json b/views/src/main/resources/vueboot/package.json index fd5d43b6a5f7db397a2ced5ab86279d80cb49676..b08b57ac842f78c61e5305c980b47a47752c31d3 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/loadSelectorApi.js b/views/src/main/resources/vueboot/src/api/loadSelectorApi.js index 0a71f943a99282d8f5891ea28793c916df95ae5e..37c6caa92ed75971124ca666715910f2e71fc587 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 0000000000000000000000000000000000000000..a58af54f92d8851de969f719d2e191c3cf81f90f --- /dev/null +++ b/views/src/main/resources/vueboot/src/api/nodeStyle.js @@ -0,0 +1,41 @@ +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', + }) +} + +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 202d782e34b6d1f6079d6ed138920d0ffa31c4d4..30cafc374b2182b4e1f61933c5beecef44092995 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-burying/burying.vue b/views/src/main/resources/vueboot/src/views/bic-burying/burying.vue index f1924e828bc0b2b49330bade4d82b6e6de7ffe5e..84137638bec045d2174f3438ed7ff3a364992664 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 @@ - + + - + - + + + + + diff --git a/views/src/main/resources/vueboot/src/views/bic-config/dialog/use-case-form.vue b/views/src/main/resources/vueboot/src/views/bic-config/dialog/use-case-form.vue index d288283a984e52a75ddad9ae2ba9289891645d93..f146946ff30cf1168e22f0842f91e638713b4c83 100644 --- a/views/src/main/resources/vueboot/src/views/bic-config/dialog/use-case-form.vue +++ b/views/src/main/resources/vueboot/src/views/bic-config/dialog/use-case-form.vue @@ -18,7 +18,7 @@ ref="ruleForm" > - + - +
- + + + + + + + + + + + + + + + + 查询 + + + 新增 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/views/src/main/resources/vueboot/src/views/bic-config/use-case-config.vue b/views/src/main/resources/vueboot/src/views/bic-config/use-case-config.vue index 5464ae2780b23b494474a1cd5263ebeea74fa7f5..0244eca9def1973b101d20fced023e0996f03e06 100644 --- a/views/src/main/resources/vueboot/src/views/bic-config/use-case-config.vue +++ b/views/src/main/resources/vueboot/src/views/bic-config/use-case-config.vue @@ -3,7 +3,7 @@ - + textValues = nodeStyleService.loadSelector(systemUuid); + return R.builderOk().data("textValues", textValues).build(); + } + + @GetMapping("loadDefaultStyle") + public R loadDefaultStyle() { + String defaultStyle = nodeStyleService.loadDefaultStyle(); + return R.builderOk().data("defaultStyle", defaultStyle).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 0000000000000000000000000000000000000000..2ad5f3fc77cd1aca5188d0c4932719e9918e391c --- /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 0000000000000000000000000000000000000000..d4d28799ed8fce9ee65c4b77577b63b1a5020df5 --- /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 0000000000000000000000000000000000000000..ad408751e997243937937c18c3d5af7281713d95 --- /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; +}