修复学校/教师/家长用户登录失败和课程套餐创建的问题。 **问题修复:** - 修正实体类表名映射(去除 t_ 前缀) - 添加Tenant登录支持到AuthServiceImpl - 为Tenant实体添加username和password字段 - 添加school角色的getCurrentUserInfo和changePassword支持 **实体类表名修正:** - Teacher.java: t_teacher → teachers - Parent.java: t_parent → parents - Student.java: t_student → students - AdminUser.java: t_admin_user → admin_users - Tenant.java: t_tenant → tenants **AuthServiceImpl增强:** - 添加TenantMapper依赖 - 添加school角色枚举支持 - login方法添加tenant自动检测 - getCurrentUserInfo添加school case - changePassword添加school case **新增文件:** - init-users.sql - 用户数据初始化脚本 - V20260312__fix_login_issues.sql - 数据库迁移脚本 - 2026-03-12-full-test.md - 功能测试记录 **测试结果:** ✅ 超管登录 (admin/123456) ✅ 学校登录 (school1/123456) ✅ 教师登录 (teacher1/123456) ✅ 家长登录 (parent1/123456) ✅ 课程套餐创建 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| src/main | ||
| db_migrate.py | ||
| db-migrate.sh | ||
| init-users.sql | ||
| pom.xml | ||
| README.md | ||
Reading Platform Java Backend
Spring Boot + MyBatis-Plus backend for the Reading Platform.
Tech Stack
- Java: 17
- Spring Boot: 3.2.3
- MyBatis-Plus: 3.5.5
- MySQL: 8.0+
- Spring Security + JWT: Authentication
- Knife4j: API Documentation (Swagger)
- Lombok: Boilerplate reduction
Project Structure
reading-platform-java/
├── pom.xml # Maven dependencies
├── src/main/java/com/reading/platform/
│ ├── ReadingPlatformApplication.java
│ ├── common/ # Common components
│ │ ├── config/ # Configuration classes
│ │ ├── exception/ # Exception handling
│ │ ├── response/ # Unified response
│ │ ├── security/ # JWT security
│ │ ├── annotation/ # Custom annotations
│ │ ├── enums/ # Enum classes
│ │ ├── aspect/ # AOP aspects
│ │ └── util/ # Utilities
│ ├── entity/ # Entity classes (27)
│ ├── mapper/ # MyBatis-Plus mappers (27)
│ ├── service/ # Service interfaces
│ ├── service/impl/ # Service implementations
│ ├── controller/ # REST controllers
│ │ ├── admin/ # Super admin endpoints
│ │ ├── school/ # School admin endpoints
│ │ ├── teacher/ # Teacher endpoints
│ │ └── parent/ # Parent endpoints
│ └── dto/ # Data Transfer Objects
│ ├── request/
│ └── response/
└── src/main/resources/
├── application.yml # Main configuration
├── application-dev.yml # Dev environment config
├── mapper/ # MyBatis XML files
└── db/migration/ # SQL scripts
Quick Start
1. Prerequisites
- JDK 17+
- Maven 3.6+
- MySQL 8.0+
2. Database Setup
# Create database and import schema
mysql -u root -p < src/main/resources/db/migration/V1__init_schema.sql
3. Configuration
Edit src/main/resources/application-dev.yml:
spring:
datasource:
url: jdbc:mysql://localhost:3306/reading_platform
username: your_username
password: your_password
4. Build and Run
# Build
mvn clean package -DskipTests
# Run
java -jar target/reading-platform-1.0.0.jar
# Or run with Maven
mvn spring-boot:run
5. API Documentation
After starting the application, access the API documentation at:
- Swagger UI: http://localhost:8080/swagger-ui.html
- Knife4j UI: http://localhost:8080/doc.html
API Endpoints
Authentication
POST /api/auth/login- User loginGET /api/auth/me- Get current user infoPOST /api/auth/change-password- Change password
Admin Endpoints
/api/admin/tenants- Tenant management/api/admin/courses- System course management
School Endpoints
/api/school/teachers- Teacher management/api/school/students- Student management/api/school/classes- Class management/api/school/parents- Parent management/api/school/tasks- Task management/api/school/growth-records- Growth record management
Teacher Endpoints
/api/teacher/courses- View courses/api/teacher/lessons- Lesson management/api/teacher/tasks- Task management/api/teacher/growth-records- Growth record management/api/teacher/notifications- Notifications
Parent Endpoints
/api/parent/children- Child information/api/parent/tasks- View and complete tasks/api/parent/growth-records- Growth record management/api/parent/notifications- Notifications
Test Accounts
| Role | Username | Password |
|---|---|---|
| Admin | admin | admin123 |
School, teacher, and parent accounts need to be created through the admin interface.
Database Tables (27)
| Module | Tables |
|---|---|
| Tenant | tenants, tenant_courses |
| Users | admin_users, teachers, students, parents, parent_students |
| Class | classes, class_teachers, student_class_history |
| Course | courses, course_versions, course_resources, course_scripts, course_script_pages, course_activities |
| Lesson | lessons, lesson_feedbacks, student_records |
| Task | tasks, task_targets, task_completions, task_templates |
| Growth | growth_records |
| Resource | resource_libraries, resource_items |
| Schedule | schedule_plans, schedule_templates |
| System | system_settings, notifications, operation_logs, tags |
Development
Adding a New Entity
- Create entity class in
entity/ - Create mapper interface in
mapper/ - Create service interface in
service/ - Create service implementation in
service/impl/ - Create controller in appropriate
controller/subdirectory
Code Style
- Use Lombok annotations to reduce boilerplate
- Follow Spring Boot conventions
- Use
@RequireRoleannotation for role-based access control
License
MIT License