pull/57/head
3y 2 years ago
commit 6cf5cc2087

@ -4,6 +4,7 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
@ -22,7 +23,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author 3y
@ -37,6 +40,9 @@ public class YunPianSmsScript implements SmsScript {
@Autowired
private AccountUtils accountUtils;
private static final String PARAMS_SPLIT_KEY = "{|}";
private static final String PARAMS_KV_SPLIT_KEY = "{:}";
@Override
public List<SmsRecord> send(SmsParam smsParam) {
@ -78,7 +84,7 @@ public class YunPianSmsScript implements SmsScript {
params.put("apikey", account.getApikey());
params.put("mobile", StringUtils.join(smsParam.getPhones(), StrUtil.C_COMMA));
params.put("tpl_id", account.getTplId());
params.put("tpl_value", "");
params.put("tpl_value", getTplValue(smsParam));
return params;
}
@ -113,5 +119,17 @@ public class YunPianSmsScript implements SmsScript {
}
private String getTplValue(SmsParam smsParam) {
String tplValue = "";
if (StrUtil.isNotBlank(smsParam.getContent())) {
tplValue = StrUtil.split(smsParam.getContent(), PARAMS_SPLIT_KEY).stream().map(item -> {
List<String> kv = StrUtil.splitTrim(item, PARAMS_KV_SPLIT_KEY, 2);
return String.join("=", URLUtil.encodeQuery(kv.get(0)), URLUtil.encodeQuery(kv.get(1)));
}).collect(Collectors.joining("&"));
}
return tplValue;
}
}

@ -30,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-_\\u4e00-\\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
public static final String EMAIL_REGEX_EXP = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
public static final HashMap<Integer, String> CHANNEL_REGEX_EXP = new HashMap<>();

@ -182,6 +182,12 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
messageTemplate.setUpdator(messageTemplate.getUpdator())
.setMsgStatus(MessageStatus.INIT.getCode()).setAuditStatus(AuditStatus.WAIT_AUDIT.getCode());
// 从数据库查询并注入 定时任务 ID
MessageTemplate dbMsg = queryById(messageTemplate.getId());
if (Objects.nonNull(dbMsg) && Objects.nonNull(dbMsg.getCronTaskId())) {
messageTemplate.setCronTaskId(dbMsg.getCronTaskId());
}
if (Objects.nonNull(messageTemplate.getCronTaskId()) && TemplateType.CLOCKING.getCode().equals(messageTemplate.getTemplateType())) {
XxlJobInfo xxlJobInfo = xxlJobUtils.buildXxlJobInfo(messageTemplate);
cronTaskService.saveCronTask(xxlJobInfo);

@ -170,16 +170,18 @@ public class Convert4Amis {
.build();
List<CommonAmisVo.ColumnsDTO> columnsDtoS = new ArrayList<>();
for (String datum : data) {
String name = datum.substring(datum.indexOf("{{") + 2, datum.indexOf("."));
CommonAmisVo.ColumnsDTO.ColumnsDTOBuilder dtoBuilder = CommonAmisVo.ColumnsDTO.builder().name(name).type("input-text").required(true).quickEdit(true);
if (datum.contains("first")) {
dtoBuilder.label("名字");
} else if (datum.contains("remark")) {
dtoBuilder.label("备注");
} else {
dtoBuilder.label(datum.split("")[0]);
if (StrUtil.isNotEmpty(datum)) {
String name = datum.substring(datum.indexOf("{{") + 2, datum.indexOf("."));
CommonAmisVo.ColumnsDTO.ColumnsDTOBuilder dtoBuilder = CommonAmisVo.ColumnsDTO.builder().name(name).type("input-text").required(true).quickEdit(true);
if (datum.contains("first")) {
dtoBuilder.label("名字");
} else if (datum.contains("remark")) {
dtoBuilder.label("备注");
} else {
dtoBuilder.label(datum.split("")[0]);
}
columnsDtoS.add(dtoBuilder.build());
}
columnsDtoS.add(dtoBuilder.build());
}
officialAccountParam.setColumns(columnsDtoS);

Loading…
Cancel
Save