From a1712c18d654a16319a5431bb6136e63f8f7a8d6 Mon Sep 17 00:00:00 2001 From: clay <20932067@zju.edu.cn> Date: Wed, 24 Apr 2024 16:37:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?readme=20:=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 446a9c8..9bf4832 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ | 依赖 | 版本 | |----------------------|------------| -| Spring Boot | 2.7.5 | +| Spring Boot | 2.7.3 | | Spring Cloud | 2021.0.5 | | Spring Cloud Alibaba | 2021.0.4.0 | | Mybatis | 3.5.2 | From 2e7c0c042e4484b44d6a69ebfc2b669af08929ae Mon Sep 17 00:00:00 2001 From: clay <20932067@zju.edu.cn> Date: Thu, 25 Apr 2024 14:08:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat=20:=20=E6=B7=BB=E5=8A=A0=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../fateverse/query/entity/PortalMapping.java | 3 +++ .../fateverse/query/entity/dto/PortalDto.java | 3 +++ .../fateverse/query/enums/PortalPremEnum.java | 12 ++++++++++-- .../portal/service/DispatchSyncService.java | 19 ++++++++++++++++--- .../query/service/impl/PortalServiceImpl.java | 11 +++++++++-- .../resources/mapper/PortalMappingMapper.xml | 15 +++++++++++---- 7 files changed, 53 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9bf4832..7572941 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ | Spring Cloud Alibaba | 2021.0.4.0 | | Mybatis | 3.5.2 | | Vue | 3.1.3 | -| React | 3.1.3 | +| React | 18.2.0 | ### 模块说明 diff --git a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/entity/PortalMapping.java b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/entity/PortalMapping.java index e97e18c..2e2f400 100644 --- a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/entity/PortalMapping.java +++ b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/entity/PortalMapping.java @@ -48,6 +48,9 @@ public class PortalMapping { */ private String inputType; + + private Boolean required; + /** * 描述 */ diff --git a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/entity/dto/PortalDto.java b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/entity/dto/PortalDto.java index 9665506..6ee3695 100644 --- a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/entity/dto/PortalDto.java +++ b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/entity/dto/PortalDto.java @@ -137,6 +137,9 @@ public class PortalDto { if (!mapping.check()) { throw new RuntimeException("映射关系不完全,请检查映射关系"); } + if (ObjectUtils.isEmpty(mapping.getRequired())) { + mapping.setRequired(Boolean.FALSE); + } } } portal.setRemark(remark); diff --git a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/enums/PortalPremEnum.java b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/enums/PortalPremEnum.java index 0791556..ac5d3f0 100644 --- a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/enums/PortalPremEnum.java +++ b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/enums/PortalPremEnum.java @@ -6,9 +6,17 @@ package cn.fateverse.query.enums; */ public enum PortalPremEnum { + /** + * 匿名 + */ ANONYMITY, + /** + * 第三方授权 + */ EXTERNAL, - LOCAL - ; + /** + * 内部使用 + */ + LOCAL; } diff --git a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/portal/service/DispatchSyncService.java b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/portal/service/DispatchSyncService.java index 9e11fb2..9c61390 100644 --- a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/portal/service/DispatchSyncService.java +++ b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/portal/service/DispatchSyncService.java @@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.rpc.cluster.specifyaddress.Address; import org.apache.dubbo.rpc.cluster.specifyaddress.UserSpecifiedAddressUtil; +import org.bouncycastle.jcajce.provider.asymmetric.RSA; import org.springframework.context.event.EventListener; import org.springframework.core.env.Environment; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -122,18 +123,28 @@ public class DispatchSyncService { } //如果为false,则将当前任务重新放入到队列中,等待下一次执行 if (state == null || !state) { - queue.add(this); + retry(); } } catch (NacosException e) { log.error("NacosException: {}", e.getMessage()); //如果发生异常也是 - //todo 后续可以添加当前任务报错次数的处理 - queue.add(this); + retry(); } finally { //将指定的地址恢复 UserSpecifiedAddressUtil.setAddress(null); } } + + /** + * 进行重试 + */ + private void retry() { + retryCount++; + if (retryCount > 5) { + log.error("任务超过最大重试次数!"); + } + queue.add(this); + } }; //像阻塞队列中添加任务 queue.add(task); @@ -169,6 +180,8 @@ public class DispatchSyncService { protected final String requestMethod; + protected Integer retryCount = 0; + private Task(String ip, int port, String path, Boolean publish, String requestMethod) { this.ip = ip; this.port = port; diff --git a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/service/impl/PortalServiceImpl.java b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/service/impl/PortalServiceImpl.java index fbe6974..7865128 100644 --- a/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/service/impl/PortalServiceImpl.java +++ b/custom-query/custom-query-biz/src/main/java/cn/fateverse/query/service/impl/PortalServiceImpl.java @@ -10,10 +10,10 @@ import cn.fateverse.query.entity.dto.MockParam; import cn.fateverse.query.entity.vo.DataAdapterVo; import cn.fateverse.query.entity.vo.PortalIdWrapper; import cn.fateverse.query.enums.DataAdapterType; +import cn.fateverse.query.enums.PortalPremEnum; import cn.fateverse.query.handler.reader.DataAdapterHandlerReader; import cn.fateverse.query.portal.service.HandlerMethodService; import cn.fateverse.query.constant.QueryConstant; -import cn.fateverse.query.entity.dto.DataAdapterDto; import cn.fateverse.query.entity.dto.PortalDto; import cn.fateverse.query.entity.query.PortalQuery; import cn.fateverse.query.entity.vo.PortalVo; @@ -76,12 +76,19 @@ public class PortalServiceImpl implements PortalService { this.handlerReader = handlerReader; taskExecuteExecutor.execute(() -> { PortalQuery query = new PortalQuery(); -// query.setState(QueryConstant.PORTAL_PUBLISH); + query.setState(QueryConstant.PORTAL_PUBLISH); List portalList = portalMapper.selectList(query); if (ObjectUtils.isEmpty(portalList)) { log.info("portal is empty!"); return; } + portalList = portalList.stream() + .filter(portal -> PortalPremEnum.ANONYMITY.equals(portal.getPermissionType()) || PortalPremEnum.EXTERNAL.equals(portal.getPermissionType())) + .collect(Collectors.toList()); + if (ObjectUtils.isEmpty(portalList)) { + log.info("portal is empty!"); + return; + } List portalIds = portalList.stream().map(Portal::getPortalId).collect(Collectors.toList()); if (ObjectUtils.isEmpty(portalIds)) { log.info("portalIds is empty!"); diff --git a/custom-query/custom-query-biz/src/main/resources/mapper/PortalMappingMapper.xml b/custom-query/custom-query-biz/src/main/resources/mapper/PortalMappingMapper.xml index 2b8f4be..ae5395d 100644 --- a/custom-query/custom-query-biz/src/main/resources/mapper/PortalMappingMapper.xml +++ b/custom-query/custom-query-biz/src/main/resources/mapper/PortalMappingMapper.xml @@ -4,7 +4,14 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - select mapping_id, portal_id, mapping_key, mapping_type, mapping_value, input_type, description + select mapping_id, + portal_id, + mapping_key, + mapping_type, + mapping_value, + input_type, + required, + description from portal_mapping @@ -21,13 +28,13 @@ - - insert into portal_mapping (portal_id, mapping_key, mapping_type, mapping_value, input_type, description) + insert into portal_mapping (portal_id, mapping_key, mapping_type, mapping_value, input_type, required, + description) values (#{item.portalId}, #{item.mappingKey}, #{item.mappingType}, #{item.mappingValue}, #{item.inputType}, - #{item.description}) + #{item.required},#{item.description})