修复删除主播和实际选择数量不一致的问题
This commit is contained in:
@@ -15,6 +15,7 @@ import javax.annotation.Resource;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
@@ -62,18 +63,21 @@ public class NewHostsServiceImpl implements NewHostsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteNewHostsListByIds(List<Long> ids) {
|
public void deleteNewHostsListByIds(List<Long> ids) {
|
||||||
// 校验存在
|
List<NewHostsDO> hostsList = getValidatedNewHosts(ids);
|
||||||
validateNewHostsExists(ids);
|
List<String> hostsIds = hostsList.stream()
|
||||||
// 删除
|
.map(NewHostsDO::getHostsId)
|
||||||
newHostsMapper.deleteByIds(ids);
|
.distinct()
|
||||||
}
|
.collect(Collectors.toList());
|
||||||
|
newHostsMapper.deleteBatch(NewHostsDO::getHostsId, hostsIds);
|
||||||
|
}
|
||||||
|
|
||||||
private void validateNewHostsExists(List<Long> ids) {
|
private List<NewHostsDO> getValidatedNewHosts(List<Long> ids) {
|
||||||
List<NewHostsDO> list = newHostsMapper.selectByIds(ids);
|
List<NewHostsDO> list = newHostsMapper.selectByIds(ids);
|
||||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||||
throw exception(ErrorCodeConstants.NEW_HOSTS_NOT_EXISTS);
|
throw exception(ErrorCodeConstants.NEW_HOSTS_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateNewHostsExists(Long id) {
|
private void validateNewHostsExists(Long id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user