邮箱黑名单

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 ```properties
serverName=ecology 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 绝对路径 rootPath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/src/main/resources/
logPath=/Users/aoey.oct.22/company/Fan_wei/code/idea/ecology9-project/log # 修改为实际的地址 # 修改为实际的地址这里可以是你实际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") @SqlOracleDbFieldAnn("AUTHORITY_MEMBER")
private String authorityMember; private String authorityMember;
/** */
@SqlOracleDbFieldAnn("DEFAULT_VALUE")
private String defaultValue;
} }

View File

@ -30,13 +30,22 @@ public class RequestLogAuthorityService {
result.put("show", false); result.put("show", false);
return result; return result;
} }
if (StrUtil.isBlank(requestId) || "-1".equals(requestId)) { if (StrUtil.isBlank(requestId) || "-1".equals(requestId)) {
if ("1".equals(requestLogAuthority.getDefaultValue())) {
result.put("enable", true);
} else {
result.put("enable", false); result.put("enable", false);
}
return result; return result;
} }
Integer id = mapper.selectRequestLogId(requestId, nodeId, String.valueOf(user.getUID())); Integer id = mapper.selectRequestLogId(requestId, nodeId, String.valueOf(user.getUID()));
if (id <= 0) { if (id <= 0) {
if ("1".equals(requestLogAuthority.getDefaultValue())) {
result.put("enable", true);
} else {
result.put("enable", false); result.put("enable", false);
}
} else { } else {
result.put("enable", true); 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.constant.RemindTypeEnum;
import com.engine.workflow.util.GetCustomLevelUtil; import com.engine.workflow.util.GetCustomLevelUtil;
import com.engine.workflow.util.WfToDocUtil; import com.engine.workflow.util.WfToDocUtil;
import com.engine.youhong.ai.taibao.email.BlackListExpansion;
import com.engine.youhong.ai.taibao.email.BlackListRegister; import com.engine.youhong.ai.taibao.email.BlackListRegister;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
@ -1747,11 +1746,9 @@ public class RequestRemindBiz {
} }
} }
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */ /* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */
for (BlackListExpansion blackListExpansion : BlackListRegister.getExpansionList()) { Set<String> expansionList = BlackListRegister.getExpansionList(mailAddress);
Set<String> mailAddress1 = blackListExpansion.sendEmailHandler(mailAddress); if (Objects.nonNull(expansionList)) {
if (Objects.nonNull(mailAddress1)) { mailAddress = expansionList;
mailAddress = mailAddress1;
}
} }
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */ /* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */
if (mailAddress.isEmpty()) return; if (mailAddress.isEmpty()) return;
@ -1784,11 +1781,9 @@ public class RequestRemindBiz {
} }
} }
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */ /* ******************* youhong.ai 添加发送邮箱的黑名单拓展start ******************* */
for (BlackListExpansion blackListExpansion : BlackListRegister.getExpansionApproveList()) { Set<String> expansionList = BlackListRegister.getExpansionApproveList(mailAddress);
Set<String> mailAddress1 = blackListExpansion.sendEmailHandler(mailAddress); if (Objects.nonNull(expansionList)) {
if (Objects.nonNull(mailAddress1)) { mailAddress = expansionList;
mailAddress = mailAddress1;
}
} }
/* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */ /* ******************* youhong.ai 添加发送邮箱的黑名单拓展 end ******************* */
EmailApprovalRunnable.threadModeReminder(String.join(",", mailAddress), title, content, String.valueOf(requestId), allAttchment); 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; 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.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/** /**
* <h1></h1> * <h1></h1>
@ -13,26 +19,42 @@ import java.util.Objects;
*/ */
public class BlackListRegister { 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) { private static final InitBlackEmailListMapper mapper = Util.getMapper(InitBlackEmailListMapper.class);
if (Objects.nonNull(blackListExpansion)) {
EXPANSION_LIST.add(blackListExpansion);
public static Set<String> getExpansionList(Set<String> set) {
if (Objects.isNull(set)) {
return null;
} }
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 void registerAPPROVEExpansion(BlackListExpansion blackListExpansion) { public static Set<String> getExpansionApproveList(Set<String> set) {
if (Objects.nonNull(blackListExpansion)) { if (Objects.isNull(set)) {
EXPANSION_APPROVE_LIST.add(blackListExpansion); return null;
} }
} String ids = mapper.selectWorkflowApproveBlackEmailList();
if (StrUtil.isBlank(ids)) {
public static List<BlackListExpansion> getExpansionList() { return null;
return EXPANSION_LIST; }
} List<String> blackEmailList = mapper.selectEmailListByHrmIds(ids);
if (CollectionUtil.isEmpty(blackEmailList)) {
public static List<BlackListExpansion> getExpansionApproveList() { return null;
return EXPANSION_APPROVE_LIST; }
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.annotation.*;
import aiyh.utils.excention.CustomerException; import aiyh.utils.excention.CustomerException;
import aiyh.utils.tool.cn.hutool.core.lang.Assert; import aiyh.utils.tool.cn.hutool.core.lang.Assert;
import aiyh.utils.tool.cn.hutool.core.util.StrUtil;
import lombok.Setter; import lombok.Setter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import weaver.general.GCONST; import weaver.general.GCONST;
@ -101,7 +102,7 @@ public class VoucherPayableNewAction extends SafeCusBaseAction {
private String deleteTemp = "false"; private String deleteTemp = "false";
@PrintParamMark @PrintParamMark
@RequiredMark("过滤字段字段名称,接口参数配置中的接口参数名,也就是序号") @ActionOptionalParam(value = "", desc = "过滤字段字段名称,接口参数配置中的接口参数名,也就是序号")
@ActionDefaultTestValue("100") @ActionDefaultTestValue("100")
private String filterField; private String filterField;
@ -214,6 +215,7 @@ public class VoucherPayableNewAction extends SafeCusBaseAction {
keys = sortKey(keys); keys = sortKey(keys);
for (Object o : list) { for (Object o : list) {
Map<String, Object> map = (Map<String, Object>) o; Map<String, Object> map = (Map<String, Object>) o;
if (!StrUtil.isBlank(filterField)) {
if (map.containsKey(filterField)) { if (map.containsKey(filterField)) {
try { try {
String value = Util.null2String(map.get(filterField)); String value = Util.null2String(map.get(filterField));
@ -223,6 +225,7 @@ public class VoucherPayableNewAction extends SafeCusBaseAction {
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} }
}
for (String key : keys) { for (String key : keys) {
if (map.containsKey(key)) { if (map.containsKey(key)) {
sb.append(map.get(key)) sb.append(map.get(key))

View File

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

View File

@ -91,7 +91,7 @@ public class SapConfigService {
} }
private SapVoucher parseByPaymentDetailTable(String requestId, String billTable, SapConfigMain sapConfigMain) { 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); 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")), List<Map<String, Object>> workflowDetailData = mapper.selectWorkflowDataByMainId(Util.null2String(workflowMainData.get("id")),
sapConfigMain.getDocumentDetailTableName()); sapConfigMain.getDocumentDetailTableName());
@ -120,7 +120,7 @@ public class SapConfigService {
private SapVoucher parsePaymentByMainTable(String requestId, String billTable, SapConfigMain sapConfigMain) { 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); Assert.notNull(workflowMainData, "payment: query workflow data fail, query request id is {}", requestId);
Map<String, Object> workflowData = new HashMap<>(); Map<String, Object> workflowData = new HashMap<>();
workflowData.put("main", workflowMainData); workflowData.put("main", workflowMainData);
@ -144,7 +144,7 @@ public class SapConfigService {
*/ */
private SapVoucher parseByMainTable(String requestId, private SapVoucher parseByMainTable(String requestId,
String billTable, SapConfigMain sapConfigMain) { 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); Assert.notNull(workflowMainData, "query workflow data fail, query request id is {}", requestId);
Map<String, Object> workflowData = new HashMap<>(); Map<String, Object> workflowData = new HashMap<>();
workflowData.put("main", workflowMainData); workflowData.put("main", workflowMainData);
@ -248,7 +248,7 @@ public class SapConfigService {
*/ */
private SapVoucher parseByDetailTable(String requestId, private SapVoucher parseByDetailTable(String requestId,
String billTable, SapConfigMain sapConfigMain) { 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); Assert.notNull(workflowMainData, "query workflow data fail, query request id is {}", requestId);
List<Map<String, Object>> workflowDetailData = mapper.selectWorkflowDataByMainId(Util.null2String(workflowMainData.get("id")), List<Map<String, Object>> workflowDetailData = mapper.selectWorkflowDataByMainId(Util.null2String(workflowMainData.get("id")),
sapConfigMain.getDocumentDetailTableName()); 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.fcuntionlist.service.FunctionListService;
import com.api.youhong.ai.taibao.qikan.service.PeriodicalService; import com.api.youhong.ai.taibao.qikan.service.PeriodicalService;
import com.cloudstore.dev.api.util.Util_DataCache; 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 com.engine.youhong.ai.taibao.email.mapper.InitBlackEmailListMapper;
import org.junit.Test; import org.junit.Test;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
@ -18,8 +19,7 @@ import weaver.workflow.webservices.WorkflowBaseInfo;
import weaver.workflow.webservices.WorkflowRequestInfo; import weaver.workflow.webservices.WorkflowRequestInfo;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.List;
/** /**
* <h1></h1> * <h1></h1>
@ -169,4 +169,14 @@ public class TestTaiBao extends BaseTest {
List<String> strings = mapper.selectEmailListByHrmIds(ids); List<String> strings = mapper.selectEmailListByHrmIds(ids);
System.out.println(JSON.toJSONString(strings)); 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);
}
} }