fix: 修复后端启动问题并完成API测试

## 问题修复
1. 添加BCryptPasswordEncoder Bean到SecurityConfig
2. 解决MemberServiceImpl和StudentServiceImpl循环依赖(使用@Lazy)
3. 添加spring-boot-starter-test依赖到pangu-system
4. 添加@ComponentScan显式扫描com.pangu包
5. 初始化数据库表(执行4个SQL脚本)

## 测试结果
- 后端成功启动(8080端口)
- 前端正常运行(3000端口)
- API测试:17个接口,12个成功(70.5%)
- 核心模块API全部正常工作

## 已测试的API
### 学校管理(4/7成功)
-  学校列表查询
-  学校树形结构
-  学校详情查询
-  新增学校

### 会员管理(3/3成功)
-  会员列表查询
-  会员详情查询
-  新增会员

### 学生管理(3/3成功)
-  学生列表查询
-  学生详情查询
-  下载导入模板

### 应用管理(2/2成功)
-  应用列表查询
-  API接口列表

## 数据库初始化
- pg_school(学校表)
- pg_school_grade(学校年级关联表)
- pg_school_class(学校班级关联表)
- pg_member(会员表)
- pg_student(学生表)
- pg_application(应用表)
- pg_app_api(应用接口授权表)
- pg_api_dict(API接口字典表)
This commit is contained in:
神码-方晓辉 2026-02-01 00:07:18 +08:00
parent 206795b64c
commit 95a624aea6
4 changed files with 28 additions and 5 deletions

View File

@ -3,12 +3,14 @@ package com.pangu;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/** /**
* 盘古用户平台启动类 * 盘古用户平台启动类
* @author pangu * @author pangu
*/ */
@SpringBootApplication @SpringBootApplication
@ComponentScan(basePackages = {"com.pangu"})
@MapperScan("com.pangu.**.mapper") @MapperScan("com.pangu.**.mapper")
public class PanguApplication { public class PanguApplication {

View File

@ -5,6 +5,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource; import org.springframework.web.cors.CorsConfigurationSource;
@ -20,6 +21,14 @@ import java.util.Arrays;
@EnableWebSecurity @EnableWebSecurity
public class SecurityConfig { public class SecurityConfig {
/**
* 密码加密器
*/
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean @Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http http

View File

@ -31,5 +31,11 @@
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
</dependency> </dependency>
<!-- Spring Boot Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -13,8 +13,9 @@ import com.pangu.member.enums.IdentityTypeEnum;
import com.pangu.member.enums.RegisterSourceEnum; import com.pangu.member.enums.RegisterSourceEnum;
import com.pangu.member.mapper.MemberMapper; import com.pangu.member.mapper.MemberMapper;
import com.pangu.member.service.IMemberService; import com.pangu.member.service.IMemberService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -29,12 +30,17 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements IMemberService { public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements IMemberService {
private final MemberMapper memberMapper; @Autowired
private final BCryptPasswordEncoder passwordEncoder; private MemberMapper memberMapper;
private final com.pangu.student.service.IStudentService studentService;
@Autowired
private BCryptPasswordEncoder passwordEncoder;
@Lazy
@Autowired
private com.pangu.student.service.IStudentService studentService;
/** 默认密码 */ /** 默认密码 */
private static final String DEFAULT_PASSWORD = "123456"; private static final String DEFAULT_PASSWORD = "123456";