|
@@ -6,8 +6,10 @@ import com.qs.mp.user.domain.UserAddr;
|
|
|
import com.qs.mp.user.mapper.UserAddrMapper;
|
|
|
import com.qs.mp.user.service.IUserAddrService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import java.util.List;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -22,29 +24,34 @@ public class UserAddrServiceImpl extends ServiceImpl<UserAddrMapper, UserAddr> i
|
|
|
IUserAddrService {
|
|
|
|
|
|
@Override
|
|
|
- public UserAddr getDefaultChannelAddr(Long channelId) {
|
|
|
- return getOne(new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, channelId)
|
|
|
+ public UserAddr getDefaultChannelAddr(Long userId) {
|
|
|
+ List<UserAddr> userAddrList = list(new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId,
|
|
|
+ userId)
|
|
|
.eq(UserAddr::getCommonAddr, 1));
|
|
|
+ if (CollectionUtils.isEmpty(userAddrList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return userAddrList.get(0);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public boolean updateDefaultChannelAddr(Long addrId, Long channelId) {
|
|
|
+ public boolean updateDefaultChannelAddr(Long addrId, Long userId) {
|
|
|
update(new LambdaUpdateWrapper<UserAddr>().set(UserAddr::getCommonAddr, 0)
|
|
|
- .eq(UserAddr::getUserId, channelId).eq(UserAddr::getCommonAddr, 1));
|
|
|
+ .eq(UserAddr::getUserId, userId).eq(UserAddr::getCommonAddr, 1));
|
|
|
return update(new LambdaUpdateWrapper<UserAddr>().set(UserAddr::getCommonAddr, 1)
|
|
|
- .eq(UserAddr::getUserId, channelId).eq(UserAddr::getAddrId, addrId));
|
|
|
+ .eq(UserAddr::getUserId, userId).eq(UserAddr::getAddrId, addrId));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean removeChannelAddrByUserId(Long addrId, Long channelId) {
|
|
|
+ public boolean removeChannelAddrByUserId(Long addrId, Long userId) {
|
|
|
return remove(new LambdaQueryWrapper<UserAddr>()
|
|
|
- .eq(UserAddr::getUserId, channelId).eq(UserAddr::getAddrId, addrId));
|
|
|
+ .eq(UserAddr::getUserId, userId).eq(UserAddr::getAddrId, addrId));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public UserAddr getChannelAddrByUserId(Long addrId, Long channelId) {
|
|
|
+ public UserAddr getChannelAddrByUserId(Long addrId, Long userId) {
|
|
|
return getOne(new LambdaQueryWrapper<UserAddr>()
|
|
|
- .eq(UserAddr::getUserId, channelId).eq(UserAddr::getAddrId, addrId));
|
|
|
+ .eq(UserAddr::getUserId, userId).eq(UserAddr::getAddrId, addrId));
|
|
|
}
|
|
|
}
|