# Avid **Repository Path**: lizhangyang666/avid ## Basic Information - **Project Name**: Avid - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2025-09-25 - **Last Updated**: 2025-12-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Exam System API Backend stack: Spring Boot 3 + MyBatis-Plus + MySQL 5.7 + JWT. Passwords are stored with BCrypt. All responses are wrapped in a unified Result: { code, msg, object }. Base URL: http://localhost:8080 Auth: Use Authorization: Bearer header for protected endpoints. Result envelope - Success: { code: 0, msg: "success", object: ... } - Failure: { code: non-zero, msg: "error message", object: null } - HTTP status is 200 in most cases; rely on code to judge success. Endpoints 1) Register - POST /api/auth/register - Body { "studentId": "2023000001", "name": "张三", "gender": "男", // 可选,男/女 "major": "计算机", // 可选 "password": "123456" } - Response { "code": 0, "msg": "success", "object": null } - Errors - 409 学号已被注册 - 400 参数错误 2) Login - POST /api/auth/login - Body { "studentId": "2023000001", "password": "123456" } - Response { "code": 0, "msg": "success", "object": { "token": "", "user": { "studentId": "2023000001", "name": "张三" } } } - Errors - 401 账号或密码错误 3) Join Course by Code (requires login) - POST /api/course/join - Headers Authorization: Bearer - Body { "courseCode": "ABC123" } - Response { "code": 0, "msg": "success", "object": null } - Errors - 401 未登录/无效的登录凭证 - 400 课程不存在 - 400 已加入该课程 Curl examples - Register curl -X POST http://localhost:8080/api/auth/register -H "Content-Type: application/json" -d "{\"studentId\":\"2023000001\",\"name\":\"张三\",\"gender\":\"男\",\"password\":\"123456\"}" - Login curl -X POST http://localhost:8080/api/auth/login -H "Content-Type: application/json" -d "{\"studentId\":\"2023000001\",\"password\":\"123456\"}" - Join course curl -X POST http://localhost:8080/api/course/join -H "Authorization: Bearer " -H "Content-Type: application/json" -d "{\"courseCode\":\"ABC123\"}" Frontend integration (Vue 2 + axios) - Create an axios instance with baseURL and an interceptor to attach the token stored after login. - Simple API methods - register(data) - login(data) -> returns token and user; persist token (e.g., localStorage) - joinCourse({ courseCode }) Example axios service (pseudo-code) - axios base const api = axios.create({ baseURL: 'http://localhost:8080' }) api.interceptors.request.use(cfg => { const t = localStorage.getItem('token'); if (t) cfg.headers.Authorization = `Bearer ${t}`; return cfg; }) api.interceptors.response.use(res => { const r = res.data; if (r && r.code === 0) return r.object; return Promise.reject(r); }) - methods export const register = (payload) => api.post('/api/auth/register', payload) export const login = async (payload) => { const out = await api.post('/api/auth/login', payload); localStorage.setItem('token', out.token); return out } export const joinCourse = (payload) => api.post('/api/course/join', payload) JWT details - Subject: studentId - Claims: name - Expiration: default 30 days (security.jwt.expiration-ms) - Secret: configure security.jwt.secret (at least 32 chars) Database tables (key ones) - student(student_id PK, name, gender, major, enrollment_time, password, avatar_url) - course(course_id PK auto, course_code UNIQUE, ...) - student_course(id PK auto, student_id, course_id) Config - application.properties keys to adjust spring.datasource.url=jdbc:mysql://localhost:3306/exam_db?... spring.datasource.username=... spring.datasource.password=... security.jwt.secret=... Notes - Passwords are bcrypt-hashed on registration; login compares raw password to stored hash. - Re-joining the same course returns 400 ("已加入该课程"). - CORS is open by default in WebMvcConfig.