pull/26/head
3y 2 years ago
commit cbf28fb1a7

@ -29,8 +29,8 @@ public enum AnchorState {
; ;
private Integer code; private final Integer code;
private String description; private final String description;
/** /**
* code * code

@ -21,8 +21,8 @@ public enum AuditStatus {
AUDIT_SUCCESS(20, "审核成功"), AUDIT_SUCCESS(20, "审核成功"),
AUDIT_REJECT(30, "被拒绝"); AUDIT_REJECT(30, "被拒绝");
private Integer code; private final Integer code;
private String description; private final String description;
} }

@ -34,29 +34,29 @@ public enum ChannelType {
/** /**
* *
*/ */
private Integer code; private final Integer code;
/** /**
* *
*/ */
private String description; private final String description;
/** /**
* Class * Class
*/ */
private Class contentModelClass; private final Class<? extends ContentModel> contentModelClass;
/** /**
* *
*/ */
private String codeEn; private final String codeEn;
/** /**
* codeclass * codeclass
* @param code * @param code
* @return * @return
*/ */
public static Class getChanelModelClassByCode(Integer code) { public static Class<? extends ContentModel> getChanelModelClassByCode(Integer code) {
ChannelType[] values = values(); ChannelType[] values = values();
for (ChannelType value : values) { for (ChannelType value : values) {
if (value.getCode().equals(code)) { if (value.getCode().equals(code)) {

@ -19,8 +19,8 @@ public enum DeduplicationType {
CONTENT(10, "N分钟相同内容去重"), CONTENT(10, "N分钟相同内容去重"),
FREQUENCY(20, "一天内N次相同渠道去重"), FREQUENCY(20, "一天内N次相同渠道去重"),
; ;
private Integer code; private final Integer code;
private String description; private final String description;
/** /**

@ -19,8 +19,8 @@ public enum FileType {
COMMON_FILE("30", "file"), COMMON_FILE("30", "file"),
VIDEO("40", "video"), VIDEO("40", "video"),
; ;
private String code; private final String code;
private String name; private final String name;
public static String getNameByCode(String code) { public static String getNameByCode(String code) {
for (FileType fileType : FileType.values()) { for (FileType fileType : FileType.values()) {

@ -25,8 +25,8 @@ public enum IdType {
FEI_SHU_USER_ID(90, "fei_shu_user_id"), FEI_SHU_USER_ID(90, "fei_shu_user_id"),
; ;
private Integer code; private final Integer code;
private String description; private final String description;
} }

@ -24,8 +24,8 @@ public enum MessageStatus {
SEND_SUCCESS(60, "发送成功"), SEND_SUCCESS(60, "发送成功"),
SEND_FAIL(70, "发送失败"); SEND_FAIL(70, "发送失败");
private Integer code; private final Integer code;
private String description; private final String description;
} }

@ -21,18 +21,18 @@ public enum MessageType {
/** /**
* *
*/ */
private Integer code; private final Integer code;
/** /**
* *
*/ */
private String description; private final String description;
/** /**
* *
*/ */
private String codeEn; private final String codeEn;
/** /**

@ -33,28 +33,28 @@ public enum SendMessageType {
; ;
private String code; private final String code;
private String description; private final String description;
/** /**
* *
*/ */
private String dingDingRobotType; private final String dingDingRobotType;
/** /**
* *
*/ */
private String dingDingWorkType; private final String dingDingWorkType;
/** /**
* *
*/ */
private String enterpriseWeChatRobotType; private final String enterpriseWeChatRobotType;
/** /**
* *
*/ */
private String feiShuRobotType; private final String feiShuRobotType;
/** /**

@ -19,8 +19,8 @@ public enum ShieldType {
NIGHT_SHIELD(20, "夜间屏蔽"), NIGHT_SHIELD(20, "夜间屏蔽"),
NIGHT_SHIELD_BUT_NEXT_DAY_SEND(30, "夜间屏蔽(次日早上9点发送)"); NIGHT_SHIELD_BUT_NEXT_DAY_SEND(30, "夜间屏蔽(次日早上9点发送)");
private Integer code; private final Integer code;
private String description; private final String description;

@ -18,8 +18,8 @@ public enum SmsStatus {
RECEIVE_FAIL(30, "用户收不到短信(收到渠道短信回执,状态失败)"), RECEIVE_FAIL(30, "用户收不到短信(收到渠道短信回执,状态失败)"),
SEND_FAIL(40, "调用渠道接口发送失败"); SEND_FAIL(40, "调用渠道接口发送失败");
private Integer code; private final Integer code;
private String description; private final String description;
/** /**

@ -17,8 +17,8 @@ public enum SmsSupplier {
TENCENT(10,"腾讯渠道商"), TENCENT(10,"腾讯渠道商"),
YUN_PAIN(20,"云片渠道商"); YUN_PAIN(20,"云片渠道商");
private Integer code; private final Integer code;
private String description; private final String description;
/** /**

@ -17,7 +17,7 @@ public enum TemplateType {
REALTIME(20, "实时类的模板(接口实时调用)"), REALTIME(20, "实时类的模板(接口实时调用)"),
; ;
private Integer code; private final Integer code;
private String description; private final String description;
} }

@ -23,6 +23,7 @@ import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
/** /**
@ -56,7 +57,7 @@ public class CrowdBatchTaskPending extends AbstractLazyPending<CrowdInfoVo> {
for (CrowdInfoVo crowdInfoVo : crowdInfoVos) { for (CrowdInfoVo crowdInfoVo : crowdInfoVos) {
String receiver = crowdInfoVo.getReceiver(); String receiver = crowdInfoVo.getReceiver();
Map<String, String> vars = crowdInfoVo.getParams(); Map<String, String> vars = crowdInfoVo.getParams();
if (paramMap.get(vars) == null) { if (Objects.isNull(paramMap.get(vars))) {
paramMap.put(vars, receiver); paramMap.put(vars, receiver);
} else { } else {
String newReceiver = StringUtils.join(new String[]{ String newReceiver = StringUtils.join(new String[]{

@ -10,10 +10,7 @@ import com.java3y.austin.cron.vo.CrowdInfoVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.FileReader; import java.io.FileReader;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* *
@ -97,7 +94,7 @@ public class ReadFileUtils {
List<CrowdInfoVo> result = new ArrayList<>(); List<CrowdInfoVo> result = new ArrayList<>();
try { try {
CsvData data = CsvUtil.getReader().read(FileUtil.file(path)); CsvData data = CsvUtil.getReader().read(FileUtil.file(path));
if (data == null || data.getRow(0) == null || data.getRow(1) == null) { if (Objects.isNull(data) || Objects.isNull(data.getRow(0)) || Objects.isNull(data.getRow(1))) {
log.error("read csv file empty!,path:{}", path); log.error("read csv file empty!,path:{}", path);
} }
// 第一行为默认为头信息,所以遍历从第二行开始,第一列默认为接收者Id(不处理) // 第一行为默认为头信息,所以遍历从第二行开始,第一列默认为接收者Id(不处理)

@ -6,10 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/** /**
* *
@ -44,7 +41,7 @@ public class XxlJobGroup {
private List<String> registryList; private List<String> registryList;
public List<String> getRegistryList() { public List<String> getRegistryList() {
if (addressList != null && addressList.trim().length() > 0) { if (Objects.nonNull(addressList) && addressList.trim().length() > 0) {
registryList = new ArrayList<String>(Arrays.asList(addressList.split(","))); registryList = new ArrayList<String>(Arrays.asList(addressList.split(",")));
} }
return registryList; return registryList;

@ -21,6 +21,7 @@ import java.net.HttpCookie;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
@ -42,7 +43,7 @@ public class CronTaskServiceImpl implements CronTaskService {
@Override @Override
public BasicResultVO saveCronTask(XxlJobInfo xxlJobInfo) { public BasicResultVO saveCronTask(XxlJobInfo xxlJobInfo) {
Map<String, Object> params = JSON.parseObject(JSON.toJSONString(xxlJobInfo), Map.class); Map<String, Object> params = JSON.parseObject(JSON.toJSONString(xxlJobInfo), Map.class);
String path = xxlJobInfo.getId() == null ? xxlAddresses + XxlJobConstant.INSERT_URL String path = Objects.isNull(xxlJobInfo.getId()) ? xxlAddresses + XxlJobConstant.INSERT_URL
: xxlAddresses + XxlJobConstant.UPDATE_URL; : xxlAddresses + XxlJobConstant.UPDATE_URL;
HttpResponse response; HttpResponse response;
@ -145,7 +146,7 @@ public class CronTaskServiceImpl implements CronTaskService {
try { try {
response = HttpRequest.post(path).form(params).cookie(getCookie()).execute(); response = HttpRequest.post(path).form(params).cookie(getCookie()).execute();
Integer id = JSON.parseObject(response.body()).getJSONArray("data").getJSONObject(0).getInteger("id"); Integer id = JSON.parseObject(response.body()).getJSONArray("data").getJSONObject(0).getInteger("id");
if (response.isOk() && id != null) { if (response.isOk() && Objects.nonNull(id)) {
return BasicResultVO.success(id); return BasicResultVO.success(id);
} }
} catch (Exception e) { } catch (Exception e) {

@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date; import java.util.Date;
import java.util.Objects;
/** /**
* xxlJob * xxlJob
@ -68,7 +69,7 @@ public class XxlJobUtils {
.alarmEmail(StrUtil.EMPTY) .alarmEmail(StrUtil.EMPTY)
.childJobId(StrUtil.EMPTY).build(); .childJobId(StrUtil.EMPTY).build();
if (messageTemplate.getCronTaskId() != null) { if (Objects.nonNull(messageTemplate.getCronTaskId())) {
xxlJobInfo.setId(messageTemplate.getCronTaskId()); xxlJobInfo.setId(messageTemplate.getCronTaskId());
} }
return xxlJobInfo; return xxlJobInfo;
@ -80,7 +81,7 @@ public class XxlJobUtils {
*/ */
private Integer queryJobGroupId() { private Integer queryJobGroupId() {
BasicResultVO basicResultVO = cronTaskService.getGroupId(appName, jobHandlerName); BasicResultVO basicResultVO = cronTaskService.getGroupId(appName, jobHandlerName);
if (basicResultVO.getData() == null) { if (Objects.isNull(basicResultVO.getData())) {
XxlJobGroup xxlJobGroup = XxlJobGroup.builder().appname(appName).title(jobHandlerName).addressType(CommonConstant.FALSE).build(); XxlJobGroup xxlJobGroup = XxlJobGroup.builder().appname(appName).title(jobHandlerName).addressType(CommonConstant.FALSE).build();
if (RespStatusEnum.SUCCESS.getCode().equals(cronTaskService.createGroup(xxlJobGroup).getStatus())) { if (RespStatusEnum.SUCCESS.getCode().equals(cronTaskService.createGroup(xxlJobGroup).getStatus())) {
return (int) cronTaskService.getGroupId(appName, jobHandlerName).getData(); return (int) cronTaskService.getGroupId(appName, jobHandlerName).getData();

@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author 3y. * @author 3y.
@ -34,7 +35,7 @@ public class DeduplicationRuleService {
List<Integer> deduplicationList = DeduplicationType.getDeduplicationList(); List<Integer> deduplicationList = DeduplicationType.getDeduplicationList();
for (Integer deduplicationType : deduplicationList) { for (Integer deduplicationType : deduplicationList) {
DeduplicationParam deduplicationParam = deduplicationHolder.selectBuilder(deduplicationType).build(deduplicationConfig, taskInfo); DeduplicationParam deduplicationParam = deduplicationHolder.selectBuilder(deduplicationType).build(deduplicationConfig, taskInfo);
if (deduplicationParam != null) { if (Objects.nonNull(deduplicationParam)) {
deduplicationHolder.selectService(deduplicationType).deduplication(deduplicationParam); deduplicationHolder.selectService(deduplicationType).deduplication(deduplicationParam);
} }
} }

@ -7,6 +7,7 @@ import com.java3y.austin.handler.deduplication.DeduplicationParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
@ -26,11 +27,11 @@ public abstract class AbstractDeduplicationBuilder implements Builder {
public DeduplicationParam getParamsFromConfig(Integer key, String duplicationConfig, TaskInfo taskInfo) { public DeduplicationParam getParamsFromConfig(Integer key, String duplicationConfig, TaskInfo taskInfo) {
JSONObject object = JSONObject.parseObject(duplicationConfig); JSONObject object = JSONObject.parseObject(duplicationConfig);
if (object == null) { if (Objects.isNull(object)) {
return null; return null;
} }
DeduplicationParam deduplicationParam = JSONObject.parseObject(object.getString(DEDUPLICATION_CONFIG_PRE + key), DeduplicationParam.class); DeduplicationParam deduplicationParam = JSONObject.parseObject(object.getString(DEDUPLICATION_CONFIG_PRE + key), DeduplicationParam.class);
if (deduplicationParam == null) { if (Objects.isNull(deduplicationParam)) {
return null; return null;
} }
deduplicationParam.setTaskInfo(taskInfo); deduplicationParam.setTaskInfo(taskInfo);

@ -6,6 +6,8 @@ import com.java3y.austin.common.enums.DeduplicationType;
import com.java3y.austin.handler.deduplication.DeduplicationParam; import com.java3y.austin.handler.deduplication.DeduplicationParam;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Objects;
/** /**
* @author huskey * @author huskey
@ -21,7 +23,7 @@ public class ContentDeduplicationBuilder extends AbstractDeduplicationBuilder im
@Override @Override
public DeduplicationParam build(String deduplication, TaskInfo taskInfo) { public DeduplicationParam build(String deduplication, TaskInfo taskInfo) {
DeduplicationParam deduplicationParam = getParamsFromConfig(deduplicationType, deduplication, taskInfo); DeduplicationParam deduplicationParam = getParamsFromConfig(deduplicationType, deduplication, taskInfo);
if (deduplicationParam == null) { if (Objects.isNull(deduplicationParam)) {
return null; return null;
} }
deduplicationParam.setAnchorState(AnchorState.CONTENT_DEDUPLICATION); deduplicationParam.setAnchorState(AnchorState.CONTENT_DEDUPLICATION);

@ -8,6 +8,7 @@ import com.java3y.austin.handler.deduplication.DeduplicationParam;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.Objects;
/** /**
* @author huskey * @author huskey
@ -23,7 +24,7 @@ public class FrequencyDeduplicationBuilder extends AbstractDeduplicationBuilder
@Override @Override
public DeduplicationParam build(String deduplication, TaskInfo taskInfo) { public DeduplicationParam build(String deduplication, TaskInfo taskInfo) {
DeduplicationParam deduplicationParam = getParamsFromConfig(deduplicationType, deduplication, taskInfo); DeduplicationParam deduplicationParam = getParamsFromConfig(deduplicationType, deduplication, taskInfo);
if (deduplicationParam == null) { if (Objects.isNull(deduplicationParam)) {
return null; return null;
} }
deduplicationParam.setDeduplicationTime((DateUtil.endOfDay(new Date()).getTime() - DateUtil.current()) / 1000); deduplicationParam.setDeduplicationTime((DateUtil.endOfDay(new Date()).getTime() - DateUtil.current()) / 1000);

@ -40,7 +40,7 @@ public class SimpleLimitService extends AbstractLimitService {
String value = inRedisValue.get(key); String value = inRedisValue.get(key);
// 符合条件的用户 // 符合条件的用户
if (value != null && Integer.parseInt(value) >= param.getCountNum()) { if (Objects.nonNull(value) && Integer.parseInt(value) >= param.getCountNum()) {
filterReceiver.add(receiver); filterReceiver.add(receiver);
} else { } else {
readyPutRedisReceiver.put(receiver, key); readyPutRedisReceiver.put(receiver, key);
@ -64,8 +64,8 @@ public class SimpleLimitService extends AbstractLimitService {
Map<String, String> keyValues = new HashMap<>(readyPutRedisReceiver.size()); Map<String, String> keyValues = new HashMap<>(readyPutRedisReceiver.size());
for (Map.Entry<String, String> entry : readyPutRedisReceiver.entrySet()) { for (Map.Entry<String, String> entry : readyPutRedisReceiver.entrySet()) {
String key = entry.getValue(); String key = entry.getValue();
if (inRedisValue.get(key) != null) { if (Objects.nonNull(inRedisValue.get(key))) {
keyValues.put(key, String.valueOf(Integer.valueOf(inRedisValue.get(key)) + 1)); keyValues.put(key, String.valueOf(Integer.parseInt(inRedisValue.get(key)) + 1));
} else { } else {
keyValues.put(key, String.valueOf(CommonConstant.TRUE)); keyValues.put(key, String.valueOf(CommonConstant.TRUE));
} }

@ -19,8 +19,8 @@ public enum RateLimitStrategy {
SEND_USER_NUM_RATE_LIMIT(20, "根据发送用户数限流"), SEND_USER_NUM_RATE_LIMIT(20, "根据发送用户数限流"),
; ;
private Integer code; private final Integer code;
private String description; private final String description;
} }

@ -50,7 +50,7 @@ public class FlowControlFactory implements ApplicationContextAware {
Double rateInitValue = flowControlParam.getRateInitValue(); Double rateInitValue = flowControlParam.getRateInitValue();
// 对比 初始限流值 与 配置限流值,以 配置中心的限流值为准 // 对比 初始限流值 与 配置限流值,以 配置中心的限流值为准
Double rateLimitConfig = getRateLimitConfig(taskInfo.getSendChannel()); Double rateLimitConfig = getRateLimitConfig(taskInfo.getSendChannel());
if (rateLimitConfig != null && !rateInitValue.equals(rateLimitConfig)) { if (Objects.nonNull(rateLimitConfig) && !rateInitValue.equals(rateLimitConfig)) {
rateLimiter = RateLimiter.create(rateLimitConfig); rateLimiter = RateLimiter.create(rateLimitConfig);
flowControlParam.setRateInitValue(rateLimitConfig); flowControlParam.setRateInitValue(rateLimitConfig);
flowControlParam.setRateLimiter(rateLimiter); flowControlParam.setRateLimiter(rateLimiter);
@ -79,7 +79,7 @@ public class FlowControlFactory implements ApplicationContextAware {
private Double getRateLimitConfig(Integer channelCode) { private Double getRateLimitConfig(Integer channelCode) {
String flowControlConfig = config.getProperty(FLOW_CONTROL_KEY, CommonConstant.EMPTY_JSON_OBJECT); String flowControlConfig = config.getProperty(FLOW_CONTROL_KEY, CommonConstant.EMPTY_JSON_OBJECT);
JSONObject jsonObject = JSON.parseObject(flowControlConfig); JSONObject jsonObject = JSON.parseObject(flowControlConfig);
if (jsonObject.getDouble(FLOW_CONTROL_PREFIX + channelCode) == null) { if (Objects.isNull(jsonObject.getDouble(FLOW_CONTROL_PREFIX + channelCode))) {
return null; return null;
} }
return jsonObject.getDouble(FLOW_CONTROL_PREFIX + channelCode); return jsonObject.getDouble(FLOW_CONTROL_PREFIX + channelCode);

@ -9,6 +9,8 @@ import com.java3y.austin.support.utils.LogUtils;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
* handler * handler
@ -48,7 +50,7 @@ public abstract class BaseHandler implements Handler {
*/ */
public void flowControl(TaskInfo taskInfo) { public void flowControl(TaskInfo taskInfo) {
// 只有子类指定了限流参数,才需要限流 // 只有子类指定了限流参数,才需要限流
if (flowControlParam != null) { if (Objects.nonNull(flowControlParam)) {
flowControlFactory.flowControl(taskInfo, flowControlParam); flowControlFactory.flowControl(taskInfo, flowControlParam);
} }
} }

@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
@ -79,7 +80,7 @@ public class TencentSmsScript implements SmsScript {
* @return * @return
*/ */
private List<SmsRecord> assembleSendSmsRecord(SmsParam smsParam, SendSmsResponse response, TencentSmsAccount tencentSmsAccount) { private List<SmsRecord> assembleSendSmsRecord(SmsParam smsParam, SendSmsResponse response, TencentSmsAccount tencentSmsAccount) {
if (response == null || ArrayUtil.isEmpty(response.getSendStatusSet())) { if (Objects.isNull(response) || ArrayUtil.isEmpty(response.getSendStatusSet())) {
return null; return null;
} }
@ -150,7 +151,7 @@ public class TencentSmsScript implements SmsScript {
*/ */
private List<SmsRecord> assemblePullSmsRecord(TencentSmsAccount account, PullSmsSendStatusResponse resp) { private List<SmsRecord> assemblePullSmsRecord(TencentSmsAccount account, PullSmsSendStatusResponse resp) {
List<SmsRecord> smsRecordList = new ArrayList<>(); List<SmsRecord> smsRecordList = new ArrayList<>();
if (resp != null && resp.getPullSmsSendStatusSet() != null && resp.getPullSmsSendStatusSet().length > 0) { if (Objects.nonNull(resp) && Objects.nonNull(resp.getPullSmsSendStatusSet()) && resp.getPullSmsSendStatusSet().length > 0) {
for (PullSmsSendStatus pullSmsSendStatus : resp.getPullSmsSendStatusSet()) { for (PullSmsSendStatus pullSmsSendStatus : resp.getPullSmsSendStatusSet()) {
SmsRecord smsRecord = SmsRecord.builder() SmsRecord smsRecord = SmsRecord.builder()
.sendDate(Integer.valueOf(DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN))) .sendDate(Integer.valueOf(DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN)))

@ -81,7 +81,7 @@ public class YunPianSmsScript implements SmsScript {
private List<SmsRecord> assembleSmsRecord(SmsParam smsParam, YunPianSendResult response, YunPianSmsAccount account) { private List<SmsRecord> assembleSmsRecord(SmsParam smsParam, YunPianSendResult response, YunPianSmsAccount account) {
if (response == null || ArrayUtil.isEmpty(response.getData())) { if (Objects.isNull(response) || ArrayUtil.isEmpty(response.getData())) {
return null; return null;
} }

@ -107,8 +107,7 @@ public class AssembleAction implements BusinessProcess<SendTaskModel> {
// 得到真正的ContentModel 类型 // 得到真正的ContentModel 类型
Integer sendChannel = messageTemplate.getSendChannel(); Integer sendChannel = messageTemplate.getSendChannel();
Class contentModelClass = ChannelType.getChanelModelClassByCode(sendChannel); Class<? extends ContentModel> contentModelClass = ChannelType.getChanelModelClassByCode(sendChannel);
// 得到模板的 msgContent 和 入参 // 得到模板的 msgContent 和 入参
Map<String, String> variables = messageParam.getVariables(); Map<String, String> variables = messageParam.getVariables();
@ -117,7 +116,7 @@ public class AssembleAction implements BusinessProcess<SendTaskModel> {
// 通过反射 组装出 contentModel // 通过反射 组装出 contentModel
Field[] fields = ReflectUtil.getFields(contentModelClass); Field[] fields = ReflectUtil.getFields(contentModelClass);
ContentModel contentModel = (ContentModel) ReflectUtil.newInstance(contentModelClass); ContentModel contentModel = ReflectUtil.newInstance(contentModelClass);
for (Field field : fields) { for (Field field : fields) {
String originValue = jsonObject.getString(field.getName()); String originValue = jsonObject.getString(field.getName());

@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -33,7 +34,7 @@ public class PreParamCheckAction implements BusinessProcess<SendTaskModel> {
List<MessageParam> messageParamList = sendTaskModel.getMessageParamList(); List<MessageParam> messageParamList = sendTaskModel.getMessageParamList();
// 1.没有传入 消息模板Id 或者 messageParam // 1.没有传入 消息模板Id 或者 messageParam
if (messageTemplateId == null || CollUtil.isEmpty(messageParamList)) { if (Objects.isNull(messageTemplateId) || CollUtil.isEmpty(messageParamList)) {
context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS)); context.setNeedBreak(true).setResponse(BasicResultVO.fail(RespStatusEnum.CLIENT_BAD_PARAMETERS));
return; return;
} }

@ -21,10 +21,10 @@ public enum BusinessCode {
/** code 关联着责任链的模板 */ /** code 关联着责任链的模板 */
private String code; private final String code;
/** 类型说明 */ /** 类型说明 */
private String description; private final String description;
} }

@ -3,6 +3,8 @@ package com.java3y.austin.support.exception;
import com.java3y.austin.common.enums.RespStatusEnum; import com.java3y.austin.common.enums.RespStatusEnum;
import com.java3y.austin.support.pipeline.ProcessContext; import com.java3y.austin.support.pipeline.ProcessContext;
import java.util.Objects;
/** /**
* @author SamLee * @author SamLee
* @since 2022-03-29 * @since 2022-03-29
@ -26,7 +28,7 @@ public class ProcessException extends RuntimeException {
@Override @Override
public String getMessage() { public String getMessage() {
if (this.processContext != null) { if (Objects.nonNull(this.processContext)) {
return this.processContext.getResponse().getMsg(); return this.processContext.getResponse().getMsg();
} else { } else {
return RespStatusEnum.CONTEXT_IS_NULL.getMsg(); return RespStatusEnum.CONTEXT_IS_NULL.getMsg();

@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* *
@ -66,7 +67,7 @@ public class ProcessController {
*/ */
private void preCheck(ProcessContext context) throws ProcessException { private void preCheck(ProcessContext context) throws ProcessException {
// 上下文 // 上下文
if (context == null) { if (Objects.isNull(context)) {
context = new ProcessContext(); context = new ProcessContext();
context.setResponse(BasicResultVO.fail(RespStatusEnum.CONTEXT_IS_NULL)); context.setResponse(BasicResultVO.fail(RespStatusEnum.CONTEXT_IS_NULL));
throw new ProcessException(context); throw new ProcessException(context);
@ -81,7 +82,7 @@ public class ProcessController {
// 执行模板 // 执行模板
ProcessTemplate processTemplate = templateConfig.get(businessCode); ProcessTemplate processTemplate = templateConfig.get(businessCode);
if (processTemplate == null) { if (Objects.isNull(processTemplate)) {
context.setResponse(BasicResultVO.fail(RespStatusEnum.PROCESS_TEMPLATE_IS_NULL)); context.setResponse(BasicResultVO.fail(RespStatusEnum.PROCESS_TEMPLATE_IS_NULL));
throw new ProcessException(context); throw new ProcessException(context);
} }

@ -35,7 +35,7 @@ public class AccountUtils {
return JSON.parseObject(channelAccount.getAccountConfig(), clazz); return JSON.parseObject(channelAccount.getAccountConfig(), clazz);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("AccountUtils#getAccount fail!", Throwables.getStackTraceAsString(e)); log.error("AccountUtils#getAccount fail! e:{}", Throwables.getStackTraceAsString(e));
} }
return null; return null;
} }

@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
@ -67,7 +68,7 @@ public class OkHttpUtils {
*/ */
public String doGet(String url, Map<String, String> params, Map<String, String> headers) { public String doGet(String url, Map<String, String> params, Map<String, String> headers) {
StringBuilder sb = new StringBuilder(url); StringBuilder sb = new StringBuilder(url);
if (params != null && params.keySet().size() > 0) { if (Objects.nonNull(params) && params.keySet().size() > 0) {
boolean firstFlag = true; boolean firstFlag = true;
for (String key : params.keySet()) { for (String key : params.keySet()) {
if (firstFlag) { if (firstFlag) {
@ -96,7 +97,7 @@ public class OkHttpUtils {
public String doPost(String url, Map<String, String> params, Map<String, String> headers) { public String doPost(String url, Map<String, String> params, Map<String, String> headers) {
FormBody.Builder formBuilder = new FormBody.Builder(); FormBody.Builder formBuilder = new FormBody.Builder();
if (params != null && params.keySet().size() > 0) { if (Objects.nonNull(params) && params.keySet().size() > 0) {
for (String key : params.keySet()) { for (String key : params.keySet()) {
formBuilder.add(key, params.get(key)); formBuilder.add(key, params.get(key));
} }

@ -14,6 +14,7 @@ import org.springframework.stereotype.Component;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
@ -170,7 +171,7 @@ public class RedisUtils {
try { try {
Long execute = redisTemplate.execute(redisScript, keys, args); Long execute = redisTemplate.execute(redisScript, keys, args);
if (execute == null) { if (Objects.isNull(execute)) {
return false; return false;
} }
return CommonConstant.TRUE.equals(execute.intValue()); return CommonConstant.TRUE.equals(execute.intValue());

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects;
/** /**
* ) * )
@ -50,7 +51,7 @@ public class DataController {
@PostMapping("/sms") @PostMapping("/sms")
@ApiOperation("/获取短信下发数据") @ApiOperation("/获取短信下发数据")
public BasicResultVO getSmsData(@RequestBody DataParam dataParam) { public BasicResultVO getSmsData(@RequestBody DataParam dataParam) {
if (dataParam == null || dataParam.getDateTime() == null || StrUtil.isBlank(dataParam.getReceiver())) { if (Objects.isNull(dataParam) || Objects.isNull(dataParam.getDateTime()) || StrUtil.isBlank(dataParam.getReceiver())) {
return new BasicResultVO<>(RespStatusEnum.SUCCESS, SmsTimeLineVo.builder().items(new ArrayList<>()).build()); return new BasicResultVO<>(RespStatusEnum.SUCCESS, SmsTimeLineVo.builder().items(new ArrayList<>()).build());
} }

@ -34,6 +34,7 @@ import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -154,7 +155,7 @@ public class MessageTemplateController {
public BasicResultVO test(Long id) { public BasicResultVO test(Long id) {
MessageTemplate messageTemplate = messageTemplateService.queryById(id); MessageTemplate messageTemplate = messageTemplateService.queryById(id);
CommonAmisVo commonAmisVo = Convert4Amis.getTestContent(messageTemplate.getMsgContent()); CommonAmisVo commonAmisVo = Convert4Amis.getTestContent(messageTemplate.getMsgContent());
if (commonAmisVo != null) { if (Objects.nonNull(commonAmisVo)) {
return BasicResultVO.success(commonAmisVo); return BasicResultVO.success(commonAmisVo);
} }
return BasicResultVO.success(); return BasicResultVO.success();

@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* *
@ -60,7 +61,7 @@ public class MiniProgramController {
@PostMapping("/detailTemplate") @PostMapping("/detailTemplate")
@ApiOperation("/根据账号Id和模板ID获取模板列表") @ApiOperation("/根据账号Id和模板ID获取模板列表")
public BasicResultVO queryDetailList(Long id, String wxTemplateId) { public BasicResultVO queryDetailList(Long id, String wxTemplateId) {
if (id == null || wxTemplateId == null) { if (Objects.isNull(id) || Objects.isNull(wxTemplateId)) {
return BasicResultVO.success(RespStatusEnum.CLIENT_BAD_PARAMETERS); return BasicResultVO.success(RespStatusEnum.CLIENT_BAD_PARAMETERS);
} }
try { try {

@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* *
@ -86,7 +87,7 @@ public class OfficialAccountController {
@PostMapping("/detailTemplate") @PostMapping("/detailTemplate")
@ApiOperation("/根据账号Id和模板ID获取模板列表") @ApiOperation("/根据账号Id和模板ID获取模板列表")
public BasicResultVO queryDetailList(Long id, String wxTemplateId) { public BasicResultVO queryDetailList(Long id, String wxTemplateId) {
if (id == null || wxTemplateId == null) { if (Objects.isNull(id) || Objects.isNull(wxTemplateId)) {
return BasicResultVO.success(RespStatusEnum.CLIENT_BAD_PARAMETERS); return BasicResultVO.success(RespStatusEnum.CLIENT_BAD_PARAMETERS);
} }
try { try {
@ -113,7 +114,7 @@ public class OfficialAccountController {
public String receiptMessage(HttpServletRequest request) { public String receiptMessage(HttpServletRequest request) {
try { try {
WeChatLoginConfig configService = loginUtils.getLoginConfig(); WeChatLoginConfig configService = loginUtils.getLoginConfig();
if (configService == null) { if (Objects.isNull(configService)) {
return RespStatusEnum.DO_NOT_NEED_LOGIN.getMsg(); return RespStatusEnum.DO_NOT_NEED_LOGIN.getMsg();
} }
WxMpService wxMpService = configService.getOfficialAccountLoginService(); WxMpService wxMpService = configService.getOfficialAccountLoginService();
@ -164,7 +165,7 @@ public class OfficialAccountController {
public BasicResultVO getQrCode() { public BasicResultVO getQrCode() {
try { try {
WeChatLoginConfig configService = loginUtils.getLoginConfig(); WeChatLoginConfig configService = loginUtils.getLoginConfig();
if (configService == null) { if (Objects.isNull(configService)) {
return BasicResultVO.fail(RespStatusEnum.DO_NOT_NEED_LOGIN); return BasicResultVO.fail(RespStatusEnum.DO_NOT_NEED_LOGIN);
} }
String id = IdUtil.getSnowflake().nextIdStr(); String id = IdUtil.getSnowflake().nextIdStr();

@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
@ -26,7 +27,7 @@ public class ChannelAccountServiceImpl implements ChannelAccountService {
@Override @Override
public ChannelAccount save(ChannelAccount channelAccount) { public ChannelAccount save(ChannelAccount channelAccount) {
if (channelAccount.getId() == null) { if (Objects.isNull(channelAccount.getId())) {
channelAccount.setCreated(Math.toIntExact(DateUtil.currentSeconds())); channelAccount.setCreated(Math.toIntExact(DateUtil.currentSeconds()));
channelAccount.setIsDeleted(CommonConstant.FALSE); channelAccount.setIsDeleted(CommonConstant.FALSE);
} }

@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* Service * Service
@ -74,7 +75,7 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
@Override @Override
public MessageTemplate saveOrUpdate(MessageTemplate messageTemplate) { public MessageTemplate saveOrUpdate(MessageTemplate messageTemplate) {
if (messageTemplate.getId() == null) { if (Objects.isNull(messageTemplate.getId())) {
initStatus(messageTemplate); initStatus(messageTemplate);
} else { } else {
resetStatus(messageTemplate); resetStatus(messageTemplate);
@ -90,7 +91,7 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
Iterable<MessageTemplate> messageTemplates = messageTemplateDao.findAllById(ids); Iterable<MessageTemplate> messageTemplates = messageTemplateDao.findAllById(ids);
messageTemplates.forEach(messageTemplate -> messageTemplate.setIsDeleted(CommonConstant.TRUE)); messageTemplates.forEach(messageTemplate -> messageTemplate.setIsDeleted(CommonConstant.TRUE));
for (MessageTemplate messageTemplate : messageTemplates) { for (MessageTemplate messageTemplate : messageTemplates) {
if (messageTemplate.getCronTaskId() != null && messageTemplate.getCronTaskId() > 0) { if (Objects.nonNull(messageTemplate.getCronTaskId()) && messageTemplate.getCronTaskId() > 0) {
cronTaskService.deleteCronTask(messageTemplate.getCronTaskId()); cronTaskService.deleteCronTask(messageTemplate.getCronTaskId());
} }
} }
@ -120,12 +121,12 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
// 3.获取taskId(如果本身存在则复用原有任务如果不存在则得到新建后任务ID) // 3.获取taskId(如果本身存在则复用原有任务如果不存在则得到新建后任务ID)
Integer taskId = messageTemplate.getCronTaskId(); Integer taskId = messageTemplate.getCronTaskId();
BasicResultVO basicResultVO = cronTaskService.saveCronTask(xxlJobInfo); BasicResultVO basicResultVO = cronTaskService.saveCronTask(xxlJobInfo);
if (taskId == null && RespStatusEnum.SUCCESS.getCode().equals(basicResultVO.getStatus()) && basicResultVO.getData() != null) { if (Objects.isNull(taskId) && RespStatusEnum.SUCCESS.getCode().equals(basicResultVO.getStatus()) && Objects.nonNull(basicResultVO.getData())) {
taskId = Integer.valueOf(String.valueOf(basicResultVO.getData())); taskId = Integer.valueOf(String.valueOf(basicResultVO.getData()));
} }
// 4. 启动定时任务 // 4. 启动定时任务
if (taskId != null) { if (Objects.nonNull(taskId)) {
cronTaskService.startCronTask(taskId); cronTaskService.startCronTask(taskId);
MessageTemplate clone = ObjectUtil.clone(messageTemplate).setMsgStatus(MessageStatus.RUN.getCode()).setCronTaskId(taskId).setUpdated(Math.toIntExact(DateUtil.currentSeconds())); MessageTemplate clone = ObjectUtil.clone(messageTemplate).setMsgStatus(MessageStatus.RUN.getCode()).setCronTaskId(taskId).setUpdated(Math.toIntExact(DateUtil.currentSeconds()));
messageTemplateDao.save(clone); messageTemplateDao.save(clone);
@ -173,7 +174,7 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
messageTemplate.setUpdator(messageTemplate.getUpdator()) messageTemplate.setUpdator(messageTemplate.getUpdator())
.setMsgStatus(MessageStatus.INIT.getCode()).setAuditStatus(AuditStatus.WAIT_AUDIT.getCode()); .setMsgStatus(MessageStatus.INIT.getCode()).setAuditStatus(AuditStatus.WAIT_AUDIT.getCode());
if (messageTemplate.getCronTaskId() != null && TemplateType.CLOCKING.getCode().equals(messageTemplate.getTemplateType())) { if (Objects.nonNull(messageTemplate.getCronTaskId()) && TemplateType.CLOCKING.getCode().equals(messageTemplate.getTemplateType())) {
XxlJobInfo xxlJobInfo = xxlJobUtils.buildXxlJobInfo(messageTemplate); XxlJobInfo xxlJobInfo = xxlJobUtils.buildXxlJobInfo(messageTemplate);
cronTaskService.saveCronTask(xxlJobInfo); cronTaskService.saveCronTask(xxlJobInfo);
cronTaskService.stopCronTask(messageTemplate.getCronTaskId()); cronTaskService.stopCronTask(messageTemplate.getCronTaskId());

@ -9,6 +9,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Objects;
/** /**
* @author 3y * @author 3y
* @date 2022/12/22 * @date 2022/12/22
@ -47,7 +49,7 @@ public class LoginUtils {
public boolean needLogin() { public boolean needLogin() {
try { try {
WeChatLoginConfig bean = applicationContext.getBean(OfficialAccountParamConstant.WE_CHAT_LOGIN_CONFIG, WeChatLoginConfig.class); WeChatLoginConfig bean = applicationContext.getBean(OfficialAccountParamConstant.WE_CHAT_LOGIN_CONFIG, WeChatLoginConfig.class);
if (CommonConstant.ENV_TEST.equals(env) && bean != null) { if (CommonConstant.ENV_TEST.equals(env) && Objects.nonNull(bean)) {
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {

@ -6,6 +6,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Objects;
/** /**
@ -35,7 +36,7 @@ public class SpringFileUtils {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (out != null) { if (Objects.nonNull(out)) {
try { try {
out.close(); out.close();
} catch (IOException e) { } catch (IOException e) {

Loading…
Cancel
Save