From 437cdec5119e0736dd6201ef05c567a03b864788 Mon Sep 17 00:00:00 2001 From: adkm12 Date: Mon, 2 Dec 2024 16:11:52 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20typeORM=20cascade=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api-server/src/modules/mindmap/mindmap.service.ts | 8 -------- BE/libs/entity/src/mindmap.entity.ts | 10 ++++++++-- BE/libs/entity/src/node.entity.ts | 2 +- BE/libs/entity/src/user.entity.ts | 5 ++++- BE/libs/entity/src/user.mindmap.role.ts | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/BE/apps/api-server/src/modules/mindmap/mindmap.service.ts b/BE/apps/api-server/src/modules/mindmap/mindmap.service.ts index e71d3d60..ecd5f28d 100644 --- a/BE/apps/api-server/src/modules/mindmap/mindmap.service.ts +++ b/BE/apps/api-server/src/modules/mindmap/mindmap.service.ts @@ -95,14 +95,6 @@ export class MindmapService { throw new MindmapException('마인드맵을 찾을 수 없습니다.'); } - if (!nodes) { - return { - title: mindmap.title, - content: mindmap.content, - aiCount: mindmap.aiCount, - connectionId: mindmap.connectionId, - }; - } return { title: mindmap.title, content: mindmap.content, diff --git a/BE/libs/entity/src/mindmap.entity.ts b/BE/libs/entity/src/mindmap.entity.ts index 97516ac7..d70a7273 100644 --- a/BE/libs/entity/src/mindmap.entity.ts +++ b/BE/libs/entity/src/mindmap.entity.ts @@ -28,13 +28,19 @@ export class Mindmap { @Column({ name: 'ai_count', default: 5 }) aiCount: number; - @OneToMany(() => UserMindmapRole, (userMindmapRole) => userMindmapRole.mindmap) + @OneToMany(() => UserMindmapRole, (userMindmapRole) => userMindmapRole.mindmap, { + cascade: true, + onDelete: 'CASCADE', + }) userMindmapRoles: UserMindmapRole[]; @Column({ name: 'connection_id' }) connectionId: string; - @OneToMany(() => Node, (node) => node.mindmap) + @OneToMany(() => Node, (node) => node.mindmap, { + cascade: true, + onDelete: 'CASCADE', + }) nodes: Node[]; @CreateDateColumn({ type: 'timestamp', name: 'create_date' }) diff --git a/BE/libs/entity/src/node.entity.ts b/BE/libs/entity/src/node.entity.ts index 5414c87f..f295af2b 100644 --- a/BE/libs/entity/src/node.entity.ts +++ b/BE/libs/entity/src/node.entity.ts @@ -19,7 +19,7 @@ export class Node { @PrimaryGeneratedColumn() id: number; - @Column({ type: 'varchar', length: 32 }) + @Column({ type: 'varchar', length: 128 }) keyword: string; @Column({ name: 'location_x', type: 'float', default: 0 }) diff --git a/BE/libs/entity/src/user.entity.ts b/BE/libs/entity/src/user.entity.ts index 736b7ce7..cc9ef5cd 100644 --- a/BE/libs/entity/src/user.entity.ts +++ b/BE/libs/entity/src/user.entity.ts @@ -18,6 +18,9 @@ export class User { @CreateDateColumn({ type: 'timestamp', name: 'create_date' }) createDate: Date; - @OneToMany(() => UserMindmapRole, (userMindmapRole) => userMindmapRole.user) + @OneToMany(() => UserMindmapRole, (userMindmapRole) => userMindmapRole.user, { + cascade: true, + onDelete: 'CASCADE', + }) userMindmapRoles: UserMindmapRole[]; } diff --git a/BE/libs/entity/src/user.mindmap.role.ts b/BE/libs/entity/src/user.mindmap.role.ts index f5e17f35..f717cf20 100644 --- a/BE/libs/entity/src/user.mindmap.role.ts +++ b/BE/libs/entity/src/user.mindmap.role.ts @@ -8,11 +8,11 @@ export class UserMindmapRole { @PrimaryGeneratedColumn() id: number; - @ManyToOne(() => User, (user) => user.userMindmapRoles, { onDelete: 'CASCADE', nullable: false }) + @ManyToOne(() => User, (user) => user.userMindmapRoles, { nullable: false }) @JoinColumn({ name: 'user_id' }) user: User; - @ManyToOne(() => Mindmap, (mindmap) => mindmap.userMindmapRoles, { onDelete: 'CASCADE', nullable: false }) + @ManyToOne(() => Mindmap, (mindmap) => mindmap.userMindmapRoles, { nullable: false }) @JoinColumn({ name: 'mindmap_id' }) mindmap: Mindmap; From a29d3786fef9d7abede5d00d782eab67a418e7ab Mon Sep 17 00:00:00 2001 From: adkm12 Date: Mon, 2 Dec 2024 16:19:28 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix=20:=20=EC=86=8C=ED=94=84=ED=8A=B8=20?= =?UTF-8?q?=EB=94=9C=EB=A6=AC=ED=8A=B8=20=EC=BB=AC=EB=9F=BC=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BE/libs/entity/src/user.mindmap.role.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BE/libs/entity/src/user.mindmap.role.ts b/BE/libs/entity/src/user.mindmap.role.ts index f717cf20..19ffce12 100644 --- a/BE/libs/entity/src/user.mindmap.role.ts +++ b/BE/libs/entity/src/user.mindmap.role.ts @@ -20,5 +20,5 @@ export class UserMindmapRole { role: Role; @DeleteDateColumn() - deleteAt: Date | null; + deletedAt: Date | null; }