Compare commits
5 Commits
968f1cbb16
...
bd802ab8fd
Author | SHA1 | Date | |
---|---|---|---|
bd802ab8fd | |||
e1a6642af4 | |||
b05b01b007 | |||
cb57a595aa | |||
953ffdfb28 |
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -134,4 +134,5 @@ public class APPUserController {
|
||||
// appUserService.sendSms(phoneNumber);
|
||||
return ResponseVO.success("success!!!");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
@ -56,10 +56,12 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
||||
*/
|
||||
@Override
|
||||
public PageResult<APPDevice> appDeviceList(Page<APPDevice> page, DeviceQueryCriteria criteria) {
|
||||
criteria.setCustomerId(SecurityUtils.getCurrentUserId());
|
||||
IPage<APPDevice> devices = appDeviceMapper.appDeviceList(page, criteria);
|
||||
return new PageResult<>(devices.getRecords(), devices.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* APP用户设备类型列表
|
||||
*
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.fuyuanshen.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.modules.system.domain.Device;
|
||||
import com.fuyuanshen.modules.system.domain.DeviceTypeGrants;
|
||||
import com.fuyuanshen.modules.system.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.DeviceTypeGrantsMapper;
|
||||
import com.fuyuanshen.modules.utils.NanoId;
|
||||
import com.fuyuanshen.utils.enums.NanoIdLengthEnum;
|
||||
@ -41,6 +45,7 @@ import java.util.stream.Collectors;
|
||||
public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceType> implements DeviceTypeService {
|
||||
|
||||
private final DeviceTypeMapper deviceTypeMapper;
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final UserCacheManager userCacheManager;
|
||||
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
||||
@ -142,9 +147,20 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改设备类型
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DeviceType resources) {
|
||||
|
||||
List<Device> deviceList = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_type", resources.getId()));
|
||||
if (CollectionUtil.isNotEmpty(deviceList)) {
|
||||
throw new BadRequestException("该设备类型下已有设备,请先解绑设备!!!");
|
||||
}
|
||||
|
||||
DeviceType deviceType = getById(resources.getId());
|
||||
deviceType.copy(resources);
|
||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
@ -153,10 +169,32 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除设备类型
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
@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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,6 +61,6 @@
|
||||
and dt.create_by = #{criteria.createBy}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user