feat(xg): 新增按学号重置学生密码(Web/移动端)

学工老师可按学号查询并重置学生登录密码为固定默认值,独立权限不复用系统用户重置。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
“wuzhen”andCursor committed 2026-10-26 08:29:50 +08:00
1 parent 0765f00458
commit df4c21bd0d
14 files changed
+781

No files matched your search

+1
View File
@@ -8,6 +8,7 @@
## API模块列表
- [学生信息管理API](./学生信息管理API.md)
- [学生密码重置API](./学生密码重置API.md) - **新增**:按学号查询并重置学生登录密码为固定默认值(2026-10-26)
- [学生信息收集批次管理API](./学生信息收集批次管理API.md)
- [学生信息收集批次API](./学生信息收集批次API.md) - **重要更新**:修改列表排序方式为按创建时间倒序(2025-01-03)
- [班级信息管理API](./班级信息管理API.md)
@@ -0,0 +1,141 @@
# 学生密码重置 API 接口文档
## 模块概述
**模块名称**:Student Password Reset / 学生密码重置
**基础路径**:`/studentMsg/studentMsg`
**版本**:v1.0
**负责人**:学工模块
**更新时间**:2026-10-26
### 模块功能
学工老师按学号查询学生基本信息后,一键将对应学生登录账号密码重置为系统固定默认值。
**不复用** `system:user:resetPwd`,避免把系统用户管理权下放给学工老师。
**核心约束**:
- 仅允许重置 `sys_user.account_type = '2'`(学生账号)
- 要求 `user_id = xg_student_msg.id`,且 `user_name` 与学号一致(若有用户名)
- 密码由服务端写死常量,前端不可传入自定义密码
- 有菜单/按钮权限即可操作任意学生,不做班主任数据范围限制
**固定默认密码**(服务端常量,勿在客户端硬编码用于改密请求):`Hzdyjsxs123456!@#`
### 权限说明
| 权限标识 | 说明 |
| -------- | ---- |
| `studentMsg:studentPwdReset:list` | Web 菜单页可见 |
| `studentMsg:studentPwdReset:query` | 按学号查询 |
| `studentMsg:studentPwdReset:reset` | 确认重置密码 |
| `student:pwdreset:listapp` | 移动端首页入口可见 |
菜单脚本:`backend/script/sql/update/update_20261026_student_pwd_reset_menu.sql`
---
## 接口概览
| 接口名称 | HTTP 方法 | 路径 | 权限要求 | 功能描述 |
| -------- | --------- | ---- | -------- | -------- |
| 按学号查询学生 | GET | `/studentMsg/studentMsg/queryByStudentNo/{studentNo}` | `studentMsg:studentPwdReset:query` | 返回姓名、学号、班级、班主任 |
| 重置学生密码 | PUT | `/studentMsg/studentMsg/resetStudentPassword/{studentNo}` | `studentMsg:studentPwdReset:reset` | 重置为固定默认密码 |
---
## 详细接口说明
### 1. 按学号查询学生(重置密码页)
- **接口路径**:`GET /studentMsg/studentMsg/queryByStudentNo/{studentNo}`
- **权限标识**:`studentMsg:studentPwdReset:query`
- **功能描述**:按学号查询学生档案,用于重置前确认身份;班主任姓名优先取学生档案,为空时回退班级表
#### 路径参数
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | ---- |
| studentNo | string | 是 | 学号 |
#### 成功响应
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"id": 1234567890123456789,
"studentNo": "202513063048",
"name": "张三",
"className": "计应2401",
"classTeacherName": "李老师"
}
}
```
#### 错误场景
| 场景 | 提示 |
| ---- | ---- |
| 学号为空 | 学号不能为空 |
| 学号不存在 | 未找到学号对应的学生信息 |
| 无权限 | 403 |
---
### 2. 重置学生密码
- **接口路径**:`PUT /studentMsg/studentMsg/resetStudentPassword/{studentNo}`
- **权限标识**:`studentMsg:studentPwdReset:reset`
- **功能描述**:将学号对应学生登录密码重置为固定默认值;写操作日志「重置学生密码」
- **防重复提交**:`@RepeatSubmit`
#### 路径参数
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---- | ---- | ---- |
| studentNo | string | 是 | 学号 |
#### 请求体
无。密码由服务端常量生成 BCrypt 后写入,不允许客户端传密。
#### 成功响应
```json
{
"code": 200,
"msg": "操作成功"
}
```
#### 错误场景
| 场景 | 提示 |
| ---- | ---- |
| 学号不存在 | 未找到学号对应的学生信息 |
| 无登录账号 | 该学生没有登录账号,无法重置密码 |
| 非学生账号 | 该账号不是学生账号,禁止重置 |
| 学号与登录名不一致 | 学号与登录账号不一致,请联系管理员 |
| 无权限 | 403 |
---
## 前端与移动端
| 端 | 路径 / 入口 |
| -- | ----------- |
| Web | `web/src/views/xg/xsjcxx/studentMsg/studentPwdReset/index.vue` |
| Web API | `web/src/api/xg/xsjcxx/studentMsg/studentMsg/index.ts` → `queryStudentForPwdReset` / `resetStudentPassword` |
| 移动端页面 | `mobile/src/pages/xg/xsjcxx/studentPwdReset/index.vue` |
| 移动端 API | `mobile/src/api/studentPwdReset.js` |
| 移动端首页 | 学工管理 →「重置学生密码」(`student:pwdreset:listapp`) |
---
## 验收要点
1. 有权限账号:学号查得到 → 重置成功 → 该学号可用默认密码登录
2. 无权限账号:接口 403
3. 不存在学号 / 无用户 / 非学生账号:友好错误,不改密
4. Web、移动端流程一致:输入学号 → 查询 → 确认 → 重置