Compare commits

4 Commits

Author SHA1 Message Date
bd802ab8fd Merge remote-tracking branch 'origin/main_app权限适配' 2025-06-26 11:29:05 +08:00
e1a6642af4 撤回设备 2025-06-26 11:28:00 +08:00
b05b01b007 删除设备类型 2025-06-26 10:27:59 +08:00
953ffdfb28 app显示还回为空的参数 2025-06-25 17:28:57 +08:00
6 changed files with 77 additions and 3 deletions

View File

@ -17,6 +17,9 @@ public class DeviceForm {
@ApiModelProperty(value = "ID", hidden = true)
private Long id;
@ApiModelProperty(value = "设备记录ID")
private Long assignId;
@ApiModelProperty(value = "设备类型")
private Long deviceType;

View File

@ -1,6 +1,7 @@
package com.fuyuanshen.modules.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -13,15 +14,27 @@ import lombok.Data;
public class APPUserVo {
@ApiModelProperty(value = "ID")
@JsonProperty("id")
private Long id;
@ApiModelProperty(value = "用户昵称")
@JsonProperty("nickName")
private String nickName;
@ApiModelProperty(value = "用户性别")
@JsonProperty("gender")
private String gender;
@ApiModelProperty(value = "电话号码")
@JsonProperty("phone")
private Long phone;
@ApiModelProperty(value = "头像存储的路径")
@JsonProperty("avatarPath")
private String avatarPath;
@ApiModelProperty(value = "地区")
@JsonProperty("region")
private String region;
}

View File

@ -146,6 +146,20 @@ public class DeviceController {
}
@Log("撤回设备")
@ApiOperation("撤回设备")
@PostMapping(value = "/withdraw")
public ResponseVO<Object> withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
try {
deviceService.withdrawDevice(deviceForm);
} catch (Exception e) {
log.error("updateDevice error: " + e.getMessage());
return ResponseVO.fail("出错了");
}
return ResponseVO.success(null);
}
@ApiOperation("设备详情")
@GetMapping(value = "/detail/{id}")
public ResponseVO<Object> getDevice(@PathVariable Long id) {

View File

@ -73,6 +73,8 @@ public interface DeviceService extends IService<Device> {
*/
void assignCustomer(CustomerVo customerVo);
void withdrawDevice(DeviceForm deviceForm);
/**
* 多选删除
*
@ -110,5 +112,4 @@ public interface DeviceService extends IService<Device> {
*/
void unbindDevice(DeviceForm deviceForm);
}

View File

@ -456,6 +456,30 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
/**
* 撤回设备
*
* @param deviceForm
*/
@Override
public void withdrawDevice(DeviceForm deviceForm) {
DeviceAssignments assignment = deviceAssignmentsMapper.selectById(deviceForm.getAssignId());
// 接收者
assignment.setAssigneeName("");
deviceAssignmentsMapper.updateById(assignment);
LambdaQueryWrapper<DeviceAssignments> q1 = new LambdaQueryWrapper<>();
q1.eq(DeviceAssignments::getAssignerId, assignment.getAssigneeId())
.like(DeviceAssignments::getLever, assignment.getLever())
.ne(DeviceAssignments::getId, assignment.getId());
DeviceAssignments d1 = new DeviceAssignments();
d1.setActive(DeviceActiveStatusEnum.INACTIVE.getCode());
deviceAssignmentsMapper.update(d1, q1);
}
/**
* 创建并保存设备类型授权记录
*
@ -551,6 +575,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
* @param ids
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAssign(List<Long> ids) {
// Step 1: 查询所有传入的设备(根据 ID
List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
@ -562,7 +587,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
throw new BadRequestException("已分配的设备不允许删除!!!");
}
deviceAssignmentsMapper.deleteBatchIds(ids);
deviceAssignmentsMapper.deleteBatchIds(nonNullCustomerIds);
deviceTypeGrantsMapper.delete(new QueryWrapper<DeviceTypeGrants>().in("assignment_id", nonNullCustomerIds));
}

View File

@ -177,7 +177,24 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(List<Long> ids) {
deviceTypeMapper.deleteBatchIds(ids);
// 查询所有与 device 关联的 deviceType IDs
List<Device> deviceList = deviceMapper.selectList(new QueryWrapper<Device>().in("device_type", ids));
// 提取与 device 关联的 deviceType IDs
List<Long> filteredIds = deviceList.stream()
.map(Device::getDeviceType)
.distinct()
.collect(Collectors.toList());
// 从原始 ids 中移除已关联 device 的 id即过滤掉能查到结果的 id
List<Long> idsToBeDeleted = ids.stream()
.filter(id -> !filteredIds.contains(id))
.collect(Collectors.toList());
if (idsToBeDeleted.isEmpty()) {
throw new BadRequestException("选中设备类型已绑定设备,请先解绑设备!!!");
}
// 删除过滤后的 id 列表
deviceTypeMapper.deleteBatchIds(idsToBeDeleted);
deviceTypeGrantsMapper.delete(new QueryWrapper<DeviceTypeGrants>().in("device_type_id", idsToBeDeleted));
}