Skip to content

Commit 8df5660

Browse files
committed
fix: 선택지에 description 제거
1 parent 7731bc0 commit 8df5660

File tree

19 files changed

+122
-66
lines changed

19 files changed

+122
-66
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `description` on the `ChoicePage` table. All the data in the column will be lost.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "ChoicePage" DROP COLUMN "description";

prisma/schema.prisma

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ model ChoicePage {
151151
game Game @relation(fields: [gameId], references: [id])
152152
gameId Int @default(1)
153153
154-
title String
155-
description String
156-
order Int
154+
title String
155+
156+
order Int
157157
158158
UserChoice UserChoice[]
159159
createdAt DateTime @default(now())

src/common/kafka/chat-gpt/port/input/chat-gpt.service.interface.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export interface IChatGPTKafkaPort {
66
}[];
77
choices: {
88
title: string;
9-
description: string;
109
}[];
1110
}): Promise<void>;
1211
}

src/game-builder/choice/applications/controllers/choice.controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export class ChoiceController {
4848
@Param('gameId', ParseIntPipe) gameId: number,
4949
@Body() body: CreateChoiceReqDto,
5050
): Promise<CreateChoiceResDto> {
51-
console.log(body);
5251
return await this.createChoiceUsecase.execute(gameId, body);
5352
}
5453

src/game-builder/choice/applications/controllers/dto/update-choice.dto.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ export class UpdateChoiceReqDto {
99
@IsNotEmpty()
1010
title: string;
1111

12-
@IsString()
13-
description: string;
14-
1512
@IsNumber()
1613
@IsNotEmpty()
1714
parentPageId: number;
@@ -24,7 +21,7 @@ export class UpdateChoiceReqDto {
2421
export class UpdateChoiceResDto {
2522
id: number;
2623
title: string;
27-
description: string;
24+
2825
parentPageId: number;
2926
childPageId: number | null;
3027
}

src/game-builder/choice/applications/usecases/update-choice.usecase.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class UpdateChoiceUseCase {
4646

4747
const pageChoice = await this.choiceService.getAllByToPageId(parentPage.id);
4848

49-
if (pageChoice.length < 1) {
49+
if (pageChoice.length < 1 && !parentPage.isStarting) {
5050
throw new ConflictException(
5151
'부모 페이지가 없으면 선택지를 만들 수 없습니다.',
5252
);
@@ -80,7 +80,6 @@ export class UpdateChoiceUseCase {
8080
return {
8181
id: newChoice.id,
8282
title: newChoice.title,
83-
description: newChoice.description,
8483
parentPageId: newChoice.parentPageId,
8584
childPageId: newChoice.childPageId,
8685
};

src/game-builder/choice/domain/choice.service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ export class ChoiceService implements IChoiceService {
4444
async create(
4545
gameId: number,
4646
createChoiceReqDto: CreateChoiceReqDto,
47+
transaction?: Prisma.TransactionClient,
4748
): Promise<ChoiceDomainEntity> {
4849
const fromPage = await this.pageService.getOneById(
4950
createChoiceReqDto.parentPageId,
51+
transaction,
5052
);
5153

5254
if (!fromPage) {
@@ -57,6 +59,7 @@ export class ChoiceService implements IChoiceService {
5759
if (createChoiceReqDto.childPageId) {
5860
const childPage = await this.pageService.getOneById(
5961
createChoiceReqDto.childPageId,
62+
transaction,
6063
);
6164
if (!childPage) {
6265
throw new NotFoundException('해당 페이지가 존재하지 않습니다.');
@@ -65,6 +68,7 @@ export class ChoiceService implements IChoiceService {
6568

6669
const pageChoices = await this.choiceRepository.getAllByFromPageId(
6770
createChoiceReqDto.parentPageId,
71+
transaction,
6872
);
6973

7074
const pageChoice = new PageChoice(
@@ -79,13 +83,15 @@ export class ChoiceService implements IChoiceService {
7983
pageChoices.length + 1,
8084
createChoiceReqDto,
8185
fromPage.version,
86+
transaction,
8287
);
8388
return choice;
8489
}
8590

8691
async update(
8792
choiceId: number,
8893
updateChoiceReqDto: UpdateChoiceReqDto,
94+
transaction?: Prisma.TransactionClient,
8995
): Promise<ChoiceDomainEntity> {
9096
const choice = await this.choiceRepository.getOneById(choiceId);
9197
if (!choice) {
@@ -94,7 +100,7 @@ export class ChoiceService implements IChoiceService {
94100

95101
choice.updateChoice(updateChoiceReqDto);
96102

97-
return this.choiceRepository.update(choiceId, choice);
103+
return this.choiceRepository.update(choiceId, choice, transaction);
98104
}
99105

100106
async updateOrder(

src/game-builder/choice/domain/entities/choice.entity.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export class ChoiceDomainEntity {
44
constructor(
55
public id: number,
66
public title: string,
7-
public description: string,
87
public parentPageId: number,
98
public childPageId: number | null,
109
public order: number,
@@ -16,10 +15,6 @@ export class ChoiceDomainEntity {
1615
this.title = title;
1716
}
1817

19-
setDescription(description: string) {
20-
this.description = description;
21-
}
22-
2318
setParentPageId(parentPageId: number) {
2419
this.parentPageId = parentPageId;
2520
}
@@ -34,8 +29,6 @@ export class ChoiceDomainEntity {
3429

3530
updateChoice(updateChoiceReqDto: UpdateChoiceReqDto) {
3631
this.setTitle(updateChoiceReqDto.title);
37-
this.setDescription(updateChoiceReqDto.description);
38-
this.setParentPageId(updateChoiceReqDto.parentPageId);
3932
this.setChildPageId(updateChoiceReqDto.childPageId);
4033
}
4134
}

src/game-builder/choice/domain/port/input/choice.service.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ export interface IChoiceService {
2323
create(
2424
gameId: number,
2525
createChoiceReqDto: CreateChoiceReqDto,
26+
transaction?: Prisma.TransactionClient,
2627
): Promise<ChoiceDomainEntity>;
2728
update(
2829
choiceId: number,
2930
updateChoiceReqDto: UpdateChoiceReqDto,
31+
transaction?: Prisma.TransactionClient,
3032
): Promise<ChoiceDomainEntity>;
3133
delete(
3234
choiceId: number,

src/game-builder/choice/infrastructure/mapper/choice.mapper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const toDomain = (choice: ChoicePage): ChoiceDomainEntity => {
55
return new ChoiceDomainEntity(
66
choice.id,
77
choice.title,
8-
choice.description,
98
choice.fromPageId,
109
choice.toPageId,
1110
choice.order,
@@ -21,7 +20,6 @@ export const toEntity = (
2120
return {
2221
id: choice.id,
2322
title: choice.title,
24-
description: choice.description,
2523
fromPageId: choice.parentPageId,
2624
toPageId: choice.childPageId,
2725
order: choice.order,

0 commit comments

Comments
 (0)