设备解绑

This commit is contained in:
2025-10-11 16:16:06 +08:00
parent dab0440128
commit 3246127893

View File

@ -282,6 +282,25 @@ public class DeviceBizService {
.set("binding_time", null); .set("binding_time", null);
deviceMapper.update(null, deviceUpdateWrapper); deviceMapper.update(null, deviceUpdateWrapper);
} }
QueryWrapper<AppDeviceBindRecord> brqWrapper = new QueryWrapper<>();
brqWrapper.eq("device_id", device.getId());
brqWrapper.eq("binding_user_id", userId);
List<AppDeviceBindRecord> appDeviceBindRecordList = appDeviceBindRecordMapper.selectList(brqWrapper);
if (CollectionUtil.isNotEmpty(appDeviceBindRecordList)) {
appDeviceBindRecordList.forEach(appDeviceBindRecord ->
appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId()));
}
AppUserVo appUserVo = appUserMapper.selectVoById(userId);
if(appUserVo != null){
QueryWrapper<AppDeviceShare> appDeviceShareQueryWrapper = new QueryWrapper<>();
appDeviceShareQueryWrapper.eq("device_id", device.getId());
appDeviceShareQueryWrapper.eq("phonenumber", appUserVo.getPhonenumber());
List<AppDeviceShare> appDeviceShareList = appDeviceShareMapper.selectList(appDeviceShareQueryWrapper);
if (CollectionUtil.isNotEmpty(appDeviceShareList)) {
appDeviceShareList.forEach(appDeviceShare ->
appDeviceShareMapper.deleteById(appDeviceShare.getId()));
}
}
}else{ }else{
QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>(); QueryWrapper<AppDeviceBindRecord> bindRecordQueryWrapper = new QueryWrapper<>();
bindRecordQueryWrapper.eq("device_id", device.getId()); bindRecordQueryWrapper.eq("device_id", device.getId());
@ -295,25 +314,17 @@ public class DeviceBizService {
.set("binding_status", BindingStatusEnum.UNBOUND.getCode()) .set("binding_status", BindingStatusEnum.UNBOUND.getCode())
.set("binding_time", null); .set("binding_time", null);
deviceMapper.update(null, deviceUpdateWrapper); deviceMapper.update(null, deviceUpdateWrapper);
}
QueryWrapper<AppDeviceBindRecord> brqWrapper = new QueryWrapper<>(); QueryWrapper<AppDeviceBindRecord> brqWrapper = new QueryWrapper<>();
brqWrapper.eq("device_id", device.getId()); brqWrapper.eq("device_id", device.getId());
if(userId != null){
brqWrapper.eq("binding_user_id", userId);
}
List<AppDeviceBindRecord> appDeviceBindRecordList = appDeviceBindRecordMapper.selectList(brqWrapper); List<AppDeviceBindRecord> appDeviceBindRecordList = appDeviceBindRecordMapper.selectList(brqWrapper);
if (CollectionUtil.isNotEmpty(appDeviceBindRecordList)) { if (CollectionUtil.isNotEmpty(appDeviceBindRecordList)) {
appDeviceBindRecordList.forEach(appDeviceBindRecord -> appDeviceBindRecordList.forEach(appDeviceBindRecord ->
appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId())); appDeviceBindRecordMapper.deleteById(appDeviceBindRecord.getId()));
} }
AppUserVo appUserVo = appUserMapper.selectVoById(userId);
if(appUserVo != null){
QueryWrapper<AppDeviceShare> appDeviceShareQueryWrapper = new QueryWrapper<>(); QueryWrapper<AppDeviceShare> appDeviceShareQueryWrapper = new QueryWrapper<>();
appDeviceShareQueryWrapper.eq("device_id", device.getId()); appDeviceShareQueryWrapper.eq("device_id", device.getId());
appDeviceShareQueryWrapper.eq("phonenumber", appUserVo.getPhonenumber());
List<AppDeviceShare> appDeviceShareList = appDeviceShareMapper.selectList(appDeviceShareQueryWrapper); List<AppDeviceShare> appDeviceShareList = appDeviceShareMapper.selectList(appDeviceShareQueryWrapper);
if (CollectionUtil.isNotEmpty(appDeviceShareList)) { if (CollectionUtil.isNotEmpty(appDeviceShareList)) {
appDeviceShareList.forEach(appDeviceShare -> appDeviceShareList.forEach(appDeviceShare ->