From 4e1be2b4946b050aa03608219dd5eab868881a60 Mon Sep 17 00:00:00 2001 From: charilezhou Date: Mon, 19 Jan 2026 12:36:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=9B=B4=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=A8=A1=E5=9D=97=E6=94=AF=E6=8C=81=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 AuthDto 调整验证规则 - 更新 UserDto 添加头像相关字段 - 更新 UserController 支持更新用户头像 Co-Authored-By: Claude Opus 4.5 --- apps/api/src/auth/dto/auth.dto.ts | 7 +++++++ apps/api/src/user/dto/user.dto.ts | 14 ++++++++++++++ apps/api/src/user/user.controller.ts | 18 ++++++++++++++++-- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/apps/api/src/auth/dto/auth.dto.ts b/apps/api/src/auth/dto/auth.dto.ts index aa627fb..fd00b8e 100644 --- a/apps/api/src/auth/dto/auth.dto.ts +++ b/apps/api/src/auth/dto/auth.dto.ts @@ -65,6 +65,13 @@ export class AuthUserDto implements AuthUser { @ApiProperty({ example: '张三', description: '用户名称', nullable: true }) name: string | null; + + @ApiProperty({ + example: 'clxxx456', + description: '用户头像文件 ID', + nullable: true, + }) + avatarId: string | null; } /** 认证响应 DTO */ diff --git a/apps/api/src/user/dto/user.dto.ts b/apps/api/src/user/dto/user.dto.ts index 1d566dd..cfc5799 100644 --- a/apps/api/src/user/dto/user.dto.ts +++ b/apps/api/src/user/dto/user.dto.ts @@ -52,6 +52,13 @@ export class UserResponseDto implements UserResponse { @ApiProperty({ example: '张三', description: '用户名称', nullable: true }) name: string | null; + @ApiProperty({ + example: 'clxxx456', + description: '用户头像文件 ID', + nullable: true, + }) + avatarId: string | null; + @ApiProperty({ example: '2026-01-16T10:00:00.000Z', description: '创建时间' }) createdAt: string; @@ -73,6 +80,13 @@ export class UserWithRolesResponseDto implements UserWithRolesResponse { @ApiProperty({ example: '张三', description: '用户名称', nullable: true }) name: string | null; + @ApiProperty({ + example: 'clxxx456', + description: '用户头像文件 ID', + nullable: true, + }) + avatarId: string | null; + @ApiProperty({ example: false, description: '是否为超级管理员' }) isSuperAdmin: boolean; diff --git a/apps/api/src/user/user.controller.ts b/apps/api/src/user/user.controller.ts index 4fa15cc..50d7d0a 100644 --- a/apps/api/src/user/user.controller.ts +++ b/apps/api/src/user/user.controller.ts @@ -1,5 +1,19 @@ -import { Controller, Get, Patch, Delete, Param, Body, Query, UseGuards } from '@nestjs/common'; -import { ApiTags, ApiOperation, ApiBearerAuth, ApiOkResponse } from '@nestjs/swagger'; +import { + Controller, + Get, + Patch, + Delete, + Param, + Body, + Query, + UseGuards, +} from '@nestjs/common'; +import { + ApiTags, + ApiOperation, + ApiBearerAuth, + ApiOkResponse, +} from '@nestjs/swagger'; import { AssignRolesDto,