|
|
|
|
@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.modules.weixin.entity.WeChatAddress; |
|
|
|
|
import org.springblade.modules.weixin.entity.WeChatUser; |
|
|
|
|
import org.springblade.modules.weixin.mapper.WeChatAddressMapper; |
|
|
|
|
@ -45,20 +46,13 @@ public class WeChatAddressServiceImpl extends BaseServiceImpl<WeChatAddressMappe |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean add(WeChatAddress weChatAddress) { |
|
|
|
|
weChatAddress.setIsDefault(0); |
|
|
|
|
// if (weChatAddress.getIsDefault() == 1) {
|
|
|
|
|
// WeChatAddress address = this.getOne(Wrappers.<WeChatAddress>lambdaQuery().eq(WeChatAddress::getUserId, weChatAddress.getUserId()).eq(WeChatAddress::getIsDefault, 1));
|
|
|
|
|
// if (address != null) {
|
|
|
|
|
// address.setIsDefault(0);
|
|
|
|
|
// this.updateById(address);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
return this.save(weChatAddress); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean edit(WeChatAddress weChatAddress) { |
|
|
|
|
if (weChatAddress.getIsDefault() == 1) { |
|
|
|
|
if (Func.isNotEmpty(weChatAddress.getIsDefault()) && weChatAddress.getIsDefault() == 1) { |
|
|
|
|
WeChatAddress address = this.getOne(Wrappers.<WeChatAddress>lambdaQuery().eq(WeChatAddress::getUserId, weChatAddress.getUserId()).eq(WeChatAddress::getIsDefault, 1)); |
|
|
|
|
if (address != null && !address.getId().equals(weChatAddress.getId())) { |
|
|
|
|
address.setIsDefault(0); |
|
|
|
|
|