Add create date on history items

This commit is contained in:
2023-05-23 16:00:59 +09:00
parent 7adfb6e294
commit 712c08303a
5 changed files with 63 additions and 37 deletions
+15 -4
View File
@@ -1,4 +1,15 @@
import { Body, Controller, DefaultValuePipe, Get, HttpCode, ParseIntPipe, Post, Query, Request, UseGuards } from '@nestjs/common';
import {
Body,
Controller,
DefaultValuePipe,
Get,
HttpCode,
ParseIntPipe,
Post,
Query,
Request,
UseGuards,
} from '@nestjs/common';
import { ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger';
import { SearchHistory, SongHistory } from '@prisma/client';
import { JwtAuthGuard } from 'src/auth/jwt-auth.guard';
@@ -6,9 +17,9 @@ import { SongHistoryDto } from './dto/SongHistoryDto';
import { HistoryService } from './history.service';
@Controller('history')
@ApiTags("history")
@ApiTags('history')
export class HistoryController {
constructor(private readonly historyService: HistoryService) {}
constructor(private readonly historyService: HistoryService) { }
@Get()
@HttpCode(200)
@@ -22,7 +33,7 @@ export class HistoryController {
return this.historyService.getHistory(req.user.id, { skip, take });
}
@Get("search")
@Get('search')
@HttpCode(200)
@UseGuards(JwtAuthGuard)
@ApiUnauthorizedResponse({ description: 'Invalid token' })
+3 -1
View File
@@ -6,7 +6,7 @@ import { SongHistoryDto } from './dto/SongHistoryDto';
@Injectable()
export class HistoryService {
constructor(private prisma: PrismaService) {}
constructor(private prisma: PrismaService) { }
async createSongHistoryRecord({
songID,
@@ -46,6 +46,7 @@ export class HistoryService {
): Promise<SongHistory[]> {
return this.prisma.songHistory.findMany({
where: { user: { id: playerId } },
orderBy: { playDate: 'asc' },
skip,
take,
});
@@ -75,6 +76,7 @@ export class HistoryService {
): Promise<SearchHistory[]> {
return this.prisma.searchHistory.findMany({
where: { user: { id: playerId } },
orderBy: { searchDate: 'asc' },
skip,
take,
});