feat : 添加必要字段

This commit is contained in:
clay
2024-04-25 14:08:24 +08:00
parent a1712c18d6
commit 2e7c0c042e
7 changed files with 53 additions and 12 deletions

View File

@@ -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 |
### 模块说明

View File

@@ -48,6 +48,9 @@ public class PortalMapping {
*/
private String inputType;
private Boolean required;
/**
* 描述
*/

View File

@@ -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);

View File

@@ -6,9 +6,17 @@ package cn.fateverse.query.enums;
*/
public enum PortalPremEnum {
/**
* 匿名
*/
ANONYMITY,
/**
* 第三方授权
*/
EXTERNAL,
LOCAL
;
/**
* 内部使用
*/
LOCAL;
}

View File

@@ -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;

View File

@@ -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<Portal> 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<Long> portalIds = portalList.stream().map(Portal::getPortalId).collect(Collectors.toList());
if (ObjectUtils.isEmpty(portalIds)) {
log.info("portalIds is empty!");

View File

@@ -4,7 +4,14 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.fateverse.query.mapper.PortalMappingMapper">
<sql id="selectPortalMapping">
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
</sql>
@@ -21,13 +28,13 @@
</foreach>
</select>
<insert id="insertBatch">
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
<foreach collection="list" item="item" separator=",">
(#{item.portalId}, #{item.mappingKey}, #{item.mappingType}, #{item.mappingValue}, #{item.inputType},
#{item.description})
#{item.required},#{item.description})
</foreach>
</insert>