Compare commits
4 Commits
cb57a595aa
...
main
Author | SHA1 | Date | |
---|---|---|---|
bd802ab8fd | |||
e1a6642af4 | |||
b05b01b007 | |||
953ffdfb28 |
@ -17,6 +17,9 @@ public class DeviceForm {
|
|||||||
@ApiModelProperty(value = "ID", hidden = true)
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "设备记录ID")
|
||||||
|
private Long assignId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "设备类型")
|
@ApiModelProperty(value = "设备类型")
|
||||||
private Long deviceType;
|
private Long deviceType;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.fuyuanshen.modules.system.domain.vo;
|
package com.fuyuanshen.modules.system.domain.vo;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -13,15 +14,27 @@ import lombok.Data;
|
|||||||
public class APPUserVo {
|
public class APPUserVo {
|
||||||
|
|
||||||
@ApiModelProperty(value = "ID")
|
@ApiModelProperty(value = "ID")
|
||||||
|
@JsonProperty("id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户昵称")
|
@ApiModelProperty(value = "用户昵称")
|
||||||
|
@JsonProperty("nickName")
|
||||||
private String nickName;
|
private String nickName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户性别")
|
@ApiModelProperty(value = "用户性别")
|
||||||
|
@JsonProperty("gender")
|
||||||
private String gender;
|
private String gender;
|
||||||
|
|
||||||
@ApiModelProperty(value = "电话号码")
|
@ApiModelProperty(value = "电话号码")
|
||||||
|
@JsonProperty("phone")
|
||||||
private Long phone;
|
private Long phone;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "头像存储的路径")
|
||||||
|
@JsonProperty("avatarPath")
|
||||||
|
private String avatarPath;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "地区")
|
||||||
|
@JsonProperty("region")
|
||||||
|
private String region;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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("设备详情")
|
@ApiOperation("设备详情")
|
||||||
@GetMapping(value = "/detail/{id}")
|
@GetMapping(value = "/detail/{id}")
|
||||||
public ResponseVO<Object> getDevice(@PathVariable Long id) {
|
public ResponseVO<Object> getDevice(@PathVariable Long id) {
|
||||||
|
@ -73,6 +73,8 @@ public interface DeviceService extends IService<Device> {
|
|||||||
*/
|
*/
|
||||||
void assignCustomer(CustomerVo customerVo);
|
void assignCustomer(CustomerVo customerVo);
|
||||||
|
|
||||||
|
void withdrawDevice(DeviceForm deviceForm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
*
|
*
|
||||||
@ -110,5 +112,4 @@ public interface DeviceService extends IService<Device> {
|
|||||||
*/
|
*/
|
||||||
void unbindDevice(DeviceForm deviceForm);
|
void unbindDevice(DeviceForm deviceForm);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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
|
* @param ids
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteAssign(List<Long> ids) {
|
public void deleteAssign(List<Long> ids) {
|
||||||
// Step 1: 查询所有传入的设备(根据 ID)
|
// Step 1: 查询所有传入的设备(根据 ID)
|
||||||
List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
|
List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
|
||||||
@ -562,7 +587,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
throw new BadRequestException("已分配的设备不允许删除!!!");
|
throw new BadRequestException("已分配的设备不允许删除!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceAssignmentsMapper.deleteBatchIds(ids);
|
deviceAssignmentsMapper.deleteBatchIds(nonNullCustomerIds);
|
||||||
|
deviceTypeGrantsMapper.delete(new QueryWrapper<DeviceTypeGrants>().in("assignment_id", nonNullCustomerIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,7 +177,24 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteAll(List<Long> ids) {
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user