feat(users): 补齐 PATCH /api/users/me(契约 §2 遗漏)
service 的 updateProfile 已存在但 controller 未注册路由, Profile 页保存资料 404。新增 UpdateProfileDto(nickname/avatar 可选, 白名单校验),与契约 §2 对齐。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Patch, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { CurrentUser, JwtPayload } from '../common/decorators/current-user.decorator';
|
||||
import { UsersService } from './users.service';
|
||||
import { UpdateProfileDto } from './dto/update-profile.dto';
|
||||
|
||||
@ApiTags('用户')
|
||||
@ApiBearerAuth()
|
||||
@@ -15,4 +16,11 @@ export class UsersController {
|
||||
async getMe(@CurrentUser() user: JwtPayload) {
|
||||
return this.usersService.findById(user.sub);
|
||||
}
|
||||
|
||||
@Patch('me')
|
||||
@ApiOperation({ summary: '更新当前用户资料(昵称/头像)' })
|
||||
@ApiOkResponse({ description: '更新后的用户' })
|
||||
async updateMe(@CurrentUser() user: JwtPayload, @Body() dto: UpdateProfileDto) {
|
||||
return this.usersService.updateProfile(user.sub, dto);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user