| | |
| | | package com.ruoyi.user.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.user.entity.UserRecipient; |
| | | import com.ruoyi.user.mapper.UserRecipientMapper; |
| | | import com.ruoyi.user.service.UserRecipientService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class UserRecipientServiceImpl extends ServiceImpl<UserRecipientMapper, UserRecipient> implements UserRecipientService { |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean updateBatchAddress(UserRecipient userRecipient, Integer userid) { |
| | | boolean result = true; |
| | | if (Constants.ONE.equals(userRecipient.getIsDefault())) { |
| | | List<UserRecipient> list = lambdaQuery().eq(UserRecipient::getUserId, userid) |
| | | .eq(UserRecipient::getIsDelete, 0).list(); |
| | | List<UserRecipient> updateList = new ArrayList<>(); |
| | | for (UserRecipient recipient : list) { |
| | | if (Constants.ONE.equals(recipient.getIsDefault())) { |
| | | recipient.setIsDefault(0); |
| | | updateList.add(recipient); |
| | | } |
| | | } |
| | | if (!updateList.isEmpty()) { |
| | | result = this.updateBatchById(updateList); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | } |