1
1
import { Injectable } from '@nestjs/common' ;
2
2
import { PrismaService } from '../prisma/prisma.service' ;
3
- import { Prisma , Profile_space } from '@prisma/client' ;
3
+ import { Prisma , ProfileSpace } from '@prisma/client' ;
4
4
5
5
@Injectable ( )
6
6
export class ProfileSpaceService {
7
7
constructor ( private readonly prisma : PrismaService ) { }
8
8
9
9
async findProfileSpacesByProfileUuid (
10
10
profileUuid : string ,
11
- ) : Promise < Profile_space [ ] > {
12
- return this . prisma . profile_space . findMany ( {
13
- where : { profile_uuid : profileUuid } ,
11
+ ) : Promise < ProfileSpace [ ] > {
12
+ return this . prisma . profileSpace . findMany ( {
13
+ where : { profileUuid : profileUuid } ,
14
14
} ) ;
15
15
}
16
16
17
17
async findProfileSpacesBySpaceUuid (
18
18
spaceUuid : string ,
19
- ) : Promise < Profile_space [ ] > {
20
- return this . prisma . profile_space . findMany ( {
21
- where : { space_uuid : spaceUuid } ,
19
+ ) : Promise < ProfileSpace [ ] > {
20
+ return this . prisma . profileSpace . findMany ( {
21
+ where : { spaceUuid : spaceUuid } ,
22
+ } ) ;
23
+ }
24
+
25
+ async findProfileSpaceByBothUuid (
26
+ profileUuid : string ,
27
+ spaceUuid : string ,
28
+ ) : Promise < ProfileSpace | null > {
29
+ return this . prisma . profileSpace . findUnique ( {
30
+ where : { spaceUuid_profileUuid : { spaceUuid, profileUuid } } ,
22
31
} ) ;
23
32
}
24
33
25
34
async joinSpace (
26
35
profileUuid : string ,
27
36
spaceUuid : string ,
28
- ) : Promise < Profile_space | null > {
37
+ ) : Promise < ProfileSpace | null > {
29
38
try {
30
- return await this . prisma . profile_space . create ( {
31
- data : { space_uuid : spaceUuid , profile_uuid : profileUuid } ,
39
+ return await this . prisma . profileSpace . create ( {
40
+ data : { spaceUuid : spaceUuid , profileUuid : profileUuid } ,
32
41
} ) ;
33
42
} catch ( err ) {
34
43
if ( err instanceof Prisma . PrismaClientKnownRequestError ) {
@@ -42,13 +51,13 @@ export class ProfileSpaceService {
42
51
async leaveSpace (
43
52
profileUuid : string ,
44
53
spaceUuid : string ,
45
- ) : Promise < Profile_space | null > {
54
+ ) : Promise < ProfileSpace | null > {
46
55
try {
47
- return await this . prisma . profile_space . delete ( {
56
+ return await this . prisma . profileSpace . delete ( {
48
57
where : {
49
- space_uuid_profile_uuid : {
50
- space_uuid : spaceUuid ,
51
- profile_uuid : profileUuid ,
58
+ spaceUuid_profileUuid : {
59
+ spaceUuid : spaceUuid ,
60
+ profileUuid : profileUuid ,
52
61
} ,
53
62
} ,
54
63
} ) ;
@@ -62,9 +71,9 @@ export class ProfileSpaceService {
62
71
}
63
72
64
73
async isSpaceEmpty ( spaceUuid : string ) {
65
- const first = await this . prisma . profile_space . findFirst ( {
74
+ const first = await this . prisma . profileSpace . findFirst ( {
66
75
where : {
67
- space_uuid : spaceUuid ,
76
+ spaceUuid : spaceUuid ,
68
77
} ,
69
78
} ) ;
70
79
return first ? false : true ;
0 commit comments