批量插入

This commit is contained in:
2025-11-28 17:43:27 +08:00
parent af8d528a2f
commit 002a34042b

View File

@@ -20,12 +20,12 @@ import java.util.stream.Collectors;
* @since 2025-11-27
*/
@Service
public class BkContactListServiceImpl extends ServiceImpl<BkContactListMapper, BkContactList> implements BkContactListService{
public class BkContactListServiceImpl extends ServiceImpl<BkContactListMapper, BkContactList> implements BkContactListService {
@Override
public List<BkContactList> getUserList(Long shopId, Set<String> phones) {
remove(QueryWrapper.create().eq(BkContactList::getShopId, shopId));
saveBatch(phones.stream()
List<BkContactList> collect = phones.stream()
.filter(StrUtil::isNotEmpty)
.map(phone -> {
BkContactList bkContact = new BkContactList();
@@ -33,7 +33,8 @@ public class BkContactListServiceImpl extends ServiceImpl<BkContactListMapper, B
bkContact.setPhone(phone.trim());
return bkContact;
})
.collect(Collectors.toList()));
.collect(Collectors.toList());
mapper.insertBatch(collect);
return mapper.getUserList(shopId);
}
}