Merge pull request 'portal' (#80) from portal into master
Reviewed-on: http://git.feashow.cn/clay/fateverse/pulls/80
This commit is contained in:
@@ -21,12 +21,12 @@
|
|||||||
|
|
||||||
| 依赖 | 版本 |
|
| 依赖 | 版本 |
|
||||||
|----------------------|------------|
|
|----------------------|------------|
|
||||||
| Spring Boot | 2.7.5 |
|
| Spring Boot | 2.7.3 |
|
||||||
| Spring Cloud | 2021.0.5 |
|
| Spring Cloud | 2021.0.5 |
|
||||||
| Spring Cloud Alibaba | 2021.0.4.0 |
|
| Spring Cloud Alibaba | 2021.0.4.0 |
|
||||||
| Mybatis | 3.5.2 |
|
| Mybatis | 3.5.2 |
|
||||||
| Vue | 3.1.3 |
|
| Vue | 3.1.3 |
|
||||||
| React | 3.1.3 |
|
| React | 18.2.0 |
|
||||||
|
|
||||||
### 模块说明
|
### 模块说明
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ public class PortalMapping {
|
|||||||
*/
|
*/
|
||||||
private String inputType;
|
private String inputType;
|
||||||
|
|
||||||
|
|
||||||
|
private Boolean required;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述
|
* 描述
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ public class PortalDto {
|
|||||||
if (!mapping.check()) {
|
if (!mapping.check()) {
|
||||||
throw new RuntimeException("映射关系不完全,请检查映射关系");
|
throw new RuntimeException("映射关系不完全,请检查映射关系");
|
||||||
}
|
}
|
||||||
|
if (ObjectUtils.isEmpty(mapping.getRequired())) {
|
||||||
|
mapping.setRequired(Boolean.FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
portal.setRemark(remark);
|
portal.setRemark(remark);
|
||||||
|
|||||||
@@ -6,9 +6,17 @@ package cn.fateverse.query.enums;
|
|||||||
*/
|
*/
|
||||||
public enum PortalPremEnum {
|
public enum PortalPremEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匿名
|
||||||
|
*/
|
||||||
ANONYMITY,
|
ANONYMITY,
|
||||||
|
/**
|
||||||
|
* 第三方授权
|
||||||
|
*/
|
||||||
EXTERNAL,
|
EXTERNAL,
|
||||||
LOCAL
|
/**
|
||||||
;
|
* 内部使用
|
||||||
|
*/
|
||||||
|
LOCAL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.apache.dubbo.rpc.cluster.specifyaddress.Address;
|
import org.apache.dubbo.rpc.cluster.specifyaddress.Address;
|
||||||
import org.apache.dubbo.rpc.cluster.specifyaddress.UserSpecifiedAddressUtil;
|
import org.apache.dubbo.rpc.cluster.specifyaddress.UserSpecifiedAddressUtil;
|
||||||
|
import org.bouncycastle.jcajce.provider.asymmetric.RSA;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
@@ -122,18 +123,28 @@ public class DispatchSyncService {
|
|||||||
}
|
}
|
||||||
//如果为false,则将当前任务重新放入到队列中,等待下一次执行
|
//如果为false,则将当前任务重新放入到队列中,等待下一次执行
|
||||||
if (state == null || !state) {
|
if (state == null || !state) {
|
||||||
queue.add(this);
|
retry();
|
||||||
}
|
}
|
||||||
} catch (NacosException e) {
|
} catch (NacosException e) {
|
||||||
log.error("NacosException: {}", e.getMessage());
|
log.error("NacosException: {}", e.getMessage());
|
||||||
//如果发生异常也是
|
//如果发生异常也是
|
||||||
//todo 后续可以添加当前任务报错次数的处理
|
retry();
|
||||||
queue.add(this);
|
|
||||||
} finally {
|
} finally {
|
||||||
//将指定的地址恢复
|
//将指定的地址恢复
|
||||||
UserSpecifiedAddressUtil.setAddress(null);
|
UserSpecifiedAddressUtil.setAddress(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进行重试
|
||||||
|
*/
|
||||||
|
private void retry() {
|
||||||
|
retryCount++;
|
||||||
|
if (retryCount > 5) {
|
||||||
|
log.error("任务超过最大重试次数!");
|
||||||
|
}
|
||||||
|
queue.add(this);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
//像阻塞队列中添加任务
|
//像阻塞队列中添加任务
|
||||||
queue.add(task);
|
queue.add(task);
|
||||||
@@ -169,6 +180,8 @@ public class DispatchSyncService {
|
|||||||
protected final String requestMethod;
|
protected final String requestMethod;
|
||||||
|
|
||||||
|
|
||||||
|
protected Integer retryCount = 0;
|
||||||
|
|
||||||
private Task(String ip, int port, String path, Boolean publish, String requestMethod) {
|
private Task(String ip, int port, String path, Boolean publish, String requestMethod) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import cn.fateverse.query.entity.dto.MockParam;
|
|||||||
import cn.fateverse.query.entity.vo.DataAdapterVo;
|
import cn.fateverse.query.entity.vo.DataAdapterVo;
|
||||||
import cn.fateverse.query.entity.vo.PortalIdWrapper;
|
import cn.fateverse.query.entity.vo.PortalIdWrapper;
|
||||||
import cn.fateverse.query.enums.DataAdapterType;
|
import cn.fateverse.query.enums.DataAdapterType;
|
||||||
|
import cn.fateverse.query.enums.PortalPremEnum;
|
||||||
import cn.fateverse.query.handler.reader.DataAdapterHandlerReader;
|
import cn.fateverse.query.handler.reader.DataAdapterHandlerReader;
|
||||||
import cn.fateverse.query.portal.service.HandlerMethodService;
|
import cn.fateverse.query.portal.service.HandlerMethodService;
|
||||||
import cn.fateverse.query.constant.QueryConstant;
|
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.dto.PortalDto;
|
||||||
import cn.fateverse.query.entity.query.PortalQuery;
|
import cn.fateverse.query.entity.query.PortalQuery;
|
||||||
import cn.fateverse.query.entity.vo.PortalVo;
|
import cn.fateverse.query.entity.vo.PortalVo;
|
||||||
@@ -76,12 +76,19 @@ public class PortalServiceImpl implements PortalService {
|
|||||||
this.handlerReader = handlerReader;
|
this.handlerReader = handlerReader;
|
||||||
taskExecuteExecutor.execute(() -> {
|
taskExecuteExecutor.execute(() -> {
|
||||||
PortalQuery query = new PortalQuery();
|
PortalQuery query = new PortalQuery();
|
||||||
// query.setState(QueryConstant.PORTAL_PUBLISH);
|
query.setState(QueryConstant.PORTAL_PUBLISH);
|
||||||
List<Portal> portalList = portalMapper.selectList(query);
|
List<Portal> portalList = portalMapper.selectList(query);
|
||||||
if (ObjectUtils.isEmpty(portalList)) {
|
if (ObjectUtils.isEmpty(portalList)) {
|
||||||
log.info("portal is empty!");
|
log.info("portal is empty!");
|
||||||
return;
|
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());
|
List<Long> portalIds = portalList.stream().map(Portal::getPortalId).collect(Collectors.toList());
|
||||||
if (ObjectUtils.isEmpty(portalIds)) {
|
if (ObjectUtils.isEmpty(portalIds)) {
|
||||||
log.info("portalIds is empty!");
|
log.info("portalIds is empty!");
|
||||||
|
|||||||
@@ -4,7 +4,14 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="cn.fateverse.query.mapper.PortalMappingMapper">
|
<mapper namespace="cn.fateverse.query.mapper.PortalMappingMapper">
|
||||||
<sql id="selectPortalMapping">
|
<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
|
from portal_mapping
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@@ -21,13 +28,13 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertBatch">
|
<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
|
values
|
||||||
<foreach collection="list" item="item" separator=",">
|
<foreach collection="list" item="item" separator=",">
|
||||||
(#{item.portalId}, #{item.mappingKey}, #{item.mappingType}, #{item.mappingValue}, #{item.inputType},
|
(#{item.portalId}, #{item.mappingKey}, #{item.mappingType}, #{item.mappingValue}, #{item.inputType},
|
||||||
#{item.description})
|
#{item.required},#{item.description})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user