Merge branch 'master' into vip

pull/9/head
3y 3 years ago
commit 14a0f24320

@ -1,4 +1,5 @@
![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/2ccd794db76e482680f72d60959cf368~tplv-k3u1fbpfcp-zoom-1.image)
![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/108bca55a5364a73b3fd50b8bde304d1~tplv-k3u1fbpfcp-watermark.image?)
<p align="center">
<a href="#"><img src="https://img.shields.io/badge/Author-3y-orange.svg" alt="作者"></a>
@ -8,9 +9,14 @@
<a href="https://github.com/ZhongFuCheng3y/austin"><img src="https://img.shields.io/github/stars/ZhongFuCheng3y/austin.svg?style=flat&label=GithubStars"></a>
<a href="https://github.com/ZhongFuCheng3y/austin-admin"><img src="https://img.shields.io/badge/austin前端-GitHub-green.svg" alt="作者"></a>
<a href="#项目交流"><img src="https://img.shields.io/badge/项目-交流-red.svg" alt="项目交流"></a>
<a href="https://space.bilibili.com/198434865/channel/collectiondetail?sid=435119"><img src="https://img.shields.io/badge/项目-视频-green.svg" alt="Bilibili"></a>
<a href="#如何准备面试"><img src="https://img.shields.io/badge/如何准备-面试-yellow.svg" alt="对线面试官"></a>
</p>
最近我已经在**bilibili**更新Austin的视频了哟**求关注和三连**!这是我更新的动力!!
[https://space.bilibili.com/198434865/channel/collectiondetail?sid=435119](https://space.bilibili.com/198434865/channel/collectiondetail?sid=435119)
## 项目介绍

@ -1,10 +1,10 @@
package com.java3y.austin.handler.deduplication.limit;
import cn.hutool.core.util.IdUtil;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.handler.deduplication.DeduplicationParam;
import com.java3y.austin.handler.deduplication.service.AbstractDeduplicationService;
import com.java3y.austin.support.utils.RedisUtils;
import com.java3y.austin.support.utils.SnowFlakeIdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.script.DefaultRedisScript;
@ -29,7 +29,6 @@ public class SlideWindowLimitService extends AbstractLimitService {
@Autowired
private RedisUtils redisUtils;
private SnowFlakeIdUtils snowFlakeIdUtils = new SnowFlakeIdUtils(1, 1);
private DefaultRedisScript<Long> redisScript;
@ -55,7 +54,7 @@ public class SlideWindowLimitService extends AbstractLimitService {
long nowTime = System.currentTimeMillis();
for (String receiver : taskInfo.getReceiver()) {
String key = LIMIT_TAG + deduplicationSingleKey(service, taskInfo, receiver);
String scoreValue = String.valueOf(snowFlakeIdUtils.nextId());
String scoreValue = String.valueOf(IdUtil.getSnowflake().nextId());
String score = String.valueOf(nowTime);
if (redisUtils.execLimitLua(redisScript, Arrays.asList(key), String.valueOf(param.getDeduplicationTime() * 1000), score, String.valueOf(param.getCountNum()), scoreValue)) {
filterReceiver.add(receiver);

@ -7,8 +7,10 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Set;
/**
* @author 3y
* push
*/
@NoArgsConstructor
@AllArgsConstructor
@Data

@ -6,6 +6,11 @@ import lombok.NoArgsConstructor;
import java.util.List;
/**
*
* @author 3y
*/
@NoArgsConstructor
@Data
public class YunPianSendResult {

@ -98,7 +98,8 @@ public class SmsHandler extends BaseHandler implements Handler {
if (index <= messageTypeSmsConfigs.get(i).getWeights()) {
supplier = messageTypeSmsConfigs.get(i);
int j = (i + 1) % messageTypeSmsConfigs.size(); // 取下一个供应商
// 取下一个供应商
int j = (i + 1) % messageTypeSmsConfigs.size();
if (i == j) {
return new MessageTypeSmsConfig[]{supplier};
}

@ -65,7 +65,7 @@ public class YunPianSmsScript extends BaseSmsScript implements SmsScript {
* @return
*/
private Map<String, Object> assembleParam(SmsParam smsParam, YunPianSmsAccount account) {
Map<String, Object> params = new HashMap<>();
Map<String, Object> params = new HashMap<>(8);
params.put("apikey", account.getApikey());
params.put("mobile", StringUtils.join(smsParam.getPhones(), StrUtil.C_COMMA));
params.put("tpl_id", account.getTplId());

@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReUtil;
import com.alibaba.fastjson.JSON;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.IdType;
import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.common.vo.BasicResultVO;
@ -31,7 +30,7 @@ import java.util.stream.Collectors;
public class AfterParamCheckAction implements BusinessProcess<SendTaskModel> {
public static final String PHONE_REGEX_EXP = "^((13[0-9])|(14[5,7,9])|(15[0-3,5-9])|(166)|(17[0-9])|(18[0-9])|(19[1,8,9]))\\d{8}$";
public static final String EMAIL_REGEX_EXP = "[a-zA-Z0-9]+@[a-zA-Z0-9]+\\\\.[a-zA-Z0-9]+";
public static final String EMAIL_REGEX_EXP = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$";
public static final HashMap<Integer, String> CHANNEL_REGEX_EXP = new HashMap<>();
static {

@ -1,108 +0,0 @@
package com.java3y.austin.support.utils;
/**
* id
*
* @author cao
* @date 2022-04-20 13:12
*/
public class SnowFlakeIdUtils {
/**
* (2017-01-01)
*/
private final static long START_TIMESTAMP = 1483200000000L;
/**
*
*/
private final static long SEQUENCE_BIT = 12; //***占用的位数
private final static long MACHINE_BIT = 5; //机器标识占用的位数
private final static long DATA_CENTER_BIT = 5; //数据中心占用的位数
/**
*
*/
private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT);
private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT);
private final static long MAX_DATA_CENTER_NUM = -1L ^ (-1L << DATA_CENTER_BIT);
/**
*
*/
private final static long MACHINE_LEFT = SEQUENCE_BIT;
private final static long DATA_CENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT;
private final static long TIMESTAMP_LEFT = DATA_CENTER_LEFT + DATA_CENTER_BIT;
private long dataCenterId; //数据中心
private long machineId; //机器标识
private long sequence = 0L; //***
private long lastTimeStamp = -1L; //上一次时间戳
/**
* IDID***
*
* @param dataCenterId ID
* @param machineId ID
*/
public SnowFlakeIdUtils(long dataCenterId, long machineId) {
if (dataCenterId > MAX_DATA_CENTER_NUM || dataCenterId < 0) {
throw new IllegalArgumentException(String.format("DtaCenterId 不能大于 %d 或小于 0", MAX_DATA_CENTER_NUM));
}
if (machineId > MAX_MACHINE_NUM || machineId < 0) {
throw new IllegalArgumentException(String.format("MachineId 不能大于 %d 或小于 0", MAX_MACHINE_NUM));
}
this.dataCenterId = dataCenterId;
this.machineId = machineId;
}
/**
* ID
*
* @return
*/
public synchronized long nextId() {
long currTimeStamp = System.currentTimeMillis();
if (currTimeStamp < lastTimeStamp) {
throw new RuntimeException("当前时间小于上一次记录的时间戳!");
}
if (currTimeStamp == lastTimeStamp) {
//相同毫秒内,***自增
sequence = (sequence + 1) & MAX_SEQUENCE;
//同一毫秒的序列数已经达到最大
if (sequence == 0L) {
currTimeStamp = getNextMill();
}
} else {
//不同毫秒内,***置为0
sequence = 0L;
}
lastTimeStamp = currTimeStamp;
return (currTimeStamp - START_TIMESTAMP) << TIMESTAMP_LEFT //时间戳部分
| dataCenterId << DATA_CENTER_LEFT //数据中心部分
| machineId << MACHINE_LEFT //机器标识部分
| sequence; //***部分
}
/**
*
*
* @return
*/
private long getNextMill() {
long mill = System.currentTimeMillis();
while (mill <= lastTimeStamp) {
mill = System.currentTimeMillis();
}
return mill;
}
}
Loading…
Cancel
Save