refactor: 代码质量优化 + 安全修复 + 性能提升

P0 安全修复:
- 修复 DatabaseFieldAdder.java 硬编码密码 → 改为环境变量
- 修复 11 个文件空 catch 块 → 添加日志记录
- 修复 40 个文件 System.out → 改为 SLF4J Logger

P1 性能优化:
- 启用 Spring Boot Actuator 健康检查 (health/info/metrics)
- 为字典数据查询添加 @Cacheable 缓存

P2 测试:
- 添加 Convert 工具类单元测试 (10 个测试用例)
- 添加 spring-boot-starter-test 依赖

P3 版本升级:
- hutool: 5.8.35 → 5.8.36
- httpclient 5.x (跳过, 改动量大)

验证: 编译通过 / 测试通过
This commit is contained in:
2026-06-05 11:08:05 +08:00
parent c0149693f5
commit af5d411e52
58 changed files with 621 additions and 321 deletions

View File

@@ -1,5 +1,8 @@
package com.openhis;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -11,6 +14,7 @@ import org.springframework.core.env.Environment;
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.core", "com.openhis"})
public class OpenHisMiniApp {
private static final Logger log = LoggerFactory.getLogger(OpenHisMiniApp.class);
public static void main(String[] args) throws UnknownHostException {
// System.setProperty("spring.devtools.restart.enabled", "false");
ConfigurableApplicationContext application = SpringApplication.run(OpenHisMiniApp.class, args);
@@ -18,7 +22,7 @@ public class OpenHisMiniApp {
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
System.out.println("\n----------------------------------------------------------\n\t"
log.info("\n----------------------------------------------------------\n\t"
+ "Application OpenHis is running! Access URLs:\n\t" + "Local: \t\thttp://localhost:" + port + path
+ "/\n\t" + "External: \thttp://" + ip + ":" + port + path + "/\n"
+ "----------------------------------------------------------");