|
|
@@ -89,54 +89,54 @@ export class AdController {
|
|
|
*
|
|
|
* Example: GET /ads/507f1f77bcf86cd799439011/url
|
|
|
*/
|
|
|
- @Get(':id/url')
|
|
|
- @UseGuards(JwtAuthGuard)
|
|
|
- @ApiBearerAuth()
|
|
|
- @ApiOperation({
|
|
|
- summary: '获取广告URL',
|
|
|
- description:
|
|
|
- '通过广告ID获取广告链接。需要JWT认证。返回广告URL并记录点击事件。',
|
|
|
- })
|
|
|
- @ApiResponse({
|
|
|
- status: 200,
|
|
|
- description: '成功返回广告URL',
|
|
|
- type: AdUrlResponseDto,
|
|
|
- })
|
|
|
- @ApiResponse({ status: 401, description: '未授权 - 需要JWT token' })
|
|
|
- @ApiResponse({ status: 404, description: '广告不存在或已过期' })
|
|
|
- async getAdUrl(
|
|
|
- @Param('id') adsId: string,
|
|
|
- @Req() req: RequestWithUser,
|
|
|
- ): Promise<AdUrlResponseDto> {
|
|
|
- const uid = req.user?.uid;
|
|
|
-
|
|
|
- if (!uid) {
|
|
|
- this.logger.error('JWT payload missing uid');
|
|
|
- throw new NotFoundException('User not authenticated');
|
|
|
- }
|
|
|
-
|
|
|
- // Extract client IP
|
|
|
- const ip =
|
|
|
- (req.headers['x-forwarded-for'] as string)?.split(',')[0]?.trim() ||
|
|
|
- (req.headers['x-real-ip'] as string) ||
|
|
|
- req.ip ||
|
|
|
- 'unknown';
|
|
|
-
|
|
|
- // Extract optional headers
|
|
|
- const userAgent = req.headers['user-agent'];
|
|
|
- const appVersion = req.headers['app-version'] as string | undefined;
|
|
|
- const os = req.headers['os'] as string | undefined;
|
|
|
-
|
|
|
- // Delegate to service for business logic
|
|
|
- return this.adService.getAdUrlAndPublishClick(
|
|
|
- adsId,
|
|
|
- uid,
|
|
|
- ip,
|
|
|
- userAgent,
|
|
|
- appVersion,
|
|
|
- os,
|
|
|
- );
|
|
|
- }
|
|
|
+ // @Get(':id/url')
|
|
|
+ // @UseGuards(JwtAuthGuard)
|
|
|
+ // @ApiBearerAuth()
|
|
|
+ // @ApiOperation({
|
|
|
+ // summary: '获取广告URL',
|
|
|
+ // description:
|
|
|
+ // '通过广告ID获取广告链接。需要JWT认证。返回广告URL并记录点击事件。',
|
|
|
+ // })
|
|
|
+ // @ApiResponse({
|
|
|
+ // status: 200,
|
|
|
+ // description: '成功返回广告URL',
|
|
|
+ // type: AdUrlResponseDto,
|
|
|
+ // })
|
|
|
+ // @ApiResponse({ status: 401, description: '未授权 - 需要JWT token' })
|
|
|
+ // @ApiResponse({ status: 404, description: '广告不存在或已过期' })
|
|
|
+ // async getAdUrl(
|
|
|
+ // @Param('id') adsId: string,
|
|
|
+ // @Req() req: RequestWithUser,
|
|
|
+ // ): Promise<AdUrlResponseDto> {
|
|
|
+ // const uid = req.user?.uid;
|
|
|
+
|
|
|
+ // if (!uid) {
|
|
|
+ // this.logger.error('JWT payload missing uid');
|
|
|
+ // throw new NotFoundException('User not authenticated');
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // Extract client IP
|
|
|
+ // const ip =
|
|
|
+ // (req.headers['x-forwarded-for'] as string)?.split(',')[0]?.trim() ||
|
|
|
+ // (req.headers['x-real-ip'] as string) ||
|
|
|
+ // req.ip ||
|
|
|
+ // 'unknown';
|
|
|
+
|
|
|
+ // // Extract optional headers
|
|
|
+ // const userAgent = req.headers['user-agent'];
|
|
|
+ // const appVersion = req.headers['app-version'] as string | undefined;
|
|
|
+ // const os = req.headers['os'] as string | undefined;
|
|
|
+
|
|
|
+ // // Delegate to service for business logic
|
|
|
+ // return this.adService.getAdUrlAndPublishClick(
|
|
|
+ // adsId,
|
|
|
+ // uid,
|
|
|
+ // ip,
|
|
|
+ // userAgent,
|
|
|
+ // appVersion,
|
|
|
+ // os,
|
|
|
+ // );
|
|
|
+ // }
|
|
|
|
|
|
/**
|
|
|
* POST /ads/click
|