邮箱黑名单

main
youHong.ai 2023-04-21 15:28:34 +08:00
parent 1aac6f6cc4
commit e23fc2161e
11 changed files with 93 additions and 132 deletions

View File

@ -113,9 +113,12 @@
```properties
serverName=ecology
rootPath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/src/main/resources/ # 修改为实际的地址
systemFilePath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/file # 修改为实际的地址这里可以是你实际ecology的文件地址即.../ecolog/web-inf/systemfile 绝对路径
logPath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/log # 修改为实际的地址
# 修改为实际的地址
rootPath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/src/main/resources/
# 修改为实际的地址这里可以是你实际ecology的文件地址即.../ecolog/web-inf/systemfile 绝对路径
systemFilePath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/file
# 修改为实际的地址
logPath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/log
```
### 测试

View File

@ -26,4 +26,8 @@ public class RequestLogAuthority {
/** 权限组成员 */
@SqlOracleDbFieldAnn("AUTHORITY_MEMBER")
private String authorityMember;
/** */
@SqlOracleDbFieldAnn("DEFAULT_VALUE")
private String defaultValue;
}

View File

@ -30,13 +30,22 @@ public class RequestLogAuthorityService {
result.put("show", false);
return result;
}
if (StrUtil.isBlank(requestId) || "-1".equals(requestId)) {
result.put("enable", false);
if ("1".equals(requestLogAuthority.getDefaultValue())) {
result.put("enable", true);
} else {
result.put("enable", false);
}
return result;
}
Integer id = mapper.selectRequestLogId(requestId, nodeId, String.valueOf(user.getUID()));
if (id <= 0) {
result.put("enable", false);
if ("1".equals(requestLogAuthority.getDefaultValue())) {
result.put("enable", true);
} else {
result.put("enable", false);
}
} else {
result.put("enable", true);
}

View File

@ -12,7 +12,6 @@ import com.engine.workflow.cmd.requestForm.remind.GetEmailRemindUrlCmd;
import com.engine.workflow.constant.RemindTypeEnum;
import com.engine.workflow.util.GetCustomLevelUtil;
import com.engine.workflow.util.WfToDocUtil;
import com.engine.youhong.ai.taibao.email.BlackListExpansion;
import com.engine.youhong.ai.taibao.email.BlackListRegister;
import com.google.common.base.Strings;
import weaver.conn.RecordSet;
@ -1747,11 +1746,9 @@ public class RequestRemindBiz {
}
}
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */
for (BlackListExpansion blackListExpansion : BlackListRegister.getExpansionList()) {
Set<String> mailAddress1 = blackListExpansion.sendEmailHandler(mailAddress);
if (Objects.nonNull(mailAddress1)) {
mailAddress = mailAddress1;
}
Set<String> expansionList = BlackListRegister.getExpansionList(mailAddress);
if (Objects.nonNull(expansionList)) {
mailAddress = expansionList;
}
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */
if (mailAddress.isEmpty()) return;
@ -1784,11 +1781,9 @@ public class RequestRemindBiz {
}
}
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */
for (BlackListExpansion blackListExpansion : BlackListRegister.getExpansionApproveList()) {
Set<String> mailAddress1 = blackListExpansion.sendEmailHandler(mailAddress);
if (Objects.nonNull(mailAddress1)) {
mailAddress = mailAddress1;
}
Set<String> expansionList = BlackListRegister.getExpansionApproveList(mailAddress);
if (Objects.nonNull(expansionList)) {
mailAddress = expansionList;
}
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */
EmailApprovalRunnable.threadModeReminder(String.join(",", mailAddress), title, content, String.valueOf(requestId), allAttchment);

View File

@ -1,21 +0,0 @@
package com.engine.youhong.ai.taibao.email;
import java.util.Set;
/**
* <h1></h1>
*
* <p>create: 2023/4/14 17:07</p>
*
* @author youHong.ai
*/
public interface BlackListExpansion {
/**
* <h2></h2>
*
* @param mailAddress
* @return
*/
Set<String> sendEmailHandler(Set<String> mailAddress);
}

View File

@ -1,8 +1,14 @@
package com.engine.youhong.ai.taibao.email;
import java.util.ArrayList;
import aiyh.utils.Util;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import com.engine.youhong.ai.taibao.email.mapper.InitBlackEmailListMapper;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
* <h1></h1>
@ -13,26 +19,42 @@ import java.util.Objects;
*/
public class BlackListRegister {
private static final List<BlackListExpansion> EXPANSION_LIST = new ArrayList<>();
private static final List<BlackListExpansion> EXPANSION_APPROVE_LIST = new ArrayList<>();
public static void registerExpansion(BlackListExpansion blackListExpansion) {
if (Objects.nonNull(blackListExpansion)) {
EXPANSION_LIST.add(blackListExpansion);
private static final InitBlackEmailListMapper mapper = Util.getMapper(InitBlackEmailListMapper.class);
public static Set<String> getExpansionList(Set<String> set) {
if (Objects.isNull(set)) {
return null;
}
}
public static void registerAPPROVEExpansion(BlackListExpansion blackListExpansion) {
if (Objects.nonNull(blackListExpansion)) {
EXPANSION_APPROVE_LIST.add(blackListExpansion);
List<String> hrmList = mapper.selectWorkflowBlackEmailList();
if (CollectionUtil.isEmpty(hrmList)) {
return null;
}
String ids = Util.join(hrmList, ",");
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
if (CollectionUtil.isEmpty(blackEmailList)) {
return set;
}
return set.stream()
.filter(item -> !blackEmailList.contains(item))
.collect(Collectors.toSet());
}
public static List<BlackListExpansion> getExpansionList() {
return EXPANSION_LIST;
}
public static List<BlackListExpansion> getExpansionApproveList() {
return EXPANSION_APPROVE_LIST;
public static Set<String> getExpansionApproveList(Set<String> set) {
if (Objects.isNull(set)) {
return null;
}
String ids = mapper.selectWorkflowApproveBlackEmailList();
if (StrUtil.isBlank(ids)) {
return null;
}
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
if (CollectionUtil.isEmpty(blackEmailList)) {
return null;
}
return set.stream()
.filter(item -> !blackEmailList.contains(item))
.collect(Collectors.toSet());
}
}

View File

@ -1,64 +0,0 @@
package com.engine.youhong.ai.taibao.email.impl;
import aiyh.utils.Util;
import aiyh.utils.tool.cn.hutool.core.collection.CollectionUtil;
import com.engine.youhong.ai.taibao.email.BlackListRegister;
import com.engine.youhong.ai.taibao.email.mapper.InitBlackEmailListMapper;
import com.weaverboot.frame.ioc.anno.classAnno.WeaSysInitComponent;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaSysInit;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <h1></h1>
*
* <p>create: 2023/4/14 17:15</p>
*
* @author youHong.ai
*/
@WeaSysInitComponent("注册email黑名单拦截器")
public class InitBlackListServiceImpl {
private final InitBlackEmailListMapper mapper = Util.getMapper(InitBlackEmailListMapper.class);
@WeaSysInit(order = 1, description = "注册拦截邮箱黑名单")
public void init() {
Util.getLogger().info("注册拦截邮箱黑名单,init");
BlackListRegister.registerExpansion(set -> {
if (Objects.isNull(set)) {
return null;
}
List<String> hrmList = mapper.selectWorkflowBlackEmailList();
String ids = Util.join(hrmList, ",");
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
if (CollectionUtil.isEmpty(blackEmailList)) {
return set;
}
return set.stream()
.filter(item -> !blackEmailList.contains(item))
.collect(Collectors.toSet());
});
}
@WeaSysInit(order = 2, description = "注册拦截邮箱黑名单")
public void initApprove() {
Util.getLogger().info("注册拦截邮箱黑名单,initApprove");
BlackListRegister.registerAPPROVEExpansion(set -> {
if (Objects.isNull(set)) {
return null;
}
String ids = mapper.selectWorkflowApproveBlackEmailList();
List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
if (CollectionUtil.isEmpty(blackEmailList)) {
return set;
}
return set.stream()
.filter(item -> !blackEmailList.contains(item))
.collect(Collectors.toSet());
});
}
}

View File

@ -5,6 +5,7 @@ import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.annotation.*;
import aiyh.utils.excention.CustomerException;
import aiyh.utils.tool.cn.hutool.core.lang.Assert;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import weaver.general.GCONST;
@ -101,7 +102,7 @@ public class VoucherPayableNewAction extends SafeCusBaseAction {
private String deleteTemp = "false";
@PrintParamMark
@RequiredMark("过滤字段字段名称,接口参数配置中的接口参数名,也就是序号")
@ActionOptionalParam(value = "", desc = "过滤字段字段名称,接口参数配置中的接口参数名,也就是序号")
@ActionDefaultTestValue("100")
private String filterField;
@ -214,13 +215,15 @@ public class VoucherPayableNewAction extends SafeCusBaseAction {
keys = sortKey(keys);
for (Object o : list) {
Map<String, Object> map = (Map<String, Object>) o;
if (map.containsKey(filterField)) {
try {
String value = Util.null2String(map.get(filterField));
if (Double.parseDouble(value) == 0.0) {
continue;
if (!StrUtil.isBlank(filterField)) {
if (map.containsKey(filterField)) {
try {
String value = Util.null2String(map.get(filterField));
if (Double.parseDouble(value) == 0.0) {
continue;
}
} catch (Exception ignore) {
}
} catch (Exception ignore) {
}
}
for (String key : keys) {

View File

@ -96,7 +96,7 @@ public interface SapConfigMapper {
* @author youHong.ai ******************************************
*/
@Select("select * from $t{billTable} where requestid = #{requestId}")
Map<String, String> selectWorkflowDataByRequestId(@ParamMapper("requestId") String requestId,
Map<String, Object> selectWorkflowDataByRequestId(@ParamMapper("requestId") String requestId,
@ParamMapper("billTable") String billTable);

View File

@ -91,7 +91,7 @@ public class SapConfigService {
}
private SapVoucher parseByPaymentDetailTable(String requestId, String billTable, SapConfigMain sapConfigMain) {
Map<String, String> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
Map<String, Object> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
Assert.notNull(workflowMainData, "payment: query workflow data fail, query request id is {}", requestId);
List<Map<String, Object>> workflowDetailData = mapper.selectWorkflowDataByMainId(Util.null2String(workflowMainData.get("id")),
sapConfigMain.getDocumentDetailTableName());
@ -120,7 +120,7 @@ public class SapConfigService {
private SapVoucher parsePaymentByMainTable(String requestId, String billTable, SapConfigMain sapConfigMain) {
Map<String, String> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
Map<String, Object> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
Assert.notNull(workflowMainData, "payment: query workflow data fail, query request id is {}", requestId);
Map<String, Object> workflowData = new HashMap<>();
workflowData.put("main", workflowMainData);
@ -144,7 +144,7 @@ public class SapConfigService {
*/
private SapVoucher parseByMainTable(String requestId,
String billTable, SapConfigMain sapConfigMain) {
Map<String, String> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
Map<String, Object> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
Assert.notNull(workflowMainData, "query workflow data fail, query request id is {}", requestId);
Map<String, Object> workflowData = new HashMap<>();
workflowData.put("main", workflowMainData);
@ -248,7 +248,7 @@ public class SapConfigService {
*/
private SapVoucher parseByDetailTable(String requestId,
String billTable, SapConfigMain sapConfigMain) {
Map<String, String> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
Map<String, Object> workflowMainData = mapper.selectWorkflowDataByRequestId(requestId, billTable);
Assert.notNull(workflowMainData, "query workflow data fail, query request id is {}", requestId);
List<Map<String, Object>> workflowDetailData = mapper.selectWorkflowDataByMainId(Util.null2String(workflowMainData.get("id")),
sapConfigMain.getDocumentDetailTableName());

View File

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray;
import com.api.youhong.ai.taibao.fcuntionlist.service.FunctionListService;
import com.api.youhong.ai.taibao.qikan.service.PeriodicalService;
import com.cloudstore.dev.api.util.Util_DataCache;
import com.engine.youhong.ai.taibao.email.BlackListRegister;
import com.engine.youhong.ai.taibao.email.mapper.InitBlackEmailListMapper;
import org.junit.Test;
import weaver.conn.RecordSet;
@ -18,8 +19,7 @@ import weaver.workflow.webservices.WorkflowBaseInfo;
import weaver.workflow.webservices.WorkflowRequestInfo;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
/**
* <h1></h1>
@ -169,4 +169,14 @@ public class TestTaiBao extends BaseTest {
List<String> strings = mapper.selectEmailListByHrmIds(ids);
System.out.println(JSON.toJSONString(strings));
}
@Test
public void testEmailFilter() {
Set<String> set = new HashSet<>(Arrays.asList("774495953@qq.com", "wxr15844272561@163.com"));
Set<String> expansionList = BlackListRegister.getExpansionList(set);
if (Objects.nonNull(expansionList)) {
set = expansionList;
}
System.out.println(set);
}
}