feat(users): add version checking endpoint
Add app version checking functionality to notify users when updates are available. The feature extracts the current version from the x-App-Version header, compares it with the latest configured version, and returns update information including download links and release notes.
This commit is contained in:
@@ -32,13 +32,15 @@ import { DeleteAccountDto, DeleteAccountResponseDto } from './dto/delete-account
|
||||
import { GuestLoginDto, GuestLoginResponseDto, RefreshGuestTokenDto, RefreshGuestTokenResponseDto } from './dto/guest-login.dto';
|
||||
import { AppStoreServerNotificationDto, ProcessNotificationResponseDto } from './dto/app-store-notification.dto';
|
||||
import { RestorePurchaseDto, RestorePurchaseResponseDto } from './dto/restore-purchase.dto';
|
||||
import { VersionCheckDto, VersionCheckResponseDto } from './dto/version-check.dto';
|
||||
import { GetUserActivityHistoryResponseDto } from './dto/user-activity.dto';
|
||||
import { UpdateWeightRecordDto, WeightRecordResponseDto, DeleteWeightRecordResponseDto } from './dto/weight-record.dto';
|
||||
import { UpdateBodyMeasurementDto, UpdateBodyMeasurementResponseDto, GetBodyMeasurementHistoryResponseDto, GetBodyMeasurementAnalysisDto, GetBodyMeasurementAnalysisResponseDto } from './dto/body-measurement.dto';
|
||||
import { UpdateBodyMeasurementDto, UpdateBodyMeasurementResponseDto, GetBodyMeasurementHistoryResponseDto, GetBodyMeasurementAnalysisResponseDto } from './dto/body-measurement.dto';
|
||||
import { GetUserBadgesResponseDto, GetAvailableBadgesResponseDto, MarkBadgeShownDto, MarkBadgeShownResponseDto } from './dto/badge.dto';
|
||||
|
||||
import { Public } from '../common/decorators/public.decorator';
|
||||
import { CurrentUser } from '../common/decorators/current-user.decorator';
|
||||
import { AppVersion } from '../common/decorators/app-version.decorator';
|
||||
import { AccessTokenPayload } from './services/apple-auth.service';
|
||||
import { JwtAuthGuard } from 'src/common/guards/jwt-auth.guard';
|
||||
import { ResponseCode } from 'src/base.dto';
|
||||
@@ -444,4 +446,30 @@ export class UsersController {
|
||||
return this.usersService.markBadgeAsShown(user.sub, markBadgeShownDto.badgeCode);
|
||||
}
|
||||
|
||||
// ==================== 版本检查相关接口 ====================
|
||||
|
||||
/**
|
||||
* 检查应用版本更新
|
||||
*/
|
||||
@Public()
|
||||
@Get('version-check')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({ summary: '检查应用版本更新' })
|
||||
@ApiQuery({ name: 'platform', required: false, description: '设备平台', enum: ['ios', 'android'] })
|
||||
@ApiResponse({ status: 200, description: '成功获取版本信息', type: VersionCheckResponseDto })
|
||||
async checkVersion(
|
||||
@AppVersion() appVersion: string | undefined,
|
||||
@Query('platform') platform?: string,
|
||||
): Promise<VersionCheckResponseDto> {
|
||||
this.logger.log(`版本检查请求 - 当前版本: ${appVersion}, 平台: ${platform}`);
|
||||
|
||||
// 构造查询对象,保持与原有服务的兼容性
|
||||
const query: VersionCheckDto = {
|
||||
currentVersion: appVersion,
|
||||
platform: platform,
|
||||
};
|
||||
|
||||
return this.usersService.checkVersion(query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user