feat(users): 添加App版本号追踪功能,支持用户版本更新记录
This commit is contained in:
@@ -87,10 +87,10 @@ export class UsersService {
|
||||
private readonly configService: ConfigService,
|
||||
) { }
|
||||
|
||||
async getProfile(user: AccessTokenPayload): Promise<UserResponseDto> {
|
||||
async getProfile(user: AccessTokenPayload, appVersion?: string): Promise<UserResponseDto> {
|
||||
try {
|
||||
// 使用NestJS Logger (会通过winston输出)
|
||||
this.logger.log(`getProfile: ${JSON.stringify(user)}`);
|
||||
this.logger.log(`getProfile: ${JSON.stringify(user)}, appVersion: ${appVersion}`);
|
||||
|
||||
// 也可以直接使用winston logger
|
||||
this.winstonLogger.info('getProfile method called', {
|
||||
@@ -111,8 +111,13 @@ export class UsersService {
|
||||
};
|
||||
}
|
||||
|
||||
// 更新用户最后登录时间
|
||||
// 更新用户最后登录时间和版本信息
|
||||
existingUser.lastLogin = new Date();
|
||||
if (appVersion && existingUser.appVersion !== appVersion) {
|
||||
const oldVersion = existingUser.appVersion;
|
||||
existingUser.appVersion = appVersion;
|
||||
this.logger.log(`用户 ${existingUser.id} 版本更新: ${oldVersion || '无'} -> ${appVersion}`);
|
||||
}
|
||||
await existingUser.save();
|
||||
|
||||
const [profile] = await this.userProfileModel.findOrCreate({
|
||||
@@ -136,6 +141,7 @@ export class UsersService {
|
||||
maxUsageCount: DEFAULT_FREE_USAGE_COUNT,
|
||||
isVip: existingUser.isVip,
|
||||
gender: existingUser.gender,
|
||||
appVersion: existingUser.appVersion,
|
||||
dailyStepsGoal: profile?.dailyStepsGoal,
|
||||
dailyCaloriesGoal: profile?.dailyCaloriesGoal,
|
||||
pilatesPurposes: profile?.pilatesPurposes,
|
||||
|
||||
Reference in New Issue
Block a user