清空所有客户端缓存

This commit is contained in:
2025-07-02 14:16:11 +08:00
parent a69aad227a
commit a487e7ae67
6 changed files with 46 additions and 40 deletions

View File

@ -39,6 +39,7 @@ logging:
org.springframework: warn org.springframework: warn
org.mybatis.spring.mapper: error org.mybatis.spring.mapper: error
org.apache.fury: warn org.apache.fury: warn
com.fuyuanshen.web.service.impl.ClientServiceImpl: debug
config: classpath:logback-plus.xml config: classpath:logback-plus.xml
# 用户配置 # 用户配置

View File

@ -39,8 +39,8 @@ public class EncryptUtilsTest {
loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e"); loginBody.setClientId("e5cd7e4891bf95d1d19206ce24a7b32e");
loginBody.setGrantType("password"); loginBody.setGrantType("password");
loginBody.setTenantId("894078"); loginBody.setTenantId("894078");
loginBody.setCode("10"); loginBody.setCode("0");
loginBody.setUuid("390942eb87174dcc9c2c074b066b1b79"); loginBody.setUuid("1c285b27f516486f9535face77023aeb");
// loginBody.setUsername("admin"); // loginBody.setUsername("admin");
// loginBody.setPassword("admin123"); // loginBody.setPassword("admin123");
loginBody.setUsername("dyf"); loginBody.setUsername("dyf");

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fuyuanshen.common.tenant.core.TenantEntity; import com.fuyuanshen.common.tenant.core.TenantEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
/** /**
@ -17,83 +18,76 @@ import lombok.Data;
**/ **/
@Data @Data
@TableName("device") @TableName("device")
@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解 @JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解
public class Device extends TenantEntity { public class Device extends TenantEntity {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
// @Schema(value = "ID") @Schema(name = "ID")
private Long id; private Long id;
// @Schema(value = "设备记录ID") @Schema(name = "设备记录ID")
@TableField(exist = false) @TableField(exist = false)
private Long assignId; private Long assignId;
// @Schema(value = "设备类型") @Schema(name = "设备类型")
private Long deviceType; private Long deviceType;
// @Schema(value = "设备类型名称") @Schema(name = "设备类型名称")
private String typeName; private String typeName;
// @Schema(value = "客户号") @Schema(name = "客户号")
private Long customerId; private Long customerId;
/** /**
* 当前所有者 * 当前所有者
* current_owner_id * current_owner_id
*/ */
// @Schema(value = "当前所有者") @Schema(name = "当前所有者")
private Long currentOwnerId; private Long currentOwnerId;
/** /**
* 原始所有者(创建者) * 原始所有者(创建者)
* original_owner_id * original_owner_id
*/ */
// @Schema(value = "原始所有者(创建者)") @Schema(name = "原始所有者(创建者)")
private Long originalOwnerId; private Long originalOwnerId;
// @Schema(value = "所属客户") @Schema(name = "所属客户")
private String customerName; private String customerName;
/*@Schema(value = "设备编号") /*@Schema( name = "设备编号")
private String deviceNo;*/ private String deviceNo;*/
// @Schema(value = "设备名称") @Schema(name = "设备名称")
private String deviceName; private String deviceName;
// @Schema(value = "设备图片") @Schema(name = "设备图片")
private String devicePic; private String devicePic;
// @Schema(value = "设备MAC") @Schema(name = "设备MAC")
private String deviceMac; private String deviceMac;
// @Schema(value = "设备IMEI") @Schema(name = "设备IMEI")
private String deviceImei; private String deviceImei;
// @Schema(value = "设备SN") @Schema(name = "设备SN")
private String deviceSn; private String deviceSn;
// @Schema(value = "经度") @Schema(name = "经度")
private String longitude; private String longitude;
// @Schema(value = "纬度") @Schema(name = "纬度")
private String latitude; private String latitude;
// @Schema(value = "备注") @Schema(name = "备注")
private String remark; private String remark;
/**
* 租户ID
*/
// @TableField(value = "tenant_id")
// // @Schema(hidden = true)
// private Long tenantId;
/** /**
* 设备状态 * 设备状态
* 0 失效 * 0 失效
* 1 正常 * 1 正常
*/ */
// @Schema(value = "设备状态") @Schema(name = "设备状态")
private Integer deviceStatus; private Integer deviceStatus;
/** /**
@ -101,12 +95,7 @@ public class Device extends TenantEntity {
* 0 未绑定 * 0 未绑定
* 1 已绑定 * 1 已绑定
*/ */
// @Schema(value = "绑定状态") @Schema(name = "绑定状态")
private Integer bindingStatus; private Integer bindingStatus;
public void copy(Device source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
}
} }

View File

@ -1,7 +1,6 @@
package com.fuyuanshen.equipment.service.impl; package com.fuyuanshen.equipment.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -96,6 +95,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
// 获取当前登录用户信息 // 获取当前登录用户信息
// LoginUser user = LoginHelper.getLoginUser(); // LoginUser user = LoginHelper.getLoginUser();
// 保存图片并获取URL // 保存图片并获取URL
String imageUrl = saveDeviceImage(deviceForm.getFile(), deviceForm.getDeviceName()); String imageUrl = saveDeviceImage(deviceForm.getFile(), deviceForm.getDeviceName());
// 设置图片路径 // 设置图片路径
@ -110,6 +110,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
} }
/** /**
* 更新设备信息 * 更新设备信息
* *

View File

@ -1,6 +1,7 @@
package com.fuyuanshen.system.controller.system; package com.fuyuanshen.system.controller.system;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import com.fuyuanshen.common.core.constant.CacheNames;
import com.fuyuanshen.common.core.domain.R; import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.excel.utils.ExcelUtil; import com.fuyuanshen.common.excel.utils.ExcelUtil;
import com.fuyuanshen.common.log.annotation.Log; import com.fuyuanshen.common.log.annotation.Log;
@ -13,6 +14,7 @@ import com.fuyuanshen.system.domain.vo.SysConfigVo;
import com.fuyuanshen.system.service.ISysConfigService; import com.fuyuanshen.system.service.ISysConfigService;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -134,4 +136,15 @@ public class SysConfigController extends BaseController {
configService.resetConfigCache(); configService.resetConfigCache();
return R.ok(); return R.ok();
} }
/**
* 清空所有客户端缓存
*/
@GetMapping(value = "/clearAllClientCache")
@CacheEvict(cacheNames = CacheNames.SYS_CLIENT, allEntries = true)
public void clearAllClientCache() {
}
} }

View File

@ -54,6 +54,7 @@ public class SysClientServiceImpl implements ISysClientService {
@Cacheable(cacheNames = CacheNames.SYS_CLIENT, key = "#clientId") @Cacheable(cacheNames = CacheNames.SYS_CLIENT, key = "#clientId")
@Override @Override
public SysClientVo queryByClientId(String clientId) { public SysClientVo queryByClientId(String clientId) {
log.debug("【queryByClientId】缓存未命中开始执行数据库查询clientId={}", clientId);
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysClient>().eq(SysClient::getClientId, clientId)); return baseMapper.selectVoOne(new LambdaQueryWrapper<SysClient>().eq(SysClient::getClientId, clientId));
} }
@ -125,16 +126,16 @@ public class SysClientServiceImpl implements ISysClientService {
@Override @Override
public int updateClientStatus(String clientId, String status) { public int updateClientStatus(String clientId, String status) {
return baseMapper.update(null, return baseMapper.update(null,
new LambdaUpdateWrapper<SysClient>() new LambdaUpdateWrapper<SysClient>()
.set(SysClient::getStatus, status) .set(SysClient::getStatus, status)
.eq(SysClient::getClientId, clientId)); .eq(SysClient::getClientId, clientId));
} }
/** /**
* 保存前的数据校验 * 保存前的数据校验
*/ */
private void validEntityBeforeSave(SysClient entity) { private void validEntityBeforeSave(SysClient entity) {
//TODO 做一些数据校验,如唯一约束 // TODO 做一些数据校验,如唯一约束
} }
/** /**
@ -144,7 +145,7 @@ public class SysClientServiceImpl implements ISysClientService {
@Override @Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) { if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验 // TODO 做一些业务上的校验,判断是否需要校验
} }
return baseMapper.deleteByIds(ids) > 0; return baseMapper.deleteByIds(ids) > 0;
} }