Skip to content

Commit 0e96a18

Browse files
authored
Merge pull request #150 from gsainfoteam/siwonpada/issue149
[BUG] third party useInfo api response 수정
2 parents 8b46fd1 + 85e3fad commit 0e96a18

File tree

6 files changed

+69
-44
lines changed

6 files changed

+69
-44
lines changed
Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
import { ApiProperty } from '@nestjs/swagger';
2-
import {
3-
$Enums,
4-
ExternalPermission,
5-
RoleExternalPermission,
6-
} from '@prisma/client';
7-
import { UserRoleInfo } from 'src/third-party/types/userRoleInfo.type';
8-
9-
class ExternalPermissionDto implements ExternalPermission {
10-
@ApiProperty()
11-
clientUuid: string;
12-
13-
@ApiProperty()
14-
permission: string;
15-
}
2+
import { $Enums, Role, RoleExternalPermission } from '@prisma/client';
3+
import { UserGroupInfo } from 'src/third-party/types/userGroupInfo.type';
164

175
class RoleExternalPermissionDto implements RoleExternalPermission {
18-
@ApiProperty({ type: ExternalPermissionDto })
19-
ExternalPermission: ExternalPermissionDto;
20-
216
@ApiProperty()
227
clientUuid: string;
238

@@ -31,7 +16,7 @@ class RoleExternalPermissionDto implements RoleExternalPermission {
3116
roleGroupUuid: string;
3217
}
3318

34-
export class UserRoleInfoResDto implements UserRoleInfo {
19+
class RoleDto implements Role {
3520
@ApiProperty({ type: [RoleExternalPermissionDto] })
3621
RoleExternalPermission: RoleExternalPermissionDto[];
3722

@@ -47,3 +32,34 @@ export class UserRoleInfoResDto implements UserRoleInfo {
4732
@ApiProperty({ enum: $Enums.Permission, isArray: true })
4833
permissions: $Enums.Permission[];
4934
}
35+
export class UserGroupInfoResDto implements UserGroupInfo {
36+
@ApiProperty({ type: [RoleDto] })
37+
Role: RoleDto[];
38+
39+
@ApiProperty()
40+
name: string;
41+
42+
@ApiProperty()
43+
description: string | null;
44+
45+
@ApiProperty()
46+
uuid: string;
47+
48+
@ApiProperty()
49+
createdAt: Date;
50+
51+
@ApiProperty()
52+
verifiedAt: Date | null;
53+
54+
@ApiProperty()
55+
presidentUuid: string;
56+
57+
@ApiProperty()
58+
deletedAt: Date | null;
59+
60+
@ApiProperty()
61+
notionPageId: string | null;
62+
63+
@ApiProperty()
64+
profileImageKey: string | null;
65+
}

src/third-party/third-party.controller.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { TokenResDto } from './dto/res/tokenRes.dto';
3131
import { UserGuard } from 'src/auth/guard/user.guard';
3232
import { GetUser } from 'src/auth/decorator/getUser.decorator';
3333
import { User } from '@prisma/client';
34-
import { UserRoleInfoResDto } from './dto/res/userRoleInfoRes.dto';
34+
import { UserGroupInfoResDto } from './dto/res/userRoleInfoRes.dto';
3535
import { ThirdPartyGuard } from './guard/third-party.guard';
3636

3737
@ApiTags('Third Party')
@@ -85,8 +85,9 @@ export class ThirdPartyController {
8585
'Retrieves user role information for the specified third-party client.',
8686
})
8787
@ApiOkResponse({
88-
description: 'Returns user role information for the third-party client.',
89-
type: [UserRoleInfoResDto],
88+
description:
89+
'Returns user group and role information for the third-party client.',
90+
type: [UserGroupInfoResDto],
9091
})
9192
@ApiUnauthorizedResponse({ description: 'Invalid request' })
9293
@ApiInternalServerErrorResponse({ description: 'Internal server error' })
@@ -96,7 +97,7 @@ export class ThirdPartyController {
9697
async userinfo(
9798
@GetUser()
9899
{ userUuid, clientUuid }: { userUuid: string; clientUuid: string },
99-
): Promise<UserRoleInfoResDto[]> {
100+
): Promise<UserGroupInfoResDto[]> {
100101
return this.thirdPartyService.userinfo(userUuid, clientUuid);
101102
}
102103
}

src/third-party/third-party.repository.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@nestjs/common';
77
import { Client } from '@prisma/client';
88
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library';
9-
import { UserRoleInfo } from './types/userRoleInfo.type';
9+
import { UserGroupInfo } from './types/userGroupInfo.type';
1010

1111
@Injectable()
1212
export class ThirdPartyRepository {
@@ -28,25 +28,33 @@ export class ThirdPartyRepository {
2828
});
2929
}
3030

31-
async findRoleByClientUuidAndUserUuid(
31+
async findGroupByClientUuidAndUserUuid(
3232
clientUuid: string,
3333
userUuid: string,
34-
): Promise<UserRoleInfo[]> {
35-
return this.prismaService.role.findMany({
34+
): Promise<UserGroupInfo[]> {
35+
return this.prismaService.group.findMany({
3636
where: {
37-
userRole: {
37+
UserRole: {
3838
some: {
3939
userUuid,
4040
},
4141
},
4242
},
4343
include: {
44-
RoleExternalPermission: {
44+
Role: {
4545
where: {
46-
clientUuid,
46+
userRole: {
47+
some: {
48+
userUuid,
49+
},
50+
},
4751
},
4852
include: {
49-
ExternalPermission: true,
53+
RoleExternalPermission: {
54+
where: {
55+
clientUuid,
56+
},
57+
},
5058
},
5159
},
5260
},

src/third-party/third-party.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { AuthorizeCache } from './types/authorizeCache.type';
1010
import { JwtService } from '@nestjs/jwt';
1111
import { ConfigService } from '@nestjs/config';
1212
import * as ms from 'ms';
13-
import { UserRoleInfoResDto } from './dto/res/userRoleInfoRes.dto';
13+
import { UserGroupInfoResDto } from './dto/res/userRoleInfoRes.dto';
1414
import { Loggable } from '@lib/logger';
1515

1616
@Loggable()
@@ -90,9 +90,9 @@ export class ThirdPartyService {
9090
async userinfo(
9191
userUuid: string,
9292
clientUuid: string,
93-
): Promise<UserRoleInfoResDto[]> {
93+
): Promise<UserGroupInfoResDto[]> {
9494
const userRoleInfo =
95-
await this.thirdPartyRepository.findRoleByClientUuidAndUserUuid(
95+
await this.thirdPartyRepository.findGroupByClientUuidAndUserUuid(
9696
clientUuid,
9797
userUuid,
9898
);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Prisma } from '@prisma/client';
2+
3+
export type UserGroupInfo = Prisma.GroupGetPayload<{
4+
include: {
5+
Role: {
6+
include: {
7+
RoleExternalPermission: true;
8+
};
9+
};
10+
};
11+
}>;

src/third-party/types/userRoleInfo.type.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)