feat: 优化AI教练聊天逻辑,增加用户聊天次数检查和响应内容
- 在AI教练控制器中添加用户聊天次数检查,若次数用完则返回相应提示信息。 - 更新AI聊天响应DTO,新增用户剩余聊天次数和AI回复文本字段,提升用户体验。 - 修改用户服务,支持初始体重和目标体重字段的更新,增强用户资料的完整性。
This commit is contained in:
@@ -108,6 +108,8 @@ export class UsersService {
|
||||
dailyCaloriesGoal: profile?.dailyCaloriesGoal,
|
||||
pilatesPurposes: profile?.pilatesPurposes,
|
||||
weight: profile?.weight,
|
||||
initialWeight: profile?.initialWeight,
|
||||
targetWeight: profile?.targetWeight,
|
||||
height: profile?.height,
|
||||
activityLevel: profile?.activityLevel,
|
||||
}
|
||||
@@ -179,7 +181,7 @@ export class UsersService {
|
||||
|
||||
// 更新用户昵称、头像
|
||||
async updateUser(updateUserDto: UpdateUserDto): Promise<UpdateUserResponseDto> {
|
||||
const { userId, name, avatar, gender, birthDate, dailyStepsGoal, dailyCaloriesGoal, pilatesPurposes, weight, height, activityLevel } = updateUserDto;
|
||||
const { userId, name, avatar, gender, birthDate, dailyStepsGoal, dailyCaloriesGoal, pilatesPurposes, weight, initialWeight, targetWeight, height, activityLevel } = updateUserDto;
|
||||
|
||||
this.logger.log(`updateUser: ${JSON.stringify(updateUserDto, null, 2)}`);
|
||||
|
||||
@@ -215,7 +217,7 @@ export class UsersService {
|
||||
await user.save();
|
||||
|
||||
// 更新或创建扩展信息
|
||||
if (dailyStepsGoal !== undefined || dailyCaloriesGoal !== undefined || pilatesPurposes !== undefined || weight !== undefined || height !== undefined || activityLevel !== undefined) {
|
||||
if (dailyStepsGoal !== undefined || dailyCaloriesGoal !== undefined || pilatesPurposes !== undefined || weight !== undefined || initialWeight !== undefined || targetWeight !== undefined || height !== undefined || activityLevel !== undefined) {
|
||||
const [profile] = await this.userProfileModel.findOrCreate({
|
||||
where: { userId },
|
||||
defaults: { userId },
|
||||
@@ -232,6 +234,14 @@ export class UsersService {
|
||||
}
|
||||
profileChanges.weight = weight;
|
||||
}
|
||||
if (initialWeight !== undefined) {
|
||||
profile.initialWeight = initialWeight;
|
||||
profileChanges.initialWeight = initialWeight;
|
||||
}
|
||||
if (targetWeight !== undefined) {
|
||||
profile.targetWeight = targetWeight;
|
||||
profileChanges.targetWeight = targetWeight;
|
||||
}
|
||||
if (height !== undefined) {
|
||||
profile.height = height;
|
||||
profileChanges.height = height;
|
||||
@@ -650,6 +660,8 @@ export class UsersService {
|
||||
dailyCaloriesGoal: profileForLogin.dailyCaloriesGoal,
|
||||
pilatesPurposes: profileForLogin.pilatesPurposes,
|
||||
weight: profileForLogin.weight,
|
||||
initialWeight: profileForLogin.initialWeight,
|
||||
targetWeight: profileForLogin.targetWeight,
|
||||
height: profileForLogin.height,
|
||||
activityLevel: profileForLogin.activityLevel,
|
||||
} : undefined,
|
||||
@@ -862,6 +874,8 @@ export class UsersService {
|
||||
dailyCaloriesGoal: profileForGuest.dailyCaloriesGoal,
|
||||
pilatesPurposes: profileForGuest.pilatesPurposes,
|
||||
weight: profileForGuest.weight,
|
||||
initialWeight: profileForGuest.initialWeight,
|
||||
targetWeight: profileForGuest.targetWeight,
|
||||
height: profileForGuest.height,
|
||||
activityLevel: profileForGuest.activityLevel,
|
||||
} : undefined,
|
||||
|
||||
Reference in New Issue
Block a user