|
|
|
@ -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,6 +169,11 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除设备类型
|
|
|
|
|
*
|
|
|
|
|
* @param ids /
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void deleteAll(List<Long> ids) {
|
|
|
|
|