38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
|
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
import { UserRecord } from '../users/interfaces/user-record.interface';
|
|
import { UpsertPlaybackHistoryDto } from './dto/upsert-history.dto';
|
|
import { HistoryService } from './history.service';
|
|
|
|
@ApiTags('History')
|
|
@Controller('/api/app/v1/history')
|
|
export class HistoryController {
|
|
constructor(private readonly historyService: HistoryService) {}
|
|
|
|
@Post()
|
|
@ApiBearerAuth()
|
|
@UseGuards(JwtAuthGuard)
|
|
upsertHistory(
|
|
@CurrentUser() user: UserRecord,
|
|
@Body() dto: UpsertPlaybackHistoryDto,
|
|
) {
|
|
return this.historyService.upsertHistory(user, dto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiBearerAuth()
|
|
@UseGuards(JwtAuthGuard)
|
|
listHistory(
|
|
@CurrentUser() user: UserRecord,
|
|
@Query('page') page?: string,
|
|
@Query('pageSize') pageSize?: string,
|
|
) {
|
|
return this.historyService.listHistory(user, {
|
|
page: Number(page) || 1,
|
|
pageSize: Number(pageSize) || 20,
|
|
});
|
|
}
|
|
}
|