mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-08 21:26:40 +08:00
优化心跳和其他
This commit is contained in:
parent
1b1b7969f8
commit
f417c8a032
@ -5,8 +5,8 @@ import net.lab1024.smartadmin.service.common.codeconst.FileResponseCodeConst;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.dto.FileDownloadDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.file.domain.vo.FileUploadVO;
|
||||
import net.lab1024.smartadmin.service.module.support.systemconfig.SystemConfigKeyEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.systemconfig.SystemConfigService;
|
||||
import net.lab1024.smartadmin.service.module.system.systemconfig.SystemConfigKeyEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.systemconfig.SystemConfigService;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -3,7 +3,6 @@ package net.lab1024.smartadmin.service.module.support.heartbeat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@ -14,11 +13,11 @@ import java.util.Date;
|
||||
* @date
|
||||
*/
|
||||
@Data
|
||||
public class HeartBeatRecordVO implements Serializable {
|
||||
public class HeartBeatRecordVO {
|
||||
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("项目名字")
|
||||
@ApiModelProperty("项目路径")
|
||||
private String projectPath;
|
||||
|
||||
@ApiModelProperty("服务器ip")
|
||||
|
@ -1,25 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.heartbeat.core;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class HeartBeatConfig {
|
||||
|
||||
/**
|
||||
* 延迟执行时间
|
||||
*/
|
||||
private Long delayHandlerTime;
|
||||
|
||||
/**
|
||||
* 间隔执行时间
|
||||
*/
|
||||
private Long intervalTime;
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
package net.lab1024.smartadmin.service.module.support.heartbeat.core;
|
||||
|
||||
import net.lab1024.smartadmin.service.util.SmartIPUtil;
|
||||
import net.lab1024.smartadmin.service.util.SmartThreadFactory;
|
||||
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -13,6 +10,10 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class HeartBeatManager {
|
||||
|
||||
private static final String THREAD_NAME_PREFIX = "smart-admin-heart-beat";
|
||||
private static final int THREAD_COUNT = 1;
|
||||
private static final long INITIAL_DELAY = 60*1000L;
|
||||
|
||||
private ScheduledThreadPoolExecutor threadPoolExecutor;
|
||||
|
||||
/**
|
||||
@ -23,46 +24,32 @@ public class HeartBeatManager {
|
||||
/**
|
||||
* 调度配置信息
|
||||
*/
|
||||
private HeartBeatConfig config;
|
||||
private long intervalMilliseconds;
|
||||
|
||||
/**
|
||||
* 服务信息
|
||||
* @param intervalMilliseconds 间隔执行时间(毫秒)
|
||||
*/
|
||||
private HeartBeatServer server;
|
||||
|
||||
/**
|
||||
* @param delayHandlerTime 延迟执行时间
|
||||
* @param intervalTime 间隔执行时间
|
||||
*/
|
||||
public HeartBeatManager(Long delayHandlerTime,
|
||||
Long intervalTime,
|
||||
public HeartBeatManager(Long intervalMilliseconds,
|
||||
IHeartBeatRecordHandler heartBeatRecordHandler) {
|
||||
this.config = HeartBeatConfig.builder().delayHandlerTime(delayHandlerTime).intervalTime(intervalTime).build();
|
||||
this.intervalMilliseconds = intervalMilliseconds;
|
||||
this.heartBeatRecordHandler = heartBeatRecordHandler;
|
||||
this.server = handlerHeartServer();
|
||||
this.threadPoolExecutor = new ScheduledThreadPoolExecutor(1, new HeartBeatThreadFactory());
|
||||
this.heartBeatScheduler();
|
||||
//使用守护线程去处理
|
||||
this.threadPoolExecutor = new ScheduledThreadPoolExecutor(THREAD_COUNT, r -> {
|
||||
Thread t = new Thread(r, THREAD_NAME_PREFIX);
|
||||
if (!t.isDaemon()) {
|
||||
t.setDaemon(true);
|
||||
}
|
||||
return t;
|
||||
});
|
||||
// 开始心跳
|
||||
this.beginHeartBeat();
|
||||
}
|
||||
|
||||
/**
|
||||
* 调度监控服务状态
|
||||
* 开启心跳
|
||||
*/
|
||||
private void heartBeatScheduler() {
|
||||
HeartBeatRunnable heartBeatRunnable = new HeartBeatRunnable(heartBeatRecordHandler,server);
|
||||
threadPoolExecutor.scheduleWithFixedDelay(heartBeatRunnable, config.getDelayHandlerTime(), config.getIntervalTime(), TimeUnit.MILLISECONDS);
|
||||
private void beginHeartBeat() {
|
||||
HeartBeatRunnable heartBeatRunnable = new HeartBeatRunnable(heartBeatRecordHandler);
|
||||
threadPoolExecutor.scheduleWithFixedDelay(heartBeatRunnable, INITIAL_DELAY, intervalMilliseconds, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务信息
|
||||
* @return
|
||||
*/
|
||||
private HeartBeatServer handlerHeartServer(){
|
||||
HeartBeatServer server = new HeartBeatServer();
|
||||
server.setProjectPath(HeatBeatRecordHelper.getProjectPath());
|
||||
server.setServerIps(SmartIPUtil.getLocalHostIPList());
|
||||
server.setProcessNo(HeatBeatRecordHelper.getProcessID());
|
||||
server.setProcessStartTime(HeatBeatRecordHelper.getStartTime());
|
||||
return server;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.lab1024.smartadmin.service.module.support.heartbeat.core;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Description: 心跳记录日志
|
||||
@ -27,11 +27,11 @@ public class HeartBeatRecord {
|
||||
/**
|
||||
* 进程开启时间
|
||||
*/
|
||||
private Date processStartTime;
|
||||
private LocalDateTime processStartTime;
|
||||
/**
|
||||
* 心跳当前时间
|
||||
*/
|
||||
private Date heartBeatTime;
|
||||
private LocalDateTime heartBeatTime;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,14 @@
|
||||
package net.lab1024.smartadmin.service.module.support.heartbeat.core;
|
||||
|
||||
import net.lab1024.smartadmin.service.util.SmartIPUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
@ -12,23 +18,50 @@ import java.util.Date;
|
||||
*/
|
||||
public class HeartBeatRunnable implements Runnable {
|
||||
|
||||
/**
|
||||
* 项目路径
|
||||
*/
|
||||
private String projectPath;
|
||||
/**
|
||||
* 服务器ip(多网卡)
|
||||
*/
|
||||
private List<String> serverIps;
|
||||
/**
|
||||
* 进程号
|
||||
*/
|
||||
private Integer processNo;
|
||||
/**
|
||||
* 进程开启时间
|
||||
*/
|
||||
private LocalDateTime processStartTime;
|
||||
|
||||
private IHeartBeatRecordHandler recordHandler;
|
||||
|
||||
private HeartBeatServer server;
|
||||
|
||||
public HeartBeatRunnable(IHeartBeatRecordHandler recordHandler, HeartBeatServer server) {
|
||||
public HeartBeatRunnable(IHeartBeatRecordHandler recordHandler) {
|
||||
this.recordHandler = recordHandler;
|
||||
this.server = server;
|
||||
this.initServerInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化心跳相关信息
|
||||
*/
|
||||
private void initServerInfo(){
|
||||
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
|
||||
this.projectPath = System.getProperty("user.dir");
|
||||
this.serverIps = SmartIPUtil.getLocalHostIPList();
|
||||
this.processNo = Integer.valueOf(runtimeMXBean.getName().split("@")[0]).intValue();
|
||||
this.processStartTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(runtimeMXBean.getStartTime()), ZoneId.systemDefault());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
HeartBeatRecord heartBeatRecord = new HeartBeatRecord();
|
||||
heartBeatRecord.setProjectPath(server.getProjectPath());
|
||||
heartBeatRecord.setServerIp(StringUtils.join(server.getServerIps(), ";"));
|
||||
heartBeatRecord.setProcessNo(server.getProcessNo());
|
||||
heartBeatRecord.setProcessStartTime(server.getProcessStartTime());
|
||||
heartBeatRecord.setHeartBeatTime(new Date());
|
||||
heartBeatRecord.setProjectPath(this.projectPath);
|
||||
heartBeatRecord.setServerIp(StringUtils.join(this.serverIps, ";"));
|
||||
heartBeatRecord.setProcessNo(this.processNo);
|
||||
heartBeatRecord.setProcessStartTime(this.processStartTime);
|
||||
heartBeatRecord.setHeartBeatTime(LocalDateTime.now());
|
||||
recordHandler.handler(heartBeatRecord);
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.heartbeat.core;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @date 2021/9/23 19:39
|
||||
*/
|
||||
@Data
|
||||
public class HeartBeatServer {
|
||||
|
||||
/**
|
||||
* 项目路径
|
||||
*/
|
||||
private String projectPath;
|
||||
/**
|
||||
* 服务器ip(多网卡)
|
||||
*/
|
||||
private List<String> serverIps;
|
||||
/**
|
||||
* 进程号
|
||||
*/
|
||||
private Integer processNo;
|
||||
/**
|
||||
* 进程开启时间
|
||||
*/
|
||||
private Date processStartTime;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.heartbeat.core;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @date 2021/9/23 20:19
|
||||
*/
|
||||
public class HeartBeatThreadFactory implements ThreadFactory {
|
||||
|
||||
private static String namePrefix = "heart-beat";
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(r, namePrefix);
|
||||
if (!t.isDaemon()) {
|
||||
t.setDaemon(true);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.heartbeat.core;
|
||||
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 心跳工具类
|
||||
* @Author: 1024lab
|
||||
* @Date: 2018/7/9 11:48
|
||||
*/
|
||||
public class HeatBeatRecordHelper {
|
||||
|
||||
/**
|
||||
* 获取进程号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static final Integer getProcessID() {
|
||||
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
|
||||
return Integer.valueOf(runtimeMXBean.getName().split("@")[0])
|
||||
.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目名称
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static final String getProjectPath() {
|
||||
return System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进程启动时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static final Date getStartTime() {
|
||||
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
|
||||
return new Date(runtimeMXBean.getStartTime());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.redismq;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @date 2020/9/6 15:53
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RedisMqHandle {
|
||||
|
||||
RedisMsgTypeEnum value();
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.redismq;
|
||||
|
||||
import net.lab1024.smartadmin.service.common.constant.BaseEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @date 2021/5/10 11:44
|
||||
*/
|
||||
public enum RedisMqTopicEnum implements BaseEnum {
|
||||
|
||||
|
||||
SMART_ADMIN("smartAdmin","主题"),
|
||||
|
||||
;
|
||||
|
||||
private String type;
|
||||
|
||||
private String desc;
|
||||
|
||||
RedisMqTopicEnum(String type, String desc) {
|
||||
this.type = type;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取枚举类的值
|
||||
*
|
||||
* @return Integer
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取枚举类的说明
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.redismq;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @date 2021/5/10 11:04
|
||||
*/
|
||||
@Data
|
||||
public class RedisMsgDTO {
|
||||
|
||||
/**
|
||||
* @see RedisMsgTypeEnum
|
||||
*/
|
||||
private Integer msgType;
|
||||
|
||||
private String jsonData;
|
||||
|
||||
public RedisMsgDTO(Integer msgType, String jsonData) {
|
||||
this.msgType = msgType;
|
||||
this.jsonData = jsonData;
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.redismq;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.third.SmartApplicationContext;
|
||||
import net.lab1024.smartadmin.service.util.SmartBaseEnumUtil;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.MethodAnnotationsScanner;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* redis 订阅消息处理类
|
||||
*
|
||||
* @author 胡克
|
||||
* @date 2019/12/25 15:02
|
||||
*/
|
||||
@Slf4j
|
||||
public class RedisMsgHandler {
|
||||
|
||||
public static final String METHOD_NAME = "receiveMessage";
|
||||
|
||||
private Map<RedisMsgTypeEnum, Method> redisHandle = Maps.newConcurrentMap();
|
||||
|
||||
public RedisMsgHandler(String scanPath) {
|
||||
this.redisMqHandleFunction(scanPath);
|
||||
}
|
||||
|
||||
public void redisMqHandleFunction(String scanPath) {
|
||||
Reflections reflections = new Reflections(new ConfigurationBuilder().forPackages(scanPath).addScanners(new MethodAnnotationsScanner()));
|
||||
Set<Method> methods = reflections.getMethodsAnnotatedWith(RedisMqHandle.class);
|
||||
for (Method method : methods) {
|
||||
RedisMqHandle redisMqHandle = method.getAnnotation(RedisMqHandle.class);
|
||||
if (redisMqHandle != null) {
|
||||
redisHandle.put(redisMqHandle.value(), method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void receiveMessage(String jsonMsg) throws InvocationTargetException, IllegalAccessException {
|
||||
log.info("Redis订阅消息处理:接收到消息->{}", jsonMsg);
|
||||
RedisMsgDTO redisMsgDTO = JSONObject.parseObject(jsonMsg, RedisMsgDTO.class);
|
||||
if (redisMsgDTO.getMsgType() == null) {
|
||||
log.error("Redis消息暂未指定消息类型");
|
||||
return;
|
||||
}
|
||||
RedisMsgTypeEnum msgTypeEnum = SmartBaseEnumUtil.getEnumByValue(redisMsgDTO.getMsgType(), RedisMsgTypeEnum.class);
|
||||
if (msgTypeEnum == null) {
|
||||
log.error("Redis消息类型错误");
|
||||
return;
|
||||
}
|
||||
Method handleMethod = redisHandle.get(msgTypeEnum);
|
||||
if (handleMethod == null) {
|
||||
log.error("Redis消息类型:{},暂未找到对应的处理类", msgTypeEnum.getDesc());
|
||||
return;
|
||||
}
|
||||
if (handleMethod.getParameterCount() == 0) {
|
||||
log.error("Redis消息类型:{},处理方法:{},无入参信息", msgTypeEnum.getDesc(), handleMethod.getName());
|
||||
return;
|
||||
}
|
||||
Object object = SmartApplicationContext.getBean(handleMethod.getDeclaringClass());
|
||||
if (object == null) {
|
||||
log.error("Redis消息类型处理方法:{},对应的类:{},无对应的bean", msgTypeEnum.getDesc(), handleMethod.getDeclaringClass());
|
||||
return;
|
||||
}
|
||||
handleMethod.invoke(object, redisMsgDTO.getJsonData());
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.module.support.redismq;
|
||||
|
||||
|
||||
import net.lab1024.smartadmin.service.common.constant.BaseEnum;
|
||||
|
||||
/**
|
||||
* [ ]
|
||||
*
|
||||
* @author 罗伊
|
||||
* @date 2021/5/10 11:03
|
||||
*/
|
||||
public enum RedisMsgTypeEnum implements BaseEnum {
|
||||
|
||||
CACHE_CLEAR(1,"清除缓存"),
|
||||
|
||||
CACHE_KEY_CLEAR(2,"清除缓存key")
|
||||
;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private String desc;
|
||||
|
||||
RedisMsgTypeEnum(Integer type, String desc) {
|
||||
this.type = type;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取枚举类的值
|
||||
*
|
||||
* @return Integer
|
||||
*/
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取枚举类的说明
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
@ -13,14 +13,14 @@ import java.lang.annotation.Target;
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface NoRepeatSubmit {
|
||||
public @interface RepeatSubmit {
|
||||
|
||||
/**
|
||||
* 重复提交间隔时间/毫秒
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int value() default 1200;
|
||||
int value();
|
||||
|
||||
/**
|
||||
* 最长间隔30s
|
@ -4,13 +4,12 @@ import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* [ ]
|
||||
* 重复提交的ticket
|
||||
*
|
||||
* @author 罗伊
|
||||
* @date
|
||||
* @author zhuoda
|
||||
*/
|
||||
@Data
|
||||
public class SmartRepeatSubmitUserDTO {
|
||||
public class RepeatSubmitTicket {
|
||||
|
||||
/**
|
||||
* 用户id
|
@ -33,16 +33,16 @@ public class SmartRepeatSubmitAspect {
|
||||
*/
|
||||
private static Cache<Object, Object> cache = Caffeine.newBuilder()
|
||||
.maximumSize(5000)
|
||||
.expireAfterWrite(NoRepeatSubmit.MAX_INTERVAL, TimeUnit.MILLISECONDS).build();
|
||||
.expireAfterWrite(RepeatSubmit.MAX_INTERVAL, TimeUnit.MILLISECONDS).build();
|
||||
|
||||
private Function<HttpServletRequest, SmartRepeatSubmitUserDTO> userFunction;
|
||||
private Function<HttpServletRequest, RepeatSubmitTicket> userFunction;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @param userFunction
|
||||
*/
|
||||
public SmartRepeatSubmitAspect(Function<HttpServletRequest, SmartRepeatSubmitUserDTO> userFunction) {
|
||||
public SmartRepeatSubmitAspect(Function<HttpServletRequest, RepeatSubmitTicket> userFunction) {
|
||||
this.userFunction = userFunction;
|
||||
}
|
||||
|
||||
@ -53,11 +53,11 @@ public class SmartRepeatSubmitAspect {
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
@Around("@annotation(net.lab1024.smartadmin.service.module.support.repeatsubmit.NoRepeatSubmit)")
|
||||
@Around("@annotation(net.lab1024.smartadmin.service.module.support.repeatsubmit.RepeatSubmit)")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
|
||||
SmartRepeatSubmitUserDTO user = this.userFunction.apply(request);
|
||||
RepeatSubmitTicket user = this.userFunction.apply(request);
|
||||
if (user == null) {
|
||||
return point.proceed();
|
||||
}
|
||||
@ -68,8 +68,8 @@ public class SmartRepeatSubmitAspect {
|
||||
Object value = cache.getIfPresent(key);
|
||||
if (value != null) {
|
||||
Method method = ((MethodSignature) point.getSignature()).getMethod();
|
||||
NoRepeatSubmit annotation = method.getAnnotation(NoRepeatSubmit.class);
|
||||
int interval = Math.min(annotation.value(), NoRepeatSubmit.MAX_INTERVAL);
|
||||
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
||||
int interval = Math.min(annotation.value(), RepeatSubmit.MAX_INTERVAL);
|
||||
if (System.currentTimeMillis() < (long) value + interval) {
|
||||
// 提交频繁
|
||||
return ResponseDTO.wrap(ResponseCodeConst.REPEAT_SUBMIT);
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.lab1024.smartadmin.service.module.system.menu;
|
||||
|
||||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
||||
import net.lab1024.smartadmin.service.module.support.systemconfig.SystemConfigKeyEnum;
|
||||
import net.lab1024.smartadmin.service.module.support.systemconfig.SystemConfigService;
|
||||
import net.lab1024.smartadmin.service.module.system.systemconfig.SystemConfigKeyEnum;
|
||||
import net.lab1024.smartadmin.service.module.system.systemconfig.SystemConfigService;
|
||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeService;
|
||||
import net.lab1024.smartadmin.service.module.system.login.domain.EmployeeLoginInfoDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.menu.constant.MenuTypeEnum;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -6,7 +6,7 @@ import net.lab1024.smartadmin.service.common.constant.SwaggerTagConst;
|
||||
import net.lab1024.smartadmin.service.common.controller.SupportBaseController;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.systemconfig.domain.*;
|
||||
import net.lab1024.smartadmin.service.module.system.systemconfig.domain.*;
|
||||
import net.lab1024.smartadmin.service.util.SmartBeanUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
@ -1,9 +1,9 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.smartadmin.service.module.support.systemconfig.domain.SystemConfigEntity;
|
||||
import net.lab1024.smartadmin.service.module.support.systemconfig.domain.SystemConfigQueryDTO;
|
||||
import net.lab1024.smartadmin.service.module.system.systemconfig.domain.SystemConfigEntity;
|
||||
import net.lab1024.smartadmin.service.module.system.systemconfig.domain.SystemConfigQueryDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -6,7 +6,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.smartadmin.service.common.codeconst.ResponseCodeConst;
|
||||
import net.lab1024.smartadmin.service.common.domain.PageResultDTO;
|
||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||
import net.lab1024.smartadmin.service.module.support.systemconfig.domain.*;
|
||||
import net.lab1024.smartadmin.service.module.system.systemconfig.domain.*;
|
||||
import net.lab1024.smartadmin.service.util.SmartBaseEnumUtil;
|
||||
import net.lab1024.smartadmin.service.util.SmartBeanUtil;
|
||||
import net.lab1024.smartadmin.service.util.SmartPageUtil;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig.domain;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig.domain;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig.domain;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig.domain;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig.domain;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
@ -1,4 +1,4 @@
|
||||
package net.lab1024.smartadmin.service.module.support.systemconfig.domain;
|
||||
package net.lab1024.smartadmin.service.module.system.systemconfig.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
@ -1,44 +0,0 @@
|
||||
package net.lab1024.smartadmin.service.util;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 拥有自己的thread facotry是为了jstack时候能看到是哪个线程
|
||||
*
|
||||
* @author jiaozi
|
||||
*/
|
||||
public class SmartThreadFactory implements ThreadFactory {
|
||||
|
||||
public static SmartThreadFactory create(String namePrefix) {
|
||||
return new SmartThreadFactory(namePrefix);
|
||||
}
|
||||
|
||||
private final AtomicInteger poolNumber = new AtomicInteger(1);
|
||||
|
||||
private final ThreadGroup group;
|
||||
|
||||
private final AtomicInteger threadNumber = new AtomicInteger(1);
|
||||
|
||||
private final String namePrefix;
|
||||
|
||||
private SmartThreadFactory(String namePrefix) {
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
|
||||
this.namePrefix = namePrefix + " pool " + poolNumber.getAndIncrement() + "-thread-";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
|
||||
if (t.isDaemon()) {
|
||||
t.setDaemon(false);
|
||||
}
|
||||
|
||||
if (t.getPriority() != Thread.NORM_PRIORITY) {
|
||||
t.setPriority(Thread.NORM_PRIORITY);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
@ -22,9 +22,9 @@ spring.jackson.time-zone=GMT+8
|
||||
spring.jackson.serialization.write-dates-as-timestamps=false
|
||||
|
||||
######################### database #########################
|
||||
spring.datasource.url=jdbc:p6spy:mysql://115.29.150.222:11024/smart_admin_v2?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
|
||||
spring.datasource.url=jdbc:p6spy:mysql://127.0.0.1:3306/smart_admin_v2?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=11024Lab
|
||||
spring.datasource.password=root
|
||||
spring.datasource.initial-size=2
|
||||
spring.datasource.min-idle=1
|
||||
spring.datasource.max-active=10
|
||||
@ -40,14 +40,14 @@ spring.datasource.druid.service.scanner=net.lab1024.smartadmin.module..*Service.
|
||||
|
||||
######################### redis #######################################
|
||||
spring.redis.database=1
|
||||
spring.redis.host=115.29.150.222
|
||||
spring.redis.host=127.0.0.1
|
||||
spring.redis.lettuce.pool.max-active=100
|
||||
spring.redis.lettuce.pool.min-idle=5
|
||||
spring.redis.lettuce.pool.max-idle=10
|
||||
spring.redis.lettuce.pool.max-wait=30000ms
|
||||
spring.redis.port=21024
|
||||
spring.redis.port=1234
|
||||
spring.redis.timeout=10000ms
|
||||
spring.redis.password=21024Lab
|
||||
spring.redis.password=root
|
||||
|
||||
######################### swagger #########################
|
||||
swagger.apiGroupName=smartAdmin
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.smartadmin.service.module.support.systemconfig.SystemConfigDao">
|
||||
<mapper namespace="net.lab1024.smartadmin.service.module.system.systemconfig.SystemConfigDao">
|
||||
<!-- 分页查询系统配置 -->
|
||||
<select id="queryByPage" resultType="net.lab1024.smartadmin.service.module.support.systemconfig.domain.SystemConfigEntity">
|
||||
<select id="queryByPage" resultType="net.lab1024.smartadmin.service.module.system.systemconfig.domain.SystemConfigEntity">
|
||||
SELECT *
|
||||
FROM t_system_config
|
||||
<where>
|
||||
@ -13,7 +13,7 @@
|
||||
</select>
|
||||
|
||||
<!-- 根据key查询获取数据 -->
|
||||
<select id="selectByKey" resultType="net.lab1024.smartadmin.service.module.support.systemconfig.domain.SystemConfigEntity">
|
||||
<select id="selectByKey" resultType="net.lab1024.smartadmin.service.module.system.systemconfig.domain.SystemConfigEntity">
|
||||
SELECT *
|
||||
FROM t_system_config
|
||||
WHERE config_key = #{key}
|
||||
|
Loading…
Reference in New Issue
Block a user