diff --git a/Front/vue-unilife/package.json b/Front/vue-unilife/package.json index 6b23c2e..b53d3a7 100644 --- a/Front/vue-unilife/package.json +++ b/Front/vue-unilife/package.json @@ -9,6 +9,7 @@ "preview": "vite preview" }, "dependencies": { + "@element-plus/icons-vue": "^2.3.1", "@vue/shared": "^3.5.13", "axios": "^1.8.3", "element-plus": "^2.9.7", diff --git a/Front/vue-unilife/pnpm-lock.yaml b/Front/vue-unilife/pnpm-lock.yaml index 5115197..62c0e43 100644 --- a/Front/vue-unilife/pnpm-lock.yaml +++ b/Front/vue-unilife/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@element-plus/icons-vue': + specifier: ^2.3.1 + version: 2.3.1(vue@3.5.13(typescript@5.7.3)) '@vue/shared': specifier: ^3.5.13 version: 3.5.13 diff --git a/Front/vue-unilife/src/components/LogPage.vue b/Front/vue-unilife/src/components/LogPage.vue index 16f4cac..21adf4f 100644 --- a/Front/vue-unilife/src/components/LogPage.vue +++ b/Front/vue-unilife/src/components/LogPage.vue @@ -137,7 +137,7 @@ const onLoginSubmit = () => { if(login_password_email.value == testEmail.value && login_password.value == testPassword.value) { console.log('测试登录成功') console.log(router) - router.push({name:'Personal'}) + router.push({name:'Home'}) } else { login().then((res) => { if(res.code === 200) { @@ -314,7 +314,7 @@ async function login(){ padding: 0; } - body{ + :global(body){ height: 100vh;; /*弹性布局,水平垂直居中*/ display:flex; diff --git a/Front/vue-unilife/src/components/Personal/AcountManager.vue b/Front/vue-unilife/src/components/Personal/AcountManager.vue index 6da00db..3066b14 100644 --- a/Front/vue-unilife/src/components/Personal/AcountManager.vue +++ b/Front/vue-unilife/src/components/Personal/AcountManager.vue @@ -1,17 +1,527 @@ - 测试样例 - - 测试样例2 - + + + + + + + 个人信息 + + + 昵称 + + + + + 个人简介 + + + + + 性别 + + + + 女 + + + + 男 + + + + + + 生日 + + + + + + + + + 账号信息 + + + 绑定邮箱 + + + + + 修改密码 + + + + + 确认修改 + + * 密码至少包含6个字符,建议使用字母、数字和符号的组合 + + + + + + + 保 存 + + + + + + + + + + + {{ username }} + + {{ email }} + + + 这是一个个人简介 + + + + + ✨ + ✨ + 💜 + 🐱 + 🍰 + + + - - \ No newline at end of file + \ No newline at end of file diff --git a/Front/vue-unilife/src/components/Personal/Personal.vue b/Front/vue-unilife/src/components/Personal/Personal.vue index fc8a4ba..2769359 100644 --- a/Front/vue-unilife/src/components/Personal/Personal.vue +++ b/Front/vue-unilife/src/components/Personal/Personal.vue @@ -99,17 +99,17 @@ export default defineComponent({ justify-content:center; align-items:center; font:900 100px ''; - color:rgba(110,90,240,0.3); + color:rgba(175, 90, 240, 0.308); background-color: #e4e9f5; } .shell{ - position:absolute; + position:fixed; top:0%; left:0%; width:84px; height:100%; - background-color:#fff; + background-color:#ead1fb; z-index:9999; transition:width 0.5s; padding-left:10px; @@ -145,7 +145,7 @@ export default defineComponent({ } .active{ - background-color: #e4e9f5; + background-color: #fff; border-top-left-radius: 50px; border-bottom-left-radius: 50px; } @@ -158,7 +158,7 @@ export default defineComponent({ width:30px; height:30px; border-bottom-right-radius:25px; - box-shadow:5px 5px 0 5px #e4e9f5; + box-shadow:5px 5px 0 5px #fff; background:transparent; } @@ -170,7 +170,7 @@ export default defineComponent({ width:30px; height:30px; border-top-right-radius: 25px; - box-shadow:5px -5px 0 5px #e4e9f5; + box-shadow:5px -5px 0 5px #fff; background:transparent; } @@ -194,7 +194,7 @@ export default defineComponent({ height:70px; color:#333; transition:0.5s; - color: rgb(110,90,240) + color: rgb(153, 109, 240) } .icon i{ @@ -218,7 +218,7 @@ export default defineComponent({ .shell ul li:hover a .icon, .shell ul li:hover a .text { - color: #ffa117;/*字体和图标被选中后的颜色 */ + color: #f3e7e9;/*字体和图标被选中后的颜色 */ } .active a .icon::before{ diff --git a/Front/前端环境.md b/Front/前端环境.md index e2facf6..4e311b5 100644 --- a/Front/前端环境.md +++ b/Front/前端环境.md @@ -52,4 +52,11 @@ pnpm add element-plus pnpm i vue-router pnpm add vue-router@4 ``` -用来完成界面跳转,同时完成vuerouter与ts的适配 \ No newline at end of file +用来完成界面跳转,同时完成vuerouter与ts的适配 + + + +### 安装elementplus的icon库 +``` +pnpm install @element-plus/icons-vue +``` \ No newline at end of file diff --git a/UniLife开发文档.md b/UniLife开发文档.md index fbfdd20..eb3c115 100644 --- a/UniLife开发文档.md +++ b/UniLife开发文档.md @@ -1,3 +1,5 @@ +[TOC] + ## 一、API规范 ### 1.1 基础信息 @@ -66,8 +68,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 +258,151 @@ 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, +} +``` + +#### 响应结果 + +```json +Copy{ + "code": 200, + "message": "更新成功", + "data": null +} +``` + +#### 3.2.3 修改用户密码 + +#### 请求信息 + +- **URL**: `/users/password` +- **方法**: `PUT` +- **描述**: 修改当前登录用户的密码 + +#### 请求参数 + +```json +Copy{ + "code": "验证码", + "newPassword": "新密码", +} +``` + +#### 响应结果 + +```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); }
- 测试样例2 -
* 密码至少包含6个字符,建议使用字母、数字和符号的组合
{{ email }}