Files
plates-server/src/users/dto/update-user.dto.ts
richarjiang 79aa300aa1 feat: 在用户资料中添加活动水平字段
- 更新用户资料相关逻辑,新增活动水平字段,支持用户在更新资料时提供活动水平信息。
- 修改相关DTO和模型,确保活动水平字段的有效性和数据一致性。
- 更新用户响应数据结构,包含活动水平信息,提升用户体验和数据完整性。
2025-08-27 10:00:18 +08:00

76 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsEmail, IsOptional, MinLength, IsNotEmpty, IsEnum } from 'class-validator';
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()
@ApiProperty({ description: '用户名', example: '张三' })
name: string;
@IsString({ message: '头像必须是字符串' })
@IsOptional()
@ApiProperty({ description: '头像', example: 'base64' })
avatar: string;
@IsEnum(Gender, { message: '性别必须是枚举值' })
@IsOptional()
@ApiProperty({ description: '性别', example: 'male' })
gender: Gender;
// 时间戳
@IsOptional()
@ApiProperty({ description: '出生年月日', example: 1713859200 })
birthDate: number;
// 扩展字段
@IsOptional()
@ApiProperty({ description: '每日步数目标', example: 8000 })
dailyStepsGoal?: number;
@IsOptional()
@ApiProperty({ description: '每日卡路里消耗目标', example: 500 })
dailyCaloriesGoal?: number;
@IsOptional()
@ApiProperty({ description: '普拉提目的(多选)', example: ['塑形', '康复'] })
pilatesPurposes?: string[];
@IsOptional()
@ApiProperty({ description: '体重(公斤)', example: 55.5 })
weight?: number;
@IsOptional()
@ApiProperty({ description: '身高(厘米)', example: 168 })
height?: number;
@IsOptional()
@ApiProperty({ description: '活动水平1-5的枚举值', example: 3, minimum: 1, maximum: 5 })
activityLevel?: number;
}
export class UpdateUserResponseDto {
@ApiProperty({ description: '状态码', example: ResponseCode.SUCCESS })
code: ResponseCode;
@ApiProperty({ description: '消息', example: 'success' })
message: string;
@ApiProperty({
description: '用户', example: {
id: '123',
name: '张三',
avatar: 'base64',
}
})
data: User | null;
}