|
@@ -144,39 +144,39 @@ export class AdController {
|
|
|
* Record ad click event for analytics.
|
|
* Record ad click event for analytics.
|
|
|
* Protected endpoint that requires JWT authentication.
|
|
* Protected endpoint that requires JWT authentication.
|
|
|
*/
|
|
*/
|
|
|
- // @Post('click')
|
|
|
|
|
- // @UseGuards(JwtAuthGuard)
|
|
|
|
|
- // @ApiBearerAuth()
|
|
|
|
|
- // @ApiOperation({
|
|
|
|
|
- // summary: '广告点击事件上报',
|
|
|
|
|
- // description:
|
|
|
|
|
- // '记录广告点击事件(uid/IP/UA 由服务端填充,不接受客户端时间戳)。',
|
|
|
|
|
- // })
|
|
|
|
|
- // @ApiResponse({
|
|
|
|
|
- // status: 200,
|
|
|
|
|
- // description: '成功',
|
|
|
|
|
- // schema: { example: { status: 1, code: 'OK' } },
|
|
|
|
|
- // })
|
|
|
|
|
- // @ApiResponse({ status: 401, description: '未授权 - 需要JWT token' })
|
|
|
|
|
- // async recordAdClick(
|
|
|
|
|
- // @Body() body: AdClickDto,
|
|
|
|
|
- // @Req() req: RequestWithUser,
|
|
|
|
|
- // ): Promise<{ status: number; code: string }> {
|
|
|
|
|
- // const uid = req.user?.uid;
|
|
|
|
|
-
|
|
|
|
|
- // if (!uid) {
|
|
|
|
|
- // this.logger.error('JWT payload missing uid');
|
|
|
|
|
- // throw new UnauthorizedException('Missing uid in JWT payload');
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // const ip = this.getClientIp(req);
|
|
|
|
|
- // const userAgent = this.getUserAgent(req);
|
|
|
|
|
-
|
|
|
|
|
- // // Fire-and-forget: don't await for immediate response
|
|
|
|
|
- // this.adService.recordAdClick(uid, body, ip, userAgent);
|
|
|
|
|
-
|
|
|
|
|
- // return { status: 1, code: 'OK' };
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ @Post('click')
|
|
|
|
|
+ @UseGuards(JwtAuthGuard)
|
|
|
|
|
+ @ApiBearerAuth()
|
|
|
|
|
+ @ApiOperation({
|
|
|
|
|
+ summary: '广告点击事件上报',
|
|
|
|
|
+ description:
|
|
|
|
|
+ '记录广告点击事件(uid/IP/UA 由服务端填充,不接受客户端时间戳)。',
|
|
|
|
|
+ })
|
|
|
|
|
+ @ApiResponse({
|
|
|
|
|
+ status: 200,
|
|
|
|
|
+ description: '成功',
|
|
|
|
|
+ schema: { example: { status: 1, code: 'OK' } },
|
|
|
|
|
+ })
|
|
|
|
|
+ @ApiResponse({ status: 401, description: '未授权 - 需要JWT token' })
|
|
|
|
|
+ async recordAdClick(
|
|
|
|
|
+ @Body() body: AdClickDto,
|
|
|
|
|
+ @Req() req: RequestWithUser,
|
|
|
|
|
+ ): Promise<{ status: number; code: string }> {
|
|
|
|
|
+ const uid = req.user?.uid;
|
|
|
|
|
+
|
|
|
|
|
+ if (!uid) {
|
|
|
|
|
+ this.logger.error('JWT payload missing uid');
|
|
|
|
|
+ throw new UnauthorizedException('Missing uid in JWT payload');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const ip = this.getClientIp(req);
|
|
|
|
|
+ const userAgent = this.getUserAgent(req);
|
|
|
|
|
+
|
|
|
|
|
+ // Fire-and-forget: don't await for immediate response
|
|
|
|
|
+ this.adService.recordAdClick(uid, body, ip, userAgent);
|
|
|
|
|
+
|
|
|
|
|
+ return { status: 1, code: 'OK' };
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* POST /ads/impression
|
|
* POST /ads/impression
|