diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java index 60cfbad..0708893 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AppController.java @@ -700,4 +700,18 @@ public class AppController extends BaseController BeanUtils.copyProperties(appPatientRecordReq, tRecordResultReq); return AjaxResult.success(tRecordService.selectTRecordListWithoutResult(tRecordResultReq)); } + + /** + * 查询版本信息 + * + * @return {@code AjaxResult} + */ + @ApiOperation("APP查询版本信息") + @Log(title = "APP查询版本信息", businessType = BusinessType.OTHER) + @GetMapping("/version/info") + public AjaxResult queryVersionInformation(){ + String localPath = RuoYiConfig.getProfile(); + String file = FileUtils.readJsonFile(localPath + "appVersion.json"); + return AjaxResult.success(JSONObject.parseObject(file)); + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/LoginFilter.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/LoginFilter.java index 141b9e3..ccbefde 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/LoginFilter.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/LoginFilter.java @@ -44,6 +44,7 @@ public class LoginFilter implements Filter { filterUrlList.add("/api/app/doctor/info"); filterUrlList.add("/api/app/patient/info"); filterUrlList.add("/api/app/patient/modify"); + filterUrlList.add("/api/app/version/info"); if (!filterUrlList.contains(currentUrl)) { LoginUser loginUser = userTokenService.getLoginUser((HttpServletRequest) servletRequest); diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java index 3556ee1..8768ecf 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -1,12 +1,6 @@ package com.ruoyi.common.utils.file; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; +import java.io.*; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Base64; @@ -345,4 +339,31 @@ public class FileUtils throw new ServiceException("Base64转图片错误,message is " + e.getMessage()); } } + + /** + * 读取json文件 + * + * @param Filename 文件名 + * @return {@code String} + */ + public static String readJsonFile(String Filename) { + String jsonStr = ""; + try { + File jsonFile = new File(Filename); + FileReader fileReader = new FileReader(jsonFile); + Reader reader = new InputStreamReader(new FileInputStream(jsonFile), StandardCharsets.UTF_8); + int ch; + StringBuilder sb = new StringBuilder(); + while ((ch = reader.read()) != -1) { + sb.append((char) ch); + } + fileReader.close(); + reader.close(); + jsonStr = sb.toString(); + return jsonStr; + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } }