feat(app): 实现系统版本管理功能-Dto 新增 SystemVersion 数据传输对象- 修改 AppAuthController 的 getAppVersion 接口,从 Redis 获取版本信息
- 新增 DeviceXinghanController 的 VersionSettings 接口,用于更新版本信息到 Redis- 引入 FastJSON 和 Redis 工具类支持版本信息的序列化与缓存 - 添加权限注解控制版本更新接口访问 - 定义全局 Redis 键常量用于版本信息存储
This commit is contained in:
@ -5,6 +5,7 @@ import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fuyuanshen.app.model.AppRegisterBody;
|
||||
import com.fuyuanshen.app.model.AppSmsLoginBody;
|
||||
import com.fuyuanshen.app.service.AppLoginService;
|
||||
@ -32,6 +33,7 @@ import com.fuyuanshen.system.service.ISysClientService;
|
||||
import com.fuyuanshen.system.service.ISysConfigService;
|
||||
import com.fuyuanshen.system.service.ISysDictTypeService;
|
||||
import com.fuyuanshen.system.service.ISysTenantService;
|
||||
import com.fuyuanshen.web.domain.Dto.SystemVersionDto;
|
||||
import com.fuyuanshen.web.domain.vo.LoginTenantVo;
|
||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
||||
@ -54,6 +56,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_CODES_KEY;
|
||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
|
||||
|
||||
/**
|
||||
* APP认证
|
||||
@ -261,23 +264,14 @@ public class AppAuthController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/version")
|
||||
public R<List<SysDictDataVo>> getAppVersion() {
|
||||
List<SysDictDataVo> list = dictTypeService.selectDictDataByType("app_version");
|
||||
|
||||
list.forEach(d -> {
|
||||
// 1. 安全拆分
|
||||
String[] arr = d.getRemark() == null ? new String[0] : d.getRemark().split("\\|");
|
||||
if (arr.length < 2) { // 格式不对
|
||||
log.warn("字典数据 app_version 格式非法:dictLabel={}, remark={}", d.getDictLabel(), d.getRemark());
|
||||
d.setDictValue(""); // 或者 d.setDictValue(d.getDictValue());
|
||||
d.setRemark(""); // 下载地址留空
|
||||
return; // 跳过
|
||||
}
|
||||
// 2. 正常赋值
|
||||
d.setDictValue(arr[0].trim()); // 版本号
|
||||
d.setRemark(arr[1].trim()); // 下载地址
|
||||
});
|
||||
|
||||
public R<List<SystemVersionDto>> getAppVersion() {
|
||||
String versionKey = GLOBAL_REDIS_KEY + "System:Version:Xinghan";
|
||||
// 缓存告警消息到Redis
|
||||
String versionJson = RedisUtils.getCacheObject(versionKey);
|
||||
if (StringUtils.isBlank(versionJson)) { // hutool 工具,可用 StringUtils.isBlank 代替
|
||||
return R.fail(versionJson);
|
||||
}
|
||||
List<SystemVersionDto> list = JSON.parseArray(versionJson, SystemVersionDto.class);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user