From 7f65ebedc213a0014a02482e3de66fe61bc3496c Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Wed, 20 Aug 2025 13:31:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/system/SysDictDataController.java | 7 +++++++ .../fuyuanshen/system/service/ISysDictDataService.java | 5 +++++ .../fuyuanshen/system/service/ISysDictTypeService.java | 5 +++++ .../system/service/impl/SysDictDataServiceImpl.java | 9 +++++++++ .../system/service/impl/SysDictTypeServiceImpl.java | 8 ++++++++ 5 files changed, 34 insertions(+) diff --git a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/controller/system/SysDictDataController.java b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/controller/system/SysDictDataController.java index ff3b6dc..4ba67de 100644 --- a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/controller/system/SysDictDataController.java +++ b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/controller/system/SysDictDataController.java @@ -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> dictType(@PathVariable String dictType) { + // 使用时先清除缓存再查询 + dictTypeService.clearDictTypeCache(dictType); List 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(); } diff --git a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/ISysDictDataService.java b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/ISysDictDataService.java index 1f8fc32..d5f0375 100644 --- a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/ISysDictDataService.java +++ b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/ISysDictDataService.java @@ -73,4 +73,9 @@ public interface ISysDictDataService { */ boolean checkDictDataUnique(SysDictDataBo dict); + /** + * 清空字典缓存 + */ + void clearDictTypeCache(String dictType); + } diff --git a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/ISysDictTypeService.java b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/ISysDictTypeService.java index 004b6e5..183ceb5 100644 --- a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/ISysDictTypeService.java +++ b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/ISysDictTypeService.java @@ -92,4 +92,9 @@ public interface ISysDictTypeService { * @return 结果 */ boolean checkDictTypeUnique(SysDictTypeBo dictType); + + /** + * 清空字典缓存 + */ + void clearDictTypeCache(String dictType); } diff --git a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/impl/SysDictDataServiceImpl.java b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/impl/SysDictDataServiceImpl.java index adcf47d..19f5544 100644 --- a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/impl/SysDictDataServiceImpl.java +++ b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/impl/SysDictDataServiceImpl.java @@ -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) { + // 仅用于清除缓存 + } + + } diff --git a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/impl/SysDictTypeServiceImpl.java b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/impl/SysDictTypeServiceImpl.java index 822a2b8..692675c 100644 --- a/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/impl/SysDictTypeServiceImpl.java +++ b/fys-modules/fys-system/src/main/java/com/fuyuanshen/system/service/impl/SysDictTypeServiceImpl.java @@ -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) { + // 仅用于清除缓存 + } + } From bb11bc4dfa3824186f72bd6460aa873f261a5ad9 Mon Sep 17 00:00:00 2001 From: daiyongfei <974332738@qq.com> Date: Wed, 20 Aug 2025 15:13:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?WEB=E7=AB=AF=E8=A7=A3=E7=BB=91=E8=AE=BE?= =?UTF-8?q?=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/WEBDeviceController.java | 6 ++--- .../service/impl/WEBDeviceServiceImpl.java | 24 ++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java index 0d19676..71be510 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/WEBDeviceController.java @@ -38,6 +38,7 @@ public class WEBDeviceController extends BaseController { private final WEBDeviceService deviceService; private final DeviceBizService appDeviceService; + /** * @param id * @return @@ -52,14 +53,12 @@ public class WEBDeviceController extends BaseController { } - - /** * 查询设备列表 */ @GetMapping("/list") public TableDataInfo list(DeviceQueryCriteria bo, PageQuery pageQuery) { - return appDeviceService.queryAppDeviceList(bo,pageQuery); + return appDeviceService.queryAppDeviceList(bo, pageQuery); } /** @@ -90,6 +89,7 @@ public class WEBDeviceController extends BaseController { /** * 重命名设备 + * * @param reNameDTO * @return */ diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java index f38a2e8..7e328b8 100644 --- a/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java +++ b/fys-admin/src/main/java/com/fuyuanshen/web/service/impl/WEBDeviceServiceImpl.java @@ -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 impl private final DeviceAssignmentsMapper deviceAssignmentsMapper; + private final AppDeviceBindRecordMapper appDeviceBindRecordMapper; + + private final DeviceMapper deviceMapper; + /** * WEB端解绑设备 @@ -33,6 +43,7 @@ public class WEBDeviceServiceImpl extends ServiceImpl 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 impl id = deviceAssignments.getDeviceId(); type = 0; } - return appDeviceService.unBindDevice(id, userId, type); + + QueryWrapper deviceId = new QueryWrapper().eq("device_id", id); + + // appDeviceService.unBindDevice(id, userId, type); + UpdateWrapper 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); }