Merge pull request 'feat(app): 实现系统版本管理功能-Dto 新增 SystemVersion 数据传输对象- 修改 AppAuthController 的 getAppVersion 接口,从 Redis 获取版本信息' (#16) from liwenlong/fys-Multi-tenant:jingquan into jingquan
Reviewed-on: #16
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.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.fuyuanshen.app.model.AppRegisterBody;
|
import com.fuyuanshen.app.model.AppRegisterBody;
|
||||||
import com.fuyuanshen.app.model.AppSmsLoginBody;
|
import com.fuyuanshen.app.model.AppSmsLoginBody;
|
||||||
import com.fuyuanshen.app.service.AppLoginService;
|
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.ISysConfigService;
|
||||||
import com.fuyuanshen.system.service.ISysDictTypeService;
|
import com.fuyuanshen.system.service.ISysDictTypeService;
|
||||||
import com.fuyuanshen.system.service.ISysTenantService;
|
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.LoginTenantVo;
|
||||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||||
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
||||||
@ -54,6 +56,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_CODES_KEY;
|
import static com.fuyuanshen.common.core.constant.GlobalConstants.DEVICE_SHARE_CODES_KEY;
|
||||||
|
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APP认证
|
* APP认证
|
||||||
@ -261,23 +264,14 @@ public class AppAuthController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("/version")
|
@GetMapping("/version")
|
||||||
public R<List<SysDictDataVo>> getAppVersion() {
|
public R<List<SystemVersionDto>> getAppVersion() {
|
||||||
List<SysDictDataVo> list = dictTypeService.selectDictDataByType("app_version");
|
String versionKey = GLOBAL_REDIS_KEY + "System:Version:Xinghan";
|
||||||
|
// 缓存告警消息到Redis
|
||||||
list.forEach(d -> {
|
String versionJson = RedisUtils.getCacheObject(versionKey);
|
||||||
// 1. 安全拆分
|
if (StringUtils.isBlank(versionJson)) { // hutool 工具,可用 StringUtils.isBlank 代替
|
||||||
String[] arr = d.getRemark() == null ? new String[0] : d.getRemark().split("\\|");
|
return R.fail(versionJson);
|
||||||
if (arr.length < 2) { // 格式不对
|
}
|
||||||
log.warn("字典数据 app_version 格式非法:dictLabel={}, remark={}", d.getDictLabel(), d.getRemark());
|
List<SystemVersionDto> list = JSON.parseArray(versionJson, SystemVersionDto.class);
|
||||||
d.setDictValue(""); // 或者 d.setDictValue(d.getDictValue());
|
|
||||||
d.setRemark(""); // 下载地址留空
|
|
||||||
return; // 跳过
|
|
||||||
}
|
|
||||||
// 2. 正常赋值
|
|
||||||
d.setDictValue(arr[0].trim()); // 版本号
|
|
||||||
d.setRemark(arr[1].trim()); // 下载地址
|
|
||||||
});
|
|
||||||
|
|
||||||
return R.ok(list);
|
return R.ok(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,21 @@
|
|||||||
package com.fuyuanshen.web.controller.device;
|
package com.fuyuanshen.web.controller.device;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
|
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
|
||||||
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
|
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
|
||||||
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
|
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
|
||||||
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
|
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
|
||||||
import com.fuyuanshen.common.core.domain.R;
|
import com.fuyuanshen.common.core.domain.R;
|
||||||
|
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||||
import com.fuyuanshen.common.core.validate.AddGroup;
|
import com.fuyuanshen.common.core.validate.AddGroup;
|
||||||
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
|
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
|
||||||
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
|
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
|
||||||
|
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||||
import com.fuyuanshen.common.web.core.BaseController;
|
import com.fuyuanshen.common.web.core.BaseController;
|
||||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||||
import com.fuyuanshen.web.domain.Dto.DeviceXinghanInstructDto;
|
import com.fuyuanshen.web.domain.Dto.DeviceXinghanInstructDto;
|
||||||
|
import com.fuyuanshen.web.domain.Dto.SystemVersionDto;
|
||||||
import com.fuyuanshen.web.domain.vo.DeviceXinghanDetailVo;
|
import com.fuyuanshen.web.domain.vo.DeviceXinghanDetailVo;
|
||||||
import com.fuyuanshen.web.service.device.DeviceXinghanBizService;
|
import com.fuyuanshen.web.service.device.DeviceXinghanBizService;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
@ -19,6 +24,13 @@ import org.springframework.validation.annotation.Validated;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.fuyuanshen.common.core.constant.GlobalConstants.GLOBAL_REDIS_KEY;
|
||||||
|
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_ALARM_MESSAGE_KEY_PREFIX;
|
||||||
|
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备控制类 HBY670
|
* 设备控制类 HBY670
|
||||||
*/
|
*/
|
||||||
@ -130,4 +142,22 @@ public class DeviceXinghanController extends BaseController {
|
|||||||
deviceXinghanBizService.upShakeBitSettings(params);
|
deviceXinghanBizService.upShakeBitSettings(params);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本更新
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("system:appVersion:up")
|
||||||
|
@PostMapping("/UpVersion")
|
||||||
|
public R<Void> VersionSettings(@RequestBody List<SystemVersionDto> params) {
|
||||||
|
// params 已经是 List<SystemVersionDto>
|
||||||
|
// 2. 转 JSON 并写 Redis,key 自己定,带个过期时间
|
||||||
|
String versionKey = GLOBAL_REDIS_KEY + "System:Version:Xinghan";
|
||||||
|
String json = JSON.toJSONString(params); // fastjson
|
||||||
|
if (StringUtils.isBlank(json)) { // hutool 工具,可用 StringUtils.isBlank 代替
|
||||||
|
return R.fail("信息无效");
|
||||||
|
}
|
||||||
|
// 缓存告警消息到Redis
|
||||||
|
RedisUtils.setCacheObject(versionKey, json, Duration.ofDays(30));
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.fuyuanshen.web.domain.Dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SystemVersionDto {
|
||||||
|
private String dictValue;
|
||||||
|
private String dictLabel;
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user