Skip to content

Commit

Permalink
Merge pull request #201 from boostcampwm2023/feat/178-stellar-route-api
Browse files Browse the repository at this point in the history
[Hotfix] 별자리선이 연결된 일기 삭제 시 별자리선도 함께 삭제
  • Loading branch information
mingxoxo authored Dec 4, 2023
2 parents c4cd1ce + bf122a7 commit c486b46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion BE/src/diaries/diaries.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { ShapesModule } from "src/shapes/shapes.module";
import { ShapesRepository } from "src/shapes/shapes.repository";
import { TagsRepository } from "src/tags/tags.repository";
import { HttpModule } from "@nestjs/axios";
import { Line } from "src/lines/lines.entity";

@Module({
imports: [
TypeOrmModule.forFeature([Diary]),
TypeOrmModule.forFeature([Diary, Line]),
AuthModule,
TagsModule,
ShapesModule,
Expand Down
11 changes: 10 additions & 1 deletion BE/src/diaries/diaries.repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { User } from "src/auth/users.entity";
import { Line } from "src/lines/lines.entity";
import {
CreateDiaryDto,
DeleteDiaryDto,
Expand Down Expand Up @@ -98,7 +99,15 @@ export class DiariesRepository {

async deleteDiary(deleteDiaryDto: DeleteDiaryDto): Promise<void> {
const { uuid } = deleteDiaryDto;
const diary = await this.getDiaryByUuid(uuid);
const diary: Diary = await this.getDiaryByUuid(uuid);

const lines = await Line.find({
where: [
{ firstDiary: { id: diary.id } },
{ secondDiary: { id: diary.id } },
],
});
await Line.softRemove(lines);

await Diary.softRemove(diary);
}
Expand Down

0 comments on commit c486b46

Please sign in to comment.