Fix compilation errors and update models

This commit is contained in:
wanxiaoli 2026-01-05 17:21:25 +08:00
commit b86d8abd07
3 changed files with 60 additions and 27 deletions

View File

@ -51,6 +51,23 @@
4. 增加 OpenAPI 文档与前端集成接口规范。 4. 增加 OpenAPI 文档与前端集成接口规范。
5. 引入结果持久化与查询报表。 5. 引入结果持久化与查询报表。
## 调试与开发指南
### Maven 命令行启动 + 远程调试
如果您偏好使用命令行启动,或者需要模拟特定的 Maven 环境,可采用以下方式:
1. **启动应用**
在终端中运行以下命令,该命令会以调试模式启动应用并监听 `5005` 端口(`suspend=n` 表示不等待调试器连接直接启动,如需等待可改为 `y`)。
> 注意PowerShell 中需要使用单引号包裹 JVM 参数,防止解析错误。
```bash
mvn -DskipTests spring-boot:run -pl business-css '-Dspring-boot.run.jvmArguments=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005'
```
2. **附加调试器**
应用启动后,转到 IDE 的 "运行和调试" (Run and Debug) 面板,选择 **"Attach to Remote Program5005"** 配置(需确保 `.vscode/launch.json` 中已存在相应配置然后点击运行。IDE 将连接到正在运行的 Maven 进程,即可开始断点调试。
## 运维与配置 ## 运维与配置
- 端口默认 `8082`,环境覆盖通过 `application.yml` 与外部化配置。 - 端口默认 `8082`,环境覆盖通过 `application.yml` 与外部化配置。
- 数据库连接按环境注入dev/test/prod - 数据库连接按环境注入dev/test/prod

View File

@ -66,6 +66,13 @@
<classifier>plain</classifier> <classifier>plain</classifier>
</dependency> </dependency>
<!-- 显式添加 MyBatis-Plus 依赖,确保测试环境类加载正确 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.6</version>
</dependency>
<!-- Lombok --> <!-- Lombok -->
<dependency> <dependency>

View File

@ -4,6 +4,7 @@ import com.yfd.platform.config.bean.LoginProperties;
import com.yfd.platform.exception.AccessDeniedHandExcetion; import com.yfd.platform.exception.AccessDeniedHandExcetion;
import com.yfd.platform.exception.AuthenticationException; import com.yfd.platform.exception.AuthenticationException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -19,6 +20,9 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
@Configuration @Configuration
public class SecurityConfig { public class SecurityConfig {
// 1. 注入配置项默认为 false
@Value("${security.dev.permit:false}")
private boolean devPermit;
@Bean @Bean
public PasswordEncoder passwordEncoder() { public PasswordEncoder passwordEncoder() {
@ -50,8 +54,12 @@ public class SecurityConfig {
http http
.csrf(csrf -> csrf.disable()) .csrf(csrf -> csrf.disable())
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authorizeHttpRequests(auth -> auth .authorizeHttpRequests(auth -> {
.requestMatchers("/user/login").anonymous() // 如果配置为 true则允许所有请求
if (devPermit) {
auth.anyRequest().permitAll();
} else {
auth.requestMatchers("/user/login").anonymous()
.requestMatchers("/user/code").permitAll() .requestMatchers("/user/code").permitAll()
.requestMatchers(HttpMethod.GET, .requestMatchers(HttpMethod.GET,
"/*.html", "/*.html",
@ -73,8 +81,9 @@ public class SecurityConfig {
"/avatar/**", "/avatar/**",
"/systemurl/**", "/systemurl/**",
"/api/imageserver/upload").permitAll() "/api/imageserver/upload").permitAll()
.anyRequest().authenticated() .anyRequest().authenticated();
) }
})
.cors(cors -> {}); .cors(cors -> {});
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class); http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);