feat: 新增体重记录接口及枚举,优化AI教练选择项处理

This commit is contained in:
richarjiang
2025-08-28 09:46:03 +08:00
parent e3cd496f33
commit 17ee96638e
6 changed files with 277 additions and 13 deletions

View File

@@ -30,6 +30,7 @@ import { GuestLoginDto, GuestLoginResponseDto, RefreshGuestTokenDto, RefreshGues
import { AppStoreServerNotificationDto, ProcessNotificationResponseDto } from './dto/app-store-notification.dto';
import { RestorePurchaseDto, RestorePurchaseResponseDto } from './dto/restore-purchase.dto';
import { GetUserActivityHistoryResponseDto } from './dto/user-activity.dto';
import { UpdateWeightRecordDto, WeightRecordResponseDto, DeleteWeightRecordResponseDto } from './dto/weight-record.dto';
import { Public } from '../common/decorators/public.decorator';
import { CurrentUser } from '../common/decorators/current-user.decorator';
import { AccessTokenPayload } from './services/apple-auth.service';
@@ -72,6 +73,40 @@ export class UsersController {
return { code: ResponseCode.SUCCESS, message: 'success', data };
}
// 更新体重记录
@UseGuards(JwtAuthGuard)
@Put('/weight-records/:id')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: '更新体重记录' })
@ApiBody({ type: UpdateWeightRecordDto })
@ApiResponse({ status: 200, description: '成功更新体重记录', type: WeightRecordResponseDto })
async updateWeightRecord(
@Param('id') recordId: string,
@Body() updateDto: UpdateWeightRecordDto,
@CurrentUser() user: AccessTokenPayload,
): Promise<WeightRecordResponseDto> {
this.logger.log(`更新体重记录 - 用户ID: ${user.sub}, 记录ID: ${recordId}`);
return this.usersService.updateWeightRecord(user.sub, parseInt(recordId), updateDto);
}
// 删除体重记录
@UseGuards(JwtAuthGuard)
@Delete('/weight-records/:id')
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: '删除体重记录' })
@ApiResponse({ status: 200, description: '成功删除体重记录', type: DeleteWeightRecordResponseDto })
async deleteWeightRecord(
@Param('id') recordId: string,
@CurrentUser() user: AccessTokenPayload,
): Promise<DeleteWeightRecordResponseDto> {
this.logger.log(`删除体重记录 - 用户ID: ${user.sub}, 记录ID: ${recordId}`);
const success = await this.usersService.deleteWeightRecord(user.sub, parseInt(recordId));
if (!success) {
throw new NotFoundException('体重记录不存在');
}
return { code: ResponseCode.SUCCESS, message: 'success' };
}
// 更新用户昵称、头像
@UseGuards(JwtAuthGuard)