修改修改方法

master
yqy 1 year ago
parent 8670e2bce8
commit 4098ee819e

@ -23,5 +23,5 @@ public interface ProxyMapper extends BaseMapper<ProxyEntity> {
void updateExpireDateStatus();
void addSurplusDay(@Param("ids") List<Long> ids,@Param("num") Integer num);
void addSurplusDay(@Param("ids") List<Long> ids, @Param("num") Integer num, @Param("status") String status);
}

@ -84,6 +84,7 @@ public class ProxyEntity {
@TableField(exist = false)
private List<String> phoneList = new ArrayList<>();
@TableField(exist = false)
private List<ProxyAccountEntity> ProxyAccountList;

@ -138,31 +138,30 @@ public class ProxyServiceImpl implements ProxyService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ProxyEntity proxyEntity) {
// 修改IP的信息
proxyMapper.updateById(proxyEntity);
List<String> phoneList = proxyEntity.getPhoneList();
List<ProxyAccountEntity> list = new ArrayList<>();
List<ProxyAccountEntity> proxyAccountEntities = proxyAccountMapper.selectList(new LambdaQueryWrapper<ProxyAccountEntity>()
.eq(ProxyAccountEntity::getProxyId, proxyEntity.getId()));
Map<String, List<ProxyAccountEntity>> map = proxyAccountEntities.stream().collect(Collectors.groupingBy(ProxyAccountEntity::getNid));
// 获取所有要绑定的账号-并添加绑定关系
for (String phone : phoneList) {
if (!map.containsKey(phone)) {
ProxyAccountEntity proxyAccountEntity = new ProxyAccountEntity(phone, proxyEntity.getId());
list.add(proxyAccountEntity);
}
}
if (CollUtil.isNotEmpty(list)) proxyAccountMapper.insertAll(list);
// 删除的账号-删除绑定关系
Set<String> phones = map.keySet();
List<String> deleteList = phones.stream().filter(t -> !phoneList.contains(t)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(deleteList)) {
proxyAccountMapper.delete(new LambdaQueryWrapper<ProxyAccountEntity>().in(ProxyAccountEntity::getNid, deleteList));
}
// List<String> phoneList = proxyEntity.getPhoneList();
// List<ProxyAccountEntity> list = new ArrayList<>();
//
// List<ProxyAccountEntity> proxyAccountEntities = proxyAccountMapper.selectList(new LambdaQueryWrapper<ProxyAccountEntity>()
// .eq(ProxyAccountEntity::getProxyId, proxyEntity.getId()));
// Map<String, List<ProxyAccountEntity>> map = proxyAccountEntities.stream().collect(Collectors.groupingBy(ProxyAccountEntity::getNid));
//
// // 获取所有要绑定的账号-并添加绑定关系
// for (String phone : phoneList) {
// if (!map.containsKey(phone)) {
// ProxyAccountEntity proxyAccountEntity = new ProxyAccountEntity(phone, proxyEntity.getId());
// list.add(proxyAccountEntity);
// }
// }
// if (CollUtil.isNotEmpty(list)) proxyAccountMapper.insertAll(list);
//
// // 删除的账号-删除绑定关系
// Set<String> phones = map.keySet();
// List<String> deleteList = phones.stream().filter(t -> !phoneList.contains(t)).collect(Collectors.toList());
// if (CollUtil.isNotEmpty(deleteList)) {
// proxyAccountMapper.delete(new LambdaQueryWrapper<ProxyAccountEntity>().in(ProxyAccountEntity::getNid, deleteList));
// }
}
@Override
@ -277,7 +276,7 @@ public class ProxyServiceImpl implements ProxyService {
@Override
public void addSurplusDay(ProxyDTO proxyDTO) {
proxyMapper.addSurplusDay(proxyDTO.getIds(), proxyDTO.getSurplusDay());
proxyMapper.addSurplusDay(proxyDTO.getIds(), proxyDTO.getSurplusDay(), "0");
}
/**

@ -33,7 +33,7 @@
</update>
<update id="addSurplusDay">
update tb_proxy
set surplus_day = surplus_day + ${num}
set surplus_day = surplus_day + ${num},status = #{status}
where id in
<foreach collection="ids" index="index" item="index" open="(" separator="," close=")">
#{index}

Loading…
Cancel
Save