From 51e838ec5f5a29184350e5bc80cc4d85a0fbd9aa Mon Sep 17 00:00:00 2001 From: wangwei <1610949092@qq.com> Date: Sat, 8 Feb 2025 17:45:29 +0800 Subject: [PATCH] =?UTF-8?q?2/8=20=20=E7=89=88=E6=9C=AC=E9=83=A8=E7=BD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/auth/LoginController.java | 62 +++++++++++++++++-- .../glxp/api/res/auth/WebTitleResponse.java | 9 +++ src/main/resources/application.yml | 3 + 3 files changed, 70 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/glxp/api/controller/auth/LoginController.java b/src/main/java/com/glxp/api/controller/auth/LoginController.java index ff60024f4..03fe98040 100644 --- a/src/main/java/com/glxp/api/controller/auth/LoginController.java +++ b/src/main/java/com/glxp/api/controller/auth/LoginController.java @@ -2,6 +2,7 @@ package com.glxp.api.controller.auth; import cn.hutool.core.date.DateUnit; import cn.hutool.crypto.SecureUtil; +import com.glxp.api.constant.FileConstant; import com.glxp.api.res.basic.UserWorkResponse; import com.glxp.api.res.basic.WorkBindWorkResponse; import com.glxp.api.service.basic.BasicCollectUserService; @@ -32,14 +33,18 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.imageio.ImageIO; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; import java.util.*; import java.util.stream.Collectors; @@ -429,13 +434,62 @@ public class LoginController extends BaseController { @Value("${WEB_SUB_TITLE}") private String WEB_SUB_TITLE; + @Value("${WEB_VERSION}") + private String WEB_VERSION; + @Value("${WEB_LOGO}") + private String WEB_LOGO; + + @GetMapping("/spms/getTitleConfig") public BaseResponse getTitleConfig() { WebTitleResponse webTitleResponse = new WebTitleResponse(); webTitleResponse.setTitle(WEB_TITLE); webTitleResponse.setSubTitle(WEB_SUB_TITLE); + webTitleResponse.setWebVersion(WEB_VERSION); + webTitleResponse.setWebLogo(WEB_LOGO); return ResultVOUtils.success(webTitleResponse); } + @Value("${file_path}") + private String filePath; + + @GetMapping(value = "/udiwms/image/getImage") + public void getImage(HttpServletResponse response, + @RequestParam String type, + @RequestParam String name) throws IOException { + File file = new File(filePath + "/register/" + type + "/" + name); + + // 检查文件是否存在 + if (!file.exists()) { + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + return; + } + + OutputStream os = null; + try { + // 读取图片 + BufferedImage image = ImageIO.read(new FileInputStream(file)); + response.setContentType("image/png"); + os = response.getOutputStream(); + + if (image != null) { + ImageIO.write(image, "png", os); + } + } catch (IOException e) { + e.printStackTrace(); + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } finally { + if (os != null) { + try { + os.flush(); + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + } diff --git a/src/main/java/com/glxp/api/res/auth/WebTitleResponse.java b/src/main/java/com/glxp/api/res/auth/WebTitleResponse.java index 6b5e2e938..ecd6d81d8 100644 --- a/src/main/java/com/glxp/api/res/auth/WebTitleResponse.java +++ b/src/main/java/com/glxp/api/res/auth/WebTitleResponse.java @@ -7,4 +7,13 @@ public class WebTitleResponse { private String title; private String subTitle; + /** + * 版本名称 + */ + private String webVersion; + + /** + * logo地址 + */ + private String webLogo; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9b5217c08..34f13bdc6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -38,3 +38,6 @@ server: WEB_TITLE: 平潭协和医院 WEB_SUB_TITLE: 医院UDI管理系统 +WEB_VERSION: +WEB_LOGO: +#http://127.0.0.1:9991/udiwms/image/getImage?type=image1&name=dima.jpg