User => Player
This commit is contained in:
@ -23,8 +23,7 @@ export class ChallengeActionsController {
|
||||
@ApiUnauthorizedResponse({ description: "Non authentifié⋅e" })
|
||||
@ApiForbiddenResponse({ description: "Permission refusée" })
|
||||
async create(@Req() request: AuthenticatedRequest, @Body() createChallengeActionDto: CreateChallengeActionDto): Promise<ChallengeActionEntity> {
|
||||
const user = request.user
|
||||
const challenge = await this.challengeActionsService.create(user, createChallengeActionDto)
|
||||
const challenge = await this.challengeActionsService.create(request.user, createChallengeActionDto)
|
||||
return new ChallengeActionEntity(challenge)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Injectable, NotAcceptableException } from '@nestjs/common'
|
||||
import { CreateChallengeActionDto } from './dto/create-challenge-action.dto'
|
||||
import { UpdateChallengeActionDto } from './dto/update-challenge-action.dto'
|
||||
import { ChallengeAction, User } from '@prisma/client'
|
||||
import { ChallengeAction, Player } from '@prisma/client'
|
||||
import { PrismaService } from 'src/prisma/prisma.service'
|
||||
import { QueryPaginationDto } from 'src/common/dto/pagination-query.dto'
|
||||
import { paginate } from 'src/common/utils/pagination.utils'
|
||||
@ -11,8 +11,8 @@ import { FilterChallengeActionsDto } from './dto/filter-challenge-action.dto'
|
||||
export class ChallengeActionsService {
|
||||
constructor(private prisma: PrismaService) { }
|
||||
|
||||
async create(authenticatedUser: User, createChallengeActionDto: CreateChallengeActionDto): Promise<ChallengeAction> {
|
||||
const data = { ...createChallengeActionDto, userId: authenticatedUser.id }
|
||||
async create(authenticatedPlayer: Player, createChallengeActionDto: CreateChallengeActionDto): Promise<ChallengeAction> {
|
||||
const data = { ...createChallengeActionDto, playerId: authenticatedPlayer.id }
|
||||
return await this.prisma.challengeAction.create({
|
||||
data: data,
|
||||
})
|
||||
@ -49,10 +49,10 @@ export class ChallengeActionsService {
|
||||
})
|
||||
}
|
||||
|
||||
async endCurrentChallenge(user: User, success: boolean): Promise<ChallengeAction> {
|
||||
async endCurrentChallenge(player: Player, success: boolean): Promise<ChallengeAction> {
|
||||
const challengeAction = await this.prisma.challengeAction.findFirst({
|
||||
where: {
|
||||
userId: user.id,
|
||||
playerId: player.id,
|
||||
active: true,
|
||||
}
|
||||
})
|
||||
|
@ -7,8 +7,8 @@ export class FilterChallengeActionsDto {
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Type(() => Number)
|
||||
@ApiProperty({ description: "Identifiant de l'utilisateur⋅rice qui effectue le défi", required: false })
|
||||
userId?: number
|
||||
@ApiProperty({ description: "Identifiant de læ joueur⋅se qui effectue le défi", required: false })
|
||||
playerId?: number
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
|
@ -10,8 +10,8 @@ export class ChallengeActionEntity implements ChallengeAction {
|
||||
@ApiProperty({ description: "Identifiant unique" })
|
||||
id: number
|
||||
|
||||
@ApiProperty({ description: "Identifiant de l'utilisateur⋅rice effectuant le défi" })
|
||||
userId: number
|
||||
@ApiProperty({ description: "Identifiant de læ joueur⋅se effectuant le défi" })
|
||||
playerId: number
|
||||
|
||||
@ApiProperty({ description: "Identifiant du défi rattaché à l'action" })
|
||||
challengeId: number
|
||||
|
Reference in New Issue
Block a user