修改修改方法

master
yqy 1 year ago
parent 8670e2bce8
commit 4098ee819e

@ -23,5 +23,5 @@ public interface ProxyMapper extends BaseMapper<ProxyEntity> {
void updateExpireDateStatus(); 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) @TableField(exist = false)
private List<String> phoneList = new ArrayList<>(); private List<String> phoneList = new ArrayList<>();
@TableField(exist = false) @TableField(exist = false)
private List<ProxyAccountEntity> ProxyAccountList; private List<ProxyAccountEntity> ProxyAccountList;

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

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

Loading…
Cancel
Save