feat: 鏍囬鏍忕増鏈彿 + 搴旂敤甯傚満涓婃灦鏃ュ巻搴旂敤涓庡垎缁勬姌鍙?+ 鏃ョ▼鍐滃巻/琛ㄥ崟妯増浼樺寲 + 涓汉璧勬枡寮圭獥

This commit is contained in:
2026-08-23 08:55:08 +08:00
parent 62776aa33b
commit 66f107058e
22 changed files with 545 additions and 29 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
import { Body, Controller, Get, Post, Req, UseGuards } from '@nestjs/common';
import { Body, Controller, Get, Patch, Post, Req, UseGuards } from '@nestjs/common';
import { AuthService } from './auth.service';
import { JwtAuthGuard } from './jwt-auth.guard';
import { CurrentUser } from './current-user.decorator';
@@ -24,6 +24,15 @@ export class AuthController {
return user;
}
@UseGuards(JwtAuthGuard)
@Patch('me')
updateMe(
@CurrentUser() user: PublicUser,
@Body() dto: { signature?: string; status?: string },
) {
return this.auth.updateProfile(user.id, dto);
}
@UseGuards(JwtAuthGuard)
@Post('logout')
logout(@Req() _req: any) {
+14
View File
@@ -17,6 +17,10 @@ export interface User {
email?: string;
department?: string;
title?: string;
/** 个人签名 */
signature?: string;
/** 自定义状态:上班/外出/出差/请假/学习/休假 等 */
status?: string;
createdAt: number;
}
@@ -86,6 +90,16 @@ export class AuthService {
}
}
/** 更新个人资料(签名、自定义状态等) */
async updateProfile(
userId: string,
patch: { signature?: string; status?: string },
) {
const user = await this.users().updateById(userId, patch);
if (!user) throw new BadRequestException('用户不存在');
return this.toPublic(user);
}
toPublic(user: User): PublicUser {
const { passwordHash, ...rest } = user;
return rest;