forked from dyf/fys-Multi-tenant
Merge remote-tracking branch 'upstream/6170'
This commit is contained in:
@ -38,6 +38,7 @@ public class WEBDeviceController extends BaseController {
|
||||
private final WEBDeviceService deviceService;
|
||||
private final DeviceBizService appDeviceService;
|
||||
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
@ -52,8 +53,6 @@ public class WEBDeviceController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
*/
|
||||
@ -90,6 +89,7 @@ public class WEBDeviceController extends BaseController {
|
||||
|
||||
/**
|
||||
* 重命名设备
|
||||
*
|
||||
* @param reNameDTO
|
||||
* @return
|
||||
*/
|
||||
|
@ -1,8 +1,13 @@
|
||||
package com.fuyuanshen.web.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.app.domain.AppDeviceBindRecord;
|
||||
import com.fuyuanshen.app.mapper.AppDeviceBindRecordMapper;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceAssignments;
|
||||
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.web.service.WEBDeviceService;
|
||||
@ -10,6 +15,7 @@ import com.fuyuanshen.web.service.device.DeviceBizService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -25,6 +31,10 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
||||
|
||||
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
||||
|
||||
private final AppDeviceBindRecordMapper appDeviceBindRecordMapper;
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
|
||||
|
||||
/**
|
||||
* WEB端解绑设备
|
||||
@ -33,6 +43,7 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int webUnBindDevice(Long id, Long userId) {
|
||||
// 设备端解绑 0:设备端解绑 1:web端解绑
|
||||
int type = 1;
|
||||
@ -44,7 +55,18 @@ public class WEBDeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impl
|
||||
id = deviceAssignments.getDeviceId();
|
||||
type = 0;
|
||||
}
|
||||
return appDeviceService.unBindDevice(id, userId, type);
|
||||
|
||||
QueryWrapper<AppDeviceBindRecord> deviceId = new QueryWrapper<AppDeviceBindRecord>().eq("device_id", id);
|
||||
|
||||
// appDeviceService.unBindDevice(id, userId, type);
|
||||
UpdateWrapper<Device> deviceUpdateWrapper = new UpdateWrapper<>();
|
||||
deviceUpdateWrapper.eq("id", id)
|
||||
.set("binding_user_id", null)
|
||||
.set("binding_status", BindingStatusEnum.UNBOUND.getCode())
|
||||
.set("binding_time", null);
|
||||
deviceMapper.update(null, deviceUpdateWrapper);
|
||||
|
||||
return appDeviceBindRecordMapper.delete(deviceId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.fuyuanshen.system.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.common.core.constant.CacheNames;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
@ -14,10 +15,12 @@ import com.fuyuanshen.system.domain.vo.SysDictDataVo;
|
||||
import com.fuyuanshen.system.service.ISysDictDataService;
|
||||
import com.fuyuanshen.system.service.ISysDictTypeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -73,6 +76,8 @@ public class SysDictDataController extends BaseController {
|
||||
*/
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public R<List<SysDictDataVo>> dictType(@PathVariable String dictType) {
|
||||
// 使用时先清除缓存再查询
|
||||
dictTypeService.clearDictTypeCache(dictType);
|
||||
List<SysDictDataVo> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (ObjectUtil.isNull(data)) {
|
||||
data = new ArrayList<>();
|
||||
@ -94,6 +99,7 @@ public class SysDictDataController extends BaseController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改保存字典类型
|
||||
*/
|
||||
@ -105,6 +111,7 @@ public class SysDictDataController extends BaseController {
|
||||
return R.fail("修改字典数据'" + dict.getDictValue() + "'失败,字典键值已存在");
|
||||
}
|
||||
dictDataService.updateDictData(dict);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
@ -73,4 +73,9 @@ public interface ISysDictDataService {
|
||||
*/
|
||||
boolean checkDictDataUnique(SysDictDataBo dict);
|
||||
|
||||
/**
|
||||
* 清空字典缓存
|
||||
*/
|
||||
void clearDictTypeCache(String dictType);
|
||||
|
||||
}
|
||||
|
@ -92,4 +92,9 @@ public interface ISysDictTypeService {
|
||||
* @return 结果
|
||||
*/
|
||||
boolean checkDictTypeUnique(SysDictTypeBo dictType);
|
||||
|
||||
/**
|
||||
* 清空字典缓存
|
||||
*/
|
||||
void clearDictTypeCache(String dictType);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.fuyuanshen.system.domain.vo.SysDictDataVo;
|
||||
import com.fuyuanshen.system.mapper.SysDictDataMapper;
|
||||
import com.fuyuanshen.system.service.ISysDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -154,4 +155,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// 清除指定dictType的缓存
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
|
||||
public void clearDictTypeCache(String dictType) {
|
||||
// 仅用于清除缓存
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.fuyuanshen.system.domain.vo.SysDictTypeVo;
|
||||
import com.fuyuanshen.system.mapper.SysDictDataMapper;
|
||||
import com.fuyuanshen.system.mapper.SysDictTypeMapper;
|
||||
import com.fuyuanshen.system.service.ISysDictTypeService;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -294,4 +295,11 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
return BeanUtil.copyToList(list, DictDataDTO.class);
|
||||
}
|
||||
|
||||
|
||||
// 清除指定dictType的缓存
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
|
||||
public void clearDictTypeCache(String dictType) {
|
||||
// 仅用于清除缓存
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user