|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.baiye.service.impl;
|
|
|
|
package com.baiye.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
@ -223,14 +224,30 @@ public class ProxyServiceImpl implements ProxyService {
|
|
|
|
proxyAccountMapper.delete(new LambdaQueryWrapper<ProxyAccountEntity>().in(ProxyAccountEntity::getNid, phoneList));
|
|
|
|
proxyAccountMapper.delete(new LambdaQueryWrapper<ProxyAccountEntity>().in(ProxyAccountEntity::getNid, phoneList));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 号码查重
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param phones 需要检测的号码集合
|
|
|
|
|
|
|
|
* @return 去掉重复后的号码集合
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public List<String> checkSamePhone(List<String> phones) {
|
|
|
|
|
|
|
|
List<String> repeatList = proxyAccountMapper.selectList(new LambdaQueryWrapper<ProxyAccountEntity>().in(ProxyAccountEntity::getNid, phones)).stream().map(ProxyAccountEntity::getNid).collect(Collectors.toList());
|
|
|
|
|
|
|
|
return CollectionUtil.subtractToList(phones, repeatList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addAccountIp(Long proxyId, String phone) {
|
|
|
|
public void addAccountIp(Long proxyId, String phone) {
|
|
|
|
List<ProxyAccountEntity> list = new ArrayList<>();
|
|
|
|
List<ProxyAccountEntity> list = new ArrayList<>();
|
|
|
|
String[] split = phone.split(",");
|
|
|
|
List<String> originList = Arrays.asList(phone.split(","));
|
|
|
|
|
|
|
|
List<String> phoneList = checkSamePhone(originList);
|
|
|
|
|
|
|
|
|
|
|
|
for (String p : split) {
|
|
|
|
for (String p : phoneList) {
|
|
|
|
log.info("号码 =" + p.trim());
|
|
|
|
|
|
|
|
ProxyAccountEntity proxyAccountEntity = new ProxyAccountEntity(p.trim(), proxyId);
|
|
|
|
ProxyAccountEntity proxyAccountEntity = new ProxyAccountEntity(p.trim(), proxyId);
|
|
|
|
|
|
|
|
// ProxyAccountEntity checkEntity = proxyAccountMapper.selectOne(new LambdaQueryWrapper<ProxyAccountEntity>().eq(ProxyAccountEntity::getNid, p.trim()));
|
|
|
|
|
|
|
|
// if (checkEntity != null && checkEntity.getProxyId() != null) {
|
|
|
|
|
|
|
|
// log.warn("号码重复 ,phone:{}", p);
|
|
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
// }
|
|
|
|
list.add(proxyAccountEntity);
|
|
|
|
list.add(proxyAccountEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
@ -246,11 +263,13 @@ public class ProxyServiceImpl implements ProxyService {
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void insertAll(List<ProxyEntity> proxyEntityList) {
|
|
|
|
public void insertAll(List<ProxyEntity> proxyEntityList) {
|
|
|
|
proxyMapper.insertAll(proxyEntityList);
|
|
|
|
proxyMapper.insertAll(proxyEntityList);
|
|
|
|
|
|
|
|
|
|
|
|
List<ProxyAccountEntity> list = new ArrayList<>();
|
|
|
|
List<ProxyAccountEntity> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
for (ProxyEntity proxyEntity : proxyEntityList) {
|
|
|
|
for (ProxyEntity proxyEntity : proxyEntityList) {
|
|
|
|
List<String> phoneList = proxyEntity.getPhoneList();
|
|
|
|
List<String> phoneList = proxyEntity.getPhoneList();
|
|
|
|
for (String phone : phoneList) {
|
|
|
|
//去重
|
|
|
|
|
|
|
|
List<String> phones = checkSamePhone(phoneList);
|
|
|
|
|
|
|
|
for (String phone : phones) {
|
|
|
|
ProxyAccountEntity proxyAccountEntity = new ProxyAccountEntity(phone, proxyEntity.getId());
|
|
|
|
ProxyAccountEntity proxyAccountEntity = new ProxyAccountEntity(phone, proxyEntity.getId());
|
|
|
|
list.add(proxyAccountEntity);
|
|
|
|
list.add(proxyAccountEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -312,7 +331,7 @@ public class ProxyServiceImpl implements ProxyService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("无效的代理地址: {},号码:{}, 错误信息:{}", proxyEntity.getIp(), phone, e.getMessage());
|
|
|
|
log.error("无效的代理地址: {},号码:{}, 错误信息:{}", proxyEntity.getIp(), phone, e.getMessage());
|
|
|
|
throw new BadRequestException("代理Ip不可用,请重新绑定,号码:" + phone);
|
|
|
|
throw new BadRequestException("代理Ip不可用或代理网络不稳定 ,请更换代理或重试,号码:" + phone);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return proxyEntity;
|
|
|
|
return proxyEntity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|