-
-
-
-
- 个人信息
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
{{ username }}
+
+
{{ email }}
+
+
+ 这是一个个人简介
+
+
+
+
+
✨
+
✨
+
💜
+
🐱
+
🍰
+
+
\ No newline at end of file
From d05eb50b441a61b91dc23b0d6b3fc3e8d78c2eda Mon Sep 17 00:00:00 2001
From: 2991692032
Date: Mon, 7 Apr 2025 10:10:00 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
UniLife开发文档.md | 156 +++++++++++++++++-
.../unilife/controller/UserController.java | 15 +-
2 files changed, 159 insertions(+), 12 deletions(-)
diff --git a/UniLife开发文档.md b/UniLife开发文档.md
index fbfdd20..249af4d 100644
--- a/UniLife开发文档.md
+++ b/UniLife开发文档.md
@@ -66,8 +66,8 @@
| id | BIGINT | PRIMARY KEY, AUTO_INCREMENT | 用户ID |
| username | VARCHAR(50) | NOT NULL, UNIQUE | 用户名 |
| email | VARCHAR(100) | NOT NULL, UNIQUE | 邮箱地址(学校邮箱) |
-| password | VARCHAR(255) | NOT NULL | 密码(加密存储) |
-| nickname | VARCHAR(50) | NOT NULL | 昵称 |
+| password | VARCHAR(255) | NOT NULL | 密码(加密存储 |
+| | | | |
| avatar | VARCHAR(255) | | 头像URL |
| bio | TEXT | | 个人简介 |
| gender | TINYINT | | 性别(0-未知, 1-男, 2-女) |
@@ -256,3 +256,155 @@ CREATE TABLE `users` (
}
```
+### 3.2用户信息管理模块
+
+#### 3.2.1获取用户个人信息
+
+#### 请求信息
+
+- **URL**: `/users/profile`
+- **方法**: `GET`
+- **描述**: 获取当前登录用户的个人资料信息
+
+#### 响应结果
+
+```json
+Copy{
+ "code": 200,
+ "message": "success",
+ "data": {
+ "id": 12345,
+ "username": "student123",
+ "email": "student@school.edu",
+ "nickname": "测试员",
+ "avatar": "https://example.com/avatars/default.png",
+ "bio": "这是一个个人简介",
+ "gender": 2,
+ "studentId": "20220101001",
+ "department": "计算机学院",
+ "major": "软件工程",
+ "grade": "2023级",
+ "points": 100,
+ "role": 0,
+ "isVerified": 1
+ }
+}
+```
+
+#### 3.2.2 更新用户个人信息
+
+#### 请求信息
+
+- **URL**: `/users/profile`
+- **方法**: `PUT`
+- **描述**: 更新当前登录用户的个人资料
+
+
+
+#### 请求参数
+
+```json
+Copy{
+ "nickname": "新昵称",
+ "bio": "这是更新后的个人简介",
+ "gender": 2,
+ "department": "计算机学院",
+ "major": "软件工程",
+ "grade": "2023级"
+}
+```
+
+#### 响应结果
+
+```json
+Copy{
+ "code": 200,
+ "message": "更新成功",
+ "data": null
+}
+```
+
+#### 3.2.3 修改用户密码
+
+#### 请求信息
+
+- **URL**: `/users/password`
+- **方法**: `PUT`
+- **描述**: 修改当前登录用户的密码
+
+#### 请求参数
+
+```json
+Copy{
+ "oldPassword": "旧密码",
+ "newPassword": "新密码",
+ "confirmPassword": "确认新密码"
+}
+```
+
+#### 响应结果
+
+```json
+Copy{
+ "code": 200,
+ "message": "密码修改成功",
+ "data": null
+}
+```
+
+#### 3.2.4 上传用户头像
+
+#### 请求信息
+
+- **URL**: `/users/avatar`
+- **方法**: `POST`
+- **描述**: 上传或更新用户头像
+
+
+
+#### 请求参数
+
+```
+Copy
+
+file: [图片文件]
+```
+
+#### 响应结果
+
+```json
+Copy{
+ "code": 200,
+ "message": "头像上传成功",
+ "data": {
+ "avatar": "https://example.com/avatars/user_123456.jpg"
+ }
+}
+```
+
+### 2.5 更新用户邮箱
+
+#### 请求信息
+
+- **URL**: `/users/email`
+- **方法**: `PUT`
+- **描述**: 更新用户邮箱地址
+
+#### 请求参数
+
+```json
+Copy{
+ "email": "new_email@school.edu",
+ "code": "123456" // 邮箱验证码
+}
+```
+
+#### 响应结果
+
+```json
+Copy{
+ "code": 200,
+ "message": "邮箱更新成功",
+ "data": null
+}
+```
diff --git a/unilife-server/src/main/java/com/unilife/controller/UserController.java b/unilife-server/src/main/java/com/unilife/controller/UserController.java
index 8e6bd5f..5496c03 100644
--- a/unilife-server/src/main/java/com/unilife/controller/UserController.java
+++ b/unilife-server/src/main/java/com/unilife/controller/UserController.java
@@ -6,7 +6,6 @@ import com.unilife.model.dto.LoginDTO;
import com.unilife.model.dto.LoginEmailDTO;
import com.unilife.model.dto.RegisterDTO;
import com.unilife.model.vo.LoginVO;
-import com.unilife.model.vo.RegisterVO;
import com.unilife.service.UserService;
import com.unilife.utils.BaseContext;
import com.unilife.utils.JwtUtil;
@@ -14,14 +13,12 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
-import java.time.Duration;
@Api(tags = "用户管理")
@@ -34,19 +31,17 @@ public class UserController {
private UserService userService;
@Autowired
private JwtUtil jwtUtil;
- @Autowired
- private StringRedisTemplate stringRedisTemplate;
@ApiOperation(value = "用户注册")
@PostMapping("register")
- public Result register(@RequestBody RegisterDTO registerDTO, HttpServletRequest request) {
+ public Result> register(@RequestBody RegisterDTO registerDTO, HttpServletRequest request) {
return userService.register(registerDTO,request);
}
@ApiOperation(value = "用户登录")
@PostMapping("login")
- public Result login(@RequestBody LoginDTO loginDTO,HttpServletRequest request) {
- Result login = userService.login(loginDTO,request);
+ public Result> login(@RequestBody LoginDTO loginDTO,HttpServletRequest request) {
+ Result> login = userService.login(loginDTO,request);
//登陆成功后生成jwt令牌
LoginVO vo=(LoginVO) login.getData();
if (vo == null) {
@@ -63,7 +58,7 @@ public class UserController {
@ApiOperation(value = "获取邮箱验证码")
@PostMapping("code")
- public Result getCode(@RequestBody EmailDTO emailDto,HttpServletRequest request) {
+ public Result> getCode(@RequestBody EmailDTO emailDto,HttpServletRequest request) {
String email=emailDto.getEmail();
log.debug("收到的原始邮箱: {}", email);
return userService.sendVerificationCode(email,request);
@@ -71,7 +66,7 @@ public class UserController {
@ApiOperation(value = "邮箱验证码登录")
@PostMapping("login/code")
- public Result loginWithEmailCode(@RequestBody LoginEmailDTO loginEmailDTO,HttpServletRequest request) {
+ public Result> loginWithEmailCode(@RequestBody LoginEmailDTO loginEmailDTO,HttpServletRequest request) {
return userService.loginWithEmail(loginEmailDTO,request);
}
From 9e7d6170150aea9b09073cfa3e67b36f69b2f9c5 Mon Sep 17 00:00:00 2001
From: abab2320 <1589841436@qq.com>
Date: Tue, 8 Apr 2025 08:17:24 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E5=BC=80=E5=8F=91=E6=96=87=E6=A1=A3?=
=?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
UniLife开发文档.md | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/UniLife开发文档.md b/UniLife开发文档.md
index 249af4d..eb3c115 100644
--- a/UniLife开发文档.md
+++ b/UniLife开发文档.md
@@ -1,3 +1,5 @@
+[TOC]
+
## 一、API规范
### 1.1 基础信息
@@ -308,9 +310,6 @@ Copy{
"nickname": "新昵称",
"bio": "这是更新后的个人简介",
"gender": 2,
- "department": "计算机学院",
- "major": "软件工程",
- "grade": "2023级"
}
```
@@ -336,9 +335,8 @@ Copy{
```json
Copy{
- "oldPassword": "旧密码",
+ "code": "验证码",
"newPassword": "新密码",
- "confirmPassword": "确认新密码"
}
```