Skip to content

Commit 5570fa9

Browse files
committed
✨ feat: Guest 삭제 기능 추가
- 관리자가 게스트 삭제 요청을 보냈을때 게스트에 대한 정보를 삭제하는 기능 추가 Issue Resolved: #
1 parent a365362 commit 5570fa9

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

back/src/domains/user/controller/user.controller.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
Body,
33
Controller,
4+
Delete,
45
Get,
56
HttpCode,
67
HttpStatus,
@@ -98,6 +99,12 @@ export class UserController {
9899
return userInfo;
99100
}
100101

102+
@UseGuards(SessionAuthGuard(USER_STATUS.ADMIN))
103+
@Delete('/guest')
104+
async deleteGuestMode() {
105+
return await this.userService.removeAllGuest();
106+
}
107+
101108
@ApiOperation({ summary: '로그인', description: 'id, password를 받아 로그인 요청을 처리한다.' })
102109
@ApiBody({
103110
type: UserLoginDto,

back/src/domains/user/repository/user.repository.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ export class UserRepository {
3131
return this.userRepository.findOne({ where: { loginId } });
3232
}
3333

34-
findOneOrFail({ where }) {
35-
if (where) {
36-
return where.id;
37-
} else {
38-
return 'no';
39-
}
34+
async deleteAllGuest() {
35+
return this.userRepository.delete({
36+
checkGuest: true,
37+
});
4038
}
4139
}

back/src/domains/user/service/user.service.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,17 @@ export class UserService {
179179
throw new InternalServerErrorException('게스트 사용자 생성에 실패하였습니다.');
180180
}
181181
}
182+
183+
async removeAllGuest() {
184+
try {
185+
const queryRunner = this.dataSource.createQueryRunner();
186+
await queryRunner.connect();
187+
await queryRunner.startTransaction();
188+
189+
return this.userRepository.deleteAllGuest();
190+
} catch (err) {
191+
this.logger.error(err.name, err.stack);
192+
throw new InternalServerErrorException('게스트 사용자 삭제에 실패하였습니다.');
193+
}
194+
}
182195
}

0 commit comments

Comments
 (0)