1
- import { Injectable , InternalServerErrorException , NotFoundException } from "@nestjs/common" ;
2
- import { Prisma } from "@prisma/client" ;
3
- import { mapScorecardRequestToDto , ScorecardPaginatedResponseDto , ScorecardQueryDto , ScorecardRequestDto , ScorecardResponseDto , ScorecardWithGroupResponseDto } from "src/dto/scorecard.dto" ;
4
- import { PrismaService } from "src/shared/modules/global/prisma.service" ;
1
+ import {
2
+ Injectable ,
3
+ InternalServerErrorException ,
4
+ NotFoundException ,
5
+ } from '@nestjs/common' ;
6
+ import { Prisma } from '@prisma/client' ;
7
+ import {
8
+ mapScorecardRequestToDto ,
9
+ ScorecardPaginatedResponseDto ,
10
+ ScorecardQueryDto ,
11
+ ScorecardRequestDto ,
12
+ ScorecardResponseDto ,
13
+ ScorecardWithGroupResponseDto ,
14
+ } from 'src/dto/scorecard.dto' ;
15
+ import { PrismaService } from 'src/shared/modules/global/prisma.service' ;
5
16
6
17
@Injectable ( )
7
18
export class ScoreCardService {
8
- constructor (
9
- private readonly prisma : PrismaService ,
10
- ) { }
19
+ constructor ( private readonly prisma : PrismaService ) { }
11
20
12
21
/**
13
22
* Adds score card
14
23
* @param body body from request
15
24
* @returns ScorecardWithGroupResponseDto
16
25
*/
17
- async addScorecard ( body : ScorecardRequestDto ) : Promise < ScorecardWithGroupResponseDto > {
26
+ async addScorecard (
27
+ body : ScorecardRequestDto ,
28
+ ) : Promise < ScorecardWithGroupResponseDto > {
18
29
const data = await this . prisma . scorecard . create ( {
19
30
data : mapScorecardRequestToDto ( body ) ,
20
31
include : {
@@ -38,7 +49,10 @@ export class ScoreCardService {
38
49
* @param body body from request
39
50
* @returns ScorecardWithGroupResponseDto
40
51
*/
41
- async editScorecard ( id : string , body : ScorecardWithGroupResponseDto ) : Promise < ScorecardWithGroupResponseDto > {
52
+ async editScorecard (
53
+ id : string ,
54
+ body : ScorecardWithGroupResponseDto ,
55
+ ) : Promise < ScorecardWithGroupResponseDto > {
42
56
const data = await this . prisma . scorecard
43
57
. update ( {
44
58
where : { id } ,
@@ -126,9 +140,15 @@ export class ScoreCardService {
126
140
* @returns response dto
127
141
*/
128
142
async getScoreCards (
129
- query : ScorecardQueryDto
143
+ query : ScorecardQueryDto ,
130
144
) : Promise < ScorecardPaginatedResponseDto > {
131
- const { page = 1 , perPage = 10 , challengeTrack, challengeType, name } = query ;
145
+ const {
146
+ page = 1 ,
147
+ perPage = 10 ,
148
+ challengeTrack,
149
+ challengeType,
150
+ name,
151
+ } = query ;
132
152
const skip = ( page - 1 ) * perPage ;
133
153
const where : Prisma . scorecardWhereInput = {
134
154
...( challengeTrack ?. length && {
@@ -161,9 +181,9 @@ export class ScoreCardService {
161
181
total : totalCount ,
162
182
page,
163
183
perPage,
164
- totalPages : Math . ceil ( totalCount / perPage ) ,
184
+ totalPages : Math . ceil ( totalCount / perPage ) ,
165
185
} ,
166
186
scoreCards : data as ScorecardResponseDto [ ] ,
167
187
} ;
168
188
}
169
- }
189
+ }
0 commit comments