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