From e3cd496f33bb8b3b473980c340cd3c03dbf0958d Mon Sep 17 00:00:00 2001 From: richarjiang Date: Wed, 27 Aug 2025 19:05:30 +0800 Subject: [PATCH] =?UTF-8?q?feat(users):=20=E6=9B=B4=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0EFICHOPER(builderI?= =?UTF-8?q?d,u-formatIdFast=E7=94=9F=E6=88=90=E6=8F=90)=E5=BD=95=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/users/dto/update-user.dto.ts | 5 ----- src/users/users.controller.ts | 4 ++-- src/users/users.service.ts | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/users/dto/update-user.dto.ts b/src/users/dto/update-user.dto.ts index 42a1fb5..8243a52 100644 --- a/src/users/dto/update-user.dto.ts +++ b/src/users/dto/update-user.dto.ts @@ -4,11 +4,6 @@ import { ResponseCode } from 'src/base.dto'; import { Gender, User } from '../models/user.model'; export class UpdateUserDto { - @IsString({ message: '用户ID必须是字符串' }) - @IsNotEmpty({ message: '用户ID不能为空' }) - @ApiProperty({ description: '用户ID', example: '123' }) - userId: string; - @IsString({ message: '用户名必须是字符串' }) @MinLength(1, { message: '用户名长度不能少于1个字符' }) @IsOptional() diff --git a/src/users/users.controller.ts b/src/users/users.controller.ts index 7cc9b02..3007b95 100644 --- a/src/users/users.controller.ts +++ b/src/users/users.controller.ts @@ -76,8 +76,8 @@ export class UsersController { // 更新用户昵称、头像 @UseGuards(JwtAuthGuard) @Put('update') - async updateUser(@Body() updateUserDto: UpdateUserDto): Promise { - return this.usersService.updateUser(updateUserDto); + async updateUser(@Body() updateUserDto: UpdateUserDto, @CurrentUser() user: AccessTokenPayload): Promise { + return this.usersService.updateUser(updateUserDto, user.sub); } // Apple 登录 diff --git a/src/users/users.service.ts b/src/users/users.service.ts index afabb8b..9b5d94b 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -180,8 +180,8 @@ export class UsersService { // 更新用户昵称、头像 - async updateUser(updateUserDto: UpdateUserDto): Promise { - const { userId, name, avatar, gender, birthDate, dailyStepsGoal, dailyCaloriesGoal, pilatesPurposes, weight, initialWeight, targetWeight, height, activityLevel } = updateUserDto; + async updateUser(updateUserDto: UpdateUserDto, userId: string): Promise { + const { name, avatar, gender, birthDate, dailyStepsGoal, dailyCaloriesGoal, pilatesPurposes, weight, initialWeight, targetWeight, height, activityLevel } = updateUserDto; this.logger.log(`updateUser: ${JSON.stringify(updateUserDto, null, 2)}`);