feat: 2.4.0
1. 支持retry 和 job可选择
This commit is contained in:
parent
a5ddbab360
commit
6b1380b8ca
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.retry.task.support;
|
||||
package com.aizuda.easy.retry.server.common;
|
||||
|
||||
/**
|
||||
* @author: www.byteblogs.com
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.retry.task.support.cache;
|
||||
package com.aizuda.easy.retry.server.common.cache;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.server.common.Lifecycle;
|
@ -11,5 +11,13 @@ public enum SystemModeEnum {
|
||||
|
||||
RETRY,
|
||||
JOB,
|
||||
ALL
|
||||
ALL;
|
||||
|
||||
public static boolean isRetry(SystemModeEnum mode) {
|
||||
return RETRY == mode || ALL == mode;
|
||||
}
|
||||
|
||||
public static boolean isJob(SystemModeEnum mode) {
|
||||
return JOB == mode || ALL == mode;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.aizuda.easy.retry.server.retry.task.support.lock;
|
||||
package com.aizuda.easy.retry.server.common.lock;
|
||||
|
||||
import com.aizuda.easy.retry.server.common.cache.CacheLockRecord;
|
||||
import com.aizuda.easy.retry.server.common.dto.LockConfig;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.cache.CacheLockRecord;
|
||||
import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
|
||||
|
||||
import java.util.Arrays;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.retry.task.support.lock;
|
||||
package com.aizuda.easy.retry.server.common.lock;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.retry.task.support.lock;
|
||||
package com.aizuda.easy.retry.server.common.lock;
|
||||
|
||||
|
||||
import com.aizuda.easy.retry.server.common.dto.LockConfig;
|
@ -1,12 +1,12 @@
|
||||
package com.aizuda.easy.retry.server.retry.task.support.schedule;
|
||||
package com.aizuda.easy.retry.server.common.schedule;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.server.common.Schedule;
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||
import com.aizuda.easy.retry.server.common.dto.LockConfig;
|
||||
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.Schedule;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.lock.LockProvider;
|
||||
import com.aizuda.easy.retry.server.common.lock.LockProvider;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
@ -1,5 +1,7 @@
|
||||
package com.aizuda.easy.retry.server.job.task;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@ -10,6 +12,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan("com.aizuda.easy.retry.server.job.task.*")
|
||||
@ConditionalOnExpression("'${easy-retry.mode}'.equals('job') or '${easy-retry.mode}'.equals('all')")
|
||||
public class EasyRetryJobTaskStarter {
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.aizuda.easy.retry.server.retry.task;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@ -10,6 +11,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan("com.aizuda.easy.retry.server.retry.task.*")
|
||||
@ConditionalOnExpression("'${easy-retry.mode}'.equals('retry') or '${easy-retry.mode}'.equals('all')")
|
||||
public class EasyRetryRetryTaskStarter {
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package com.aizuda.easy.retry.server.retry.task.support.handler;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
import com.aizuda.easy.retry.common.core.enums.HeadersEnum;
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.common.core.model.EasyRetryRequest;
|
||||
import com.aizuda.easy.retry.common.core.model.NettyResult;
|
||||
@ -67,6 +69,10 @@ public class ReportRetryInfoHttpRequestHandler extends PostHttpRequestHandler {
|
||||
Object[] args = retryRequest.getArgs();
|
||||
|
||||
try {
|
||||
|
||||
// 同步版本
|
||||
syncConfig(headers);
|
||||
|
||||
TaskGenerator taskGenerator = taskGenerators.stream()
|
||||
.filter(t -> t.supports(TaskGeneratorScene.CLIENT_REPORT.getScene()))
|
||||
.findFirst().orElseThrow(() -> new EasyRetryServerException("没有匹配的任务生成器"));
|
||||
@ -132,4 +138,10 @@ public class ReportRetryInfoHttpRequestHandler extends PostHttpRequestHandler {
|
||||
return JsonUtil.toJsonString(new NettyResult(StatusEnum.YES.getStatus(), throwable.getMessage(), Boolean.FALSE, retryRequest.getReqId()));
|
||||
}
|
||||
}
|
||||
|
||||
private void syncConfig(HttpHeaders headers) {
|
||||
ConfigVersionSyncHandler syncHandler = SpringContext.getBeanByType(ConfigVersionSyncHandler.class);
|
||||
Integer clientVersion = headers.getInt(HeadersEnum.VERSION.getKey());
|
||||
syncHandler.addSyncTask(headers.get(HeadersEnum.GROUP_NAME.getKey()), clientVersion);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.aizuda.easy.retry.server.retry.task.support.schedule;
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.server.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||
import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.RetryTaskLogMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.RetryTaskLogMessageMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.RetryTaskLog;
|
||||
|
@ -9,6 +9,7 @@ import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.common.core.util.EnvironmentUtils;
|
||||
import com.aizuda.easy.retry.common.core.util.HostUtils;
|
||||
import com.aizuda.easy.retry.server.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
|
||||
import com.aizuda.easy.retry.template.datasource.access.AccessTemplate;
|
||||
import com.aizuda.easy.retry.template.datasource.access.TaskAccess;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
|
||||
|
@ -10,6 +10,7 @@ import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.common.core.util.EnvironmentUtils;
|
||||
import com.aizuda.easy.retry.common.core.util.HostUtils;
|
||||
import com.aizuda.easy.retry.server.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
|
||||
import com.aizuda.easy.retry.template.datasource.access.AccessTemplate;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig;
|
||||
|
@ -2,6 +2,7 @@ package com.aizuda.easy.retry.server.retry.task.support.schedule;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.server.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
|
||||
import com.aizuda.easy.retry.server.retry.task.service.RetryService;
|
||||
import com.aizuda.easy.retry.template.datasource.access.AccessTemplate;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.aizuda.easy.retry.server;
|
||||
|
||||
import com.aizuda.easy.retry.server.server.NettyHttpServer;
|
||||
import com.aizuda.easy.retry.server.starter.server.NettyHttpServer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(scanBasePackages = {"com.aizuda.easy.retry.server.starter.*"})
|
||||
@EnableTransactionManagement(proxyTargetClass = true)
|
||||
@Slf4j
|
||||
public class EasyRetryServerApplication {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.dispatch;
|
||||
package com.aizuda.easy.retry.server.starter.dispatch;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.dispatch;
|
||||
package com.aizuda.easy.retry.server.starter.dispatch;
|
||||
|
||||
import akka.actor.AbstractActor;
|
||||
import akka.actor.ActorRef;
|
||||
@ -27,10 +27,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 消费当前节点分配的bucket并生成扫描任务
|
||||
@ -70,7 +67,7 @@ public class ConsumerBucketActor extends AbstractActor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (systemProperties.getMode() == SystemModeEnum.ALL || systemProperties.getMode() == SystemModeEnum.RETRY) {
|
||||
if (SystemModeEnum.isRetry(systemProperties.getMode())) {
|
||||
// 查询桶对应组信息
|
||||
List<GroupConfig> groupConfigs = accessTemplate.getGroupConfigAccess().list(
|
||||
new LambdaQueryWrapper<GroupConfig>()
|
||||
@ -90,7 +87,7 @@ public class ConsumerBucketActor extends AbstractActor {
|
||||
}
|
||||
}
|
||||
|
||||
if (systemProperties.getMode() == SystemModeEnum.ALL || systemProperties.getMode() == SystemModeEnum.JOB) {
|
||||
if (SystemModeEnum.isJob(systemProperties.getMode())) {
|
||||
// 扫描回调数据
|
||||
ScanTask scanTask = new ScanTask();
|
||||
scanTask.setBuckets(consumerBucket.getBuckets());
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.dispatch;
|
||||
package com.aizuda.easy.retry.server.starter.dispatch;
|
||||
|
||||
import akka.actor.ActorRef;
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
@ -1,10 +1,11 @@
|
||||
package com.aizuda.easy.retry.server.retry.task.support.schedule;
|
||||
package com.aizuda.easy.retry.server.starter.schedule;
|
||||
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.server.common.Lifecycle;
|
||||
import com.aizuda.easy.retry.server.common.dto.RegisterNodeInfo;
|
||||
import com.aizuda.easy.retry.server.common.cache.CacheRegisterTable;
|
||||
import com.aizuda.easy.retry.server.common.register.ServerRegister;
|
||||
import com.aizuda.easy.retry.server.common.schedule.AbstractSchedule;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.ServerNodeMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.server;
|
||||
package com.aizuda.easy.retry.server.starter.server;
|
||||
|
||||
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.server;
|
||||
package com.aizuda.easy.retry.server.starter.server;
|
||||
|
||||
import akka.actor.ActorRef;
|
||||
import com.aizuda.easy.retry.server.common.akka.ActorGenerator;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.server;
|
||||
package com.aizuda.easy.retry.server.starter.server;
|
||||
|
||||
import akka.actor.AbstractActor;
|
||||
import cn.hutool.core.net.url.UrlBuilder;
|
||||
@ -8,13 +8,12 @@ import com.aizuda.easy.retry.common.core.enums.HeadersEnum;
|
||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||
import com.aizuda.easy.retry.common.core.model.Result;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.server.common.HttpRequestHandler;
|
||||
import com.aizuda.easy.retry.server.common.Register;
|
||||
import com.aizuda.easy.retry.server.common.akka.ActorGenerator;
|
||||
import com.aizuda.easy.retry.server.common.dto.NettyHttpRequest;
|
||||
import com.aizuda.easy.retry.server.common.Register;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.handler.ConfigVersionSyncHandler;
|
||||
import com.aizuda.easy.retry.server.common.register.ClientRegister;
|
||||
import com.aizuda.easy.retry.server.common.register.RegisterContext;
|
||||
import com.aizuda.easy.retry.server.common.HttpRequestHandler;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http.DefaultFullHttpResponse;
|
||||
@ -101,10 +100,6 @@ public class RequestHandlerActor extends AbstractActor {
|
||||
LogUtils.warn(log, "client register error. groupName:[{}]", groupName);
|
||||
}
|
||||
|
||||
// 同步版本
|
||||
ConfigVersionSyncHandler syncHandler = SpringContext.getBeanByType(ConfigVersionSyncHandler.class);
|
||||
Integer clientVersion = headers.getInt(HeadersEnum.VERSION.getKey());
|
||||
syncHandler.addSyncTask(groupName, clientVersion);
|
||||
|
||||
UrlBuilder builder = UrlBuilder.ofHttp(uri);
|
||||
Collection<HttpRequestHandler> httpRequestHandlers = SpringContext.CONTEXT
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.server.handler;
|
||||
package com.aizuda.easy.retry.server.starter.server.handler;
|
||||
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
import com.aizuda.easy.retry.common.core.constant.SystemConstants.HTTP_PATH;
|
@ -1,4 +1,4 @@
|
||||
package com.aizuda.easy.retry.server.server.handler;
|
||||
package com.aizuda.easy.retry.server.starter.server.handler;
|
||||
|
||||
import cn.hutool.core.net.url.UrlQuery;
|
||||
import com.aizuda.easy.retry.server.common.handler.GetHttpRequestHandler;
|
@ -48,7 +48,7 @@ easy-retry:
|
||||
max-count: 288 #回调最大执行次数
|
||||
trigger-interval: 900 #间隔时间
|
||||
db-type: mysql #当前使用的数据库
|
||||
mode: retry
|
||||
mode: all
|
||||
|
||||
|
||||
|
||||
|
@ -27,4 +27,6 @@ public class SystemUserResponseVO {
|
||||
|
||||
private LocalDateTime updateDt;
|
||||
|
||||
private String mode;
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,9 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.HashUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||
import com.aizuda.easy.retry.server.common.enums.IdGeneratorMode;
|
||||
import com.aizuda.easy.retry.server.common.enums.SystemModeEnum;
|
||||
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||
import com.aizuda.easy.retry.server.retry.task.support.handler.ConfigVersionSyncHandler;
|
||||
import com.aizuda.easy.retry.server.web.service.GroupConfigService;
|
||||
@ -27,6 +29,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.jdbc.BadSqlGrammarException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -53,12 +56,15 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
||||
@Autowired
|
||||
private SequenceAllocMapper sequenceAllocMapper;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private ConfigVersionSyncHandler configVersionSyncHandler;
|
||||
|
||||
@Value("${easy-retry.total-partition:32}")
|
||||
private Integer totalPartition;
|
||||
@Value("${easy-retry.step:100}")
|
||||
private Integer step;
|
||||
@Autowired
|
||||
private SystemProperties systemProperties;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@ -125,11 +131,13 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
||||
|
||||
doUpdateSceneConfig(groupConfigRequestVO);
|
||||
|
||||
// 同步版本, 版本为0代表需要同步到客户端
|
||||
boolean add = configVersionSyncHandler.addSyncTask(groupConfigRequestVO.getGroupName(), 0);
|
||||
// 若添加失败则强制发起同步
|
||||
if (!add) {
|
||||
configVersionSyncHandler.syncVersion(groupConfigRequestVO.getGroupName());
|
||||
if (SystemModeEnum.isRetry(systemProperties.getMode())) {
|
||||
// 同步版本, 版本为0代表需要同步到客户端
|
||||
boolean add = configVersionSyncHandler.addSyncTask(groupConfigRequestVO.getGroupName(), 0);
|
||||
// 若添加失败则强制发起同步
|
||||
if (!add) {
|
||||
configVersionSyncHandler.syncVersion(groupConfigRequestVO.getGroupName());
|
||||
}
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
|
@ -46,6 +46,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -73,10 +74,6 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class RetryTaskServiceImpl implements RetryTaskService {
|
||||
|
||||
public static final String URL = "http://{0}:{1}/{2}/retry/generate/idempotent-id/v1";
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
@Autowired
|
||||
private ClientNodeAllocateHandler clientNodeAllocateHandler;
|
||||
@Autowired
|
||||
@ -86,7 +83,9 @@ public class RetryTaskServiceImpl implements RetryTaskService {
|
||||
@Autowired
|
||||
private AccessTemplate accessTemplate;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private List<TaskGenerator> taskGenerators;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private List<TaskExecutor> taskExecutors;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.aizuda.easy.retry.server.web.service.impl;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.aizuda.easy.retry.server.common.config.SystemProperties;
|
||||
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.SystemUserMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.SystemUserPermissionMapper;
|
||||
@ -41,12 +42,14 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class SystemUserServiceImpl implements SystemUserService {
|
||||
|
||||
public static final long EXPIRE_TIME = 3600 * 1000;
|
||||
public static final long EXPIRE_TIME = 3600 * 7 * 1000;
|
||||
|
||||
@Autowired
|
||||
private SystemUserMapper systemUserMapper;
|
||||
@Autowired
|
||||
private SystemUserPermissionMapper systemUserPermissionMapper;
|
||||
@Autowired
|
||||
private SystemProperties systemProperties;
|
||||
|
||||
@Override
|
||||
public SystemUserResponseVO login(SystemUserRequestVO requestVO) {
|
||||
@ -64,6 +67,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
|
||||
SystemUserResponseVO systemUserResponseVO = SystemUserResponseVOConverter.INSTANCE.convert(systemUser);
|
||||
systemUserResponseVO.setToken(token);
|
||||
systemUserResponseVO.setMode(systemProperties.getMode().name());
|
||||
|
||||
if (RoleEnum.ADMIN.getRoleId().equals(systemUser.getRole())) {
|
||||
return systemUserResponseVO;
|
||||
@ -80,6 +84,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
@Override
|
||||
public SystemUserResponseVO getUserInfo(SystemUser systemUser) {
|
||||
SystemUserResponseVO systemUserResponseVO = SystemUserResponseVOConverter.INSTANCE.convert(systemUser);
|
||||
systemUserResponseVO.setMode(systemProperties.getMode().name());
|
||||
|
||||
if (RoleEnum.ADMIN.getRoleId().equals(systemUser.getRole())) {
|
||||
return systemUserResponseVO;
|
||||
@ -90,6 +95,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
systemUserResponseVO.setGroupNameList(systemUserPermissions.stream()
|
||||
.map(SystemUserPermission::getGroupName).collect(Collectors.toList()));
|
||||
|
||||
|
||||
return systemUserResponseVO;
|
||||
}
|
||||
|
||||
|
@ -99,54 +99,32 @@ export const asyncRouterMap = [
|
||||
}
|
||||
]
|
||||
},
|
||||
// {
|
||||
// path: '/retry-dead-letter',
|
||||
// name: 'RetryDeadLetter',
|
||||
// component: RouteView,
|
||||
// hideChildrenInMenu: true,
|
||||
// redirect: '/retry-dead-letter/list',
|
||||
// meta: { title: '死信队列管理', icon: 'exception', permission: ['retryDeadLetter'] },
|
||||
// children: [
|
||||
// {
|
||||
// path: '/retry-dead-letter/list',
|
||||
// name: 'RetryDeadLetterList',
|
||||
// component: () => import('@/views/task/RetryDeadLetterList'),
|
||||
// meta: { title: '死信队列管理列表', icon: 'profile', permission: ['retryDeadLetter'] }
|
||||
// },
|
||||
// {
|
||||
// path: '/retry-dead-letter/info',
|
||||
// name: 'RetryDeadLetterInfo',
|
||||
// component: () => import('@/views/task/RetryDeadLetterInfo'),
|
||||
// meta: { title: '死信队列管理详情', icon: 'profile', permission: ['retryDeadLetter'] }
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
path: '/job',
|
||||
name: 'Job',
|
||||
component: RouteView,
|
||||
redirect: '/job/list',
|
||||
meta: { title: '定时任务管理', icon: 'profile', permission: ['retryLog'] },
|
||||
meta: { title: '定时任务管理', icon: 'profile', permission: ['job'] },
|
||||
children: [
|
||||
{
|
||||
path: '/job/list',
|
||||
name: 'JobList',
|
||||
component: () => import('@/views/job/JobList'),
|
||||
meta: { title: '任务信息', icon: 'profile', permission: ['retryLog'] }
|
||||
meta: { title: '任务信息', icon: 'profile', permission: ['job'] }
|
||||
},
|
||||
{
|
||||
path: '/job/info',
|
||||
name: 'JobInfo',
|
||||
hidden: true,
|
||||
component: () => import('@/views/job/JobInfo'),
|
||||
meta: { title: '定时任务详情', icon: 'profile', permission: ['retryLog'] }
|
||||
meta: { title: '定时任务详情', icon: 'profile', permission: ['job'] }
|
||||
},
|
||||
{
|
||||
path: '/job/config',
|
||||
name: 'JobFrom',
|
||||
hidden: true,
|
||||
component: () => import('@/views/job/from/JobFrom'),
|
||||
meta: { title: '任务配置', icon: 'profile', permission: ['retryLog'] }
|
||||
meta: { title: '任务配置', icon: 'profile', permission: ['job'] }
|
||||
},
|
||||
{
|
||||
path: '/job/batch/list',
|
||||
|
@ -67,7 +67,6 @@ const permission = {
|
||||
return new Promise(resolve => {
|
||||
const { roles } = data
|
||||
const routerMap = cloneDeep(asyncRouterMap)
|
||||
console.log(routerMap)
|
||||
const accessedRouters = filterAsyncRouter(routerMap, roles)
|
||||
|
||||
console.log(routerMap)
|
||||
|
@ -52,9 +52,8 @@ const user = {
|
||||
return new Promise((resolve, reject) => {
|
||||
getInfo().then(response => {
|
||||
const result = response.data
|
||||
|
||||
result['role'] = {
|
||||
permissions: permissionsConfig(result.role)
|
||||
permissions: permissionsConfig(result.role, result.mode)
|
||||
}
|
||||
|
||||
if (result.role && result.role.permissions.length > 0) {
|
||||
|
256
frontend/src/utils/permissionsConfig.js
Normal file
256
frontend/src/utils/permissionsConfig.js
Normal file
@ -0,0 +1,256 @@
|
||||
const permissionsConfig = {
|
||||
RETRY: {
|
||||
1: [
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'group',
|
||||
permissionName: '组配置',
|
||||
actionEntitySet: []
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'dashboard',
|
||||
permissionName: '看板'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryTask',
|
||||
permissionName: '任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryDeadLetter',
|
||||
permissionName: '死信队列管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryLog',
|
||||
permissionName: '重试日志管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'basicConfig',
|
||||
permissionName: '基础信息配置'
|
||||
}
|
||||
],
|
||||
2: [
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'group',
|
||||
permissionName: '组配置',
|
||||
actionEntitySet: [
|
||||
{
|
||||
action: 'add',
|
||||
describe: '新增',
|
||||
defaultCheck: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'user',
|
||||
permissionName: '用户'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'userForm',
|
||||
permissionName: '新增或更新用户'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'dashboard',
|
||||
permissionName: '看板'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryTask',
|
||||
permissionName: '任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryDeadLetter',
|
||||
permissionName: '死信队列管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryLog',
|
||||
permissionName: '重试日志管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'basicConfig',
|
||||
permissionName: '基础信息配置'
|
||||
}
|
||||
]
|
||||
},
|
||||
JOB: {
|
||||
1: [
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'group',
|
||||
permissionName: '组配置',
|
||||
actionEntitySet: []
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'dashboard',
|
||||
permissionName: '看板'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'job',
|
||||
permissionName: '定时任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'JobBatch',
|
||||
permissionName: '任务批次'
|
||||
}
|
||||
],
|
||||
2: [
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'group',
|
||||
permissionName: '组配置',
|
||||
actionEntitySet: [
|
||||
{
|
||||
action: 'add',
|
||||
describe: '新增',
|
||||
defaultCheck: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'user',
|
||||
permissionName: '用户'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'userForm',
|
||||
permissionName: '新增或更新用户'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'dashboard',
|
||||
permissionName: '看板'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'job',
|
||||
permissionName: '定时任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'JobBatch',
|
||||
permissionName: '任务批次'
|
||||
}
|
||||
]
|
||||
},
|
||||
ALL: {
|
||||
1: [
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'group',
|
||||
permissionName: '组配置',
|
||||
actionEntitySet: []
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'dashboard',
|
||||
permissionName: '看板'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryTask',
|
||||
permissionName: '任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryDeadLetter',
|
||||
permissionName: '死信队列管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryLog',
|
||||
permissionName: '重试日志管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'basicConfig',
|
||||
permissionName: '基础信息配置'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'job',
|
||||
permissionName: '定时任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'JobBatch',
|
||||
permissionName: '任务批次'
|
||||
}
|
||||
],
|
||||
2: [
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'group',
|
||||
permissionName: '组配置',
|
||||
actionEntitySet: [
|
||||
{
|
||||
action: 'add',
|
||||
describe: '新增',
|
||||
defaultCheck: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'user',
|
||||
permissionName: '用户'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'userForm',
|
||||
permissionName: '新增或更新用户'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'dashboard',
|
||||
permissionName: '看板'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryTask',
|
||||
permissionName: '任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryDeadLetter',
|
||||
permissionName: '死信队列管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryLog',
|
||||
permissionName: '重试日志管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'basicConfig',
|
||||
permissionName: '基础信息配置'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'job',
|
||||
permissionName: '定时任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'JobBatch',
|
||||
permissionName: '任务批次'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = permissionsConfig
|
@ -1,3 +1,5 @@
|
||||
const permissionsConfig1 = require('@/utils/permissionsConfig')
|
||||
|
||||
export function timeFix () {
|
||||
const time = new Date()
|
||||
const hour = time.getHours()
|
||||
@ -94,93 +96,8 @@ export function scorePassword (pass) {
|
||||
return parseInt(score)
|
||||
}
|
||||
|
||||
export function permissionsConfig (roleId) {
|
||||
const role = {
|
||||
1: [
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'group',
|
||||
permissionName: '组配置',
|
||||
actionEntitySet: []
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'dashboard',
|
||||
permissionName: '看板'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryTask',
|
||||
permissionName: '任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryDeadLetter',
|
||||
permissionName: '死信队列管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'retryLog',
|
||||
permissionName: '重试日志管理'
|
||||
},
|
||||
{
|
||||
roleId: 1,
|
||||
permissionId: 'basicConfig',
|
||||
permissionName: '基础信息配置'
|
||||
}
|
||||
],
|
||||
2: [
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'group',
|
||||
permissionName: '组配置',
|
||||
actionEntitySet: [
|
||||
{
|
||||
action: 'add',
|
||||
describe: '新增',
|
||||
defaultCheck: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'user',
|
||||
permissionName: '用户'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'userForm',
|
||||
permissionName: '新增或更新用户'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'dashboard',
|
||||
permissionName: '看板'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryTask',
|
||||
permissionName: '任务管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryDeadLetter',
|
||||
permissionName: '死信队列管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'retryLog',
|
||||
permissionName: '重试日志管理'
|
||||
},
|
||||
{
|
||||
roleId: 2,
|
||||
permissionId: 'basicConfig',
|
||||
permissionName: '基础信息配置'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return role[roleId]
|
||||
export function permissionsConfig (roleId, mode) {
|
||||
return permissionsConfig1[mode][roleId]
|
||||
}
|
||||
|
||||
export function officialWebsite () {
|
||||
|
Loading…
Reference in New Issue
Block a user