Commit 9ec134a4 authored by honghy's avatar honghy

修正短信节点不能更新bug

parent fba11b8c
......@@ -223,6 +223,8 @@ public class SmsNodeServiceImpl extends AbstractService<SmsNodeMapper, SmsNodeDO
smsNodeDO.setIsOrders(createReqVO.getIsOrders());
List<SmsNodeDO> smsNodeDOList = smsNodeMapper.selectList(smsNodeDO);
String country = createReqVO.getCountryId();
// 获取目的仓
List<List<Long>> receiveAddrs = getReceiveAddrList(createReqVO.getReceiveAddrList());
if (smsNodeDOList != null && !smsNodeDOList.isEmpty()) {
Map<String, Integer> map = new HashMap<>();
for (SmsNodeDO nodeDO : smsNodeDOList) {
......@@ -251,10 +253,9 @@ public class SmsNodeServiceImpl extends AbstractService<SmsNodeMapper, SmsNodeDO
}
}
Set<String> existingCountryIds = new HashSet<>(Arrays.asList(country.split(",")));
// 获取目的仓
List<List<Long>> receiveAddrList = getReceiveAddrList(createReqVO.getReceiveAddrList());
for (List<Long> integers : receiveAddrList) {
for (List<Long> integers : receiveAddrs) {
for (String existingCountryId : existingCountryIds) {
String key = generateKey(existingCountryId, integers);
if (map.containsKey(key)) {
......@@ -263,11 +264,10 @@ public class SmsNodeServiceImpl extends AbstractService<SmsNodeMapper, SmsNodeDO
}
}
}
SmsNodeExtraVO smsNodeExtraVO = new SmsNodeExtraVO();
smsNodeExtraVO.setReceiveAddrList(receiveAddrList);
smsNode.setExtra(JSON.toJSONString(smsNodeExtraVO));
}
SmsNodeExtraVO smsNodeExtraVO = new SmsNodeExtraVO();
smsNodeExtraVO.setReceiveAddrList(receiveAddrs);
smsNode.setExtra(JSON.toJSONString(smsNodeExtraVO));
// 插入新的短信节点到数据库
smsNodeMapper.insert(smsNode);
// 设置新的缓存
......@@ -378,14 +378,14 @@ public class SmsNodeServiceImpl extends AbstractService<SmsNodeMapper, SmsNodeDO
}
Set<String> existingCountryIds = new HashSet<>(Arrays.asList(country.split(",")));
List<List<Long>> receiveAddrList = updateReqVO.getReceiveAddrList();
List<List<Long>> receiveAddrList = getReceiveAddrList(updateReqVO.getReceiveAddrList());
for (List<Long> integers : receiveAddrList) {
for (String existingCountryId : existingCountryIds) {
String key = generateKey(existingCountryId, integers);
if (map.containsKey(key)) {
SmsNodeDO nodeDO = map.get(key);
if (nodeDO.getId() != updateObj.getId()) {
if (!nodeDO.getId().equals(updateObj.getId())) {
// 如果节点已存在,抛出异常
throw new ServiceException(500, "不能重复设置");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment