Skip to content

Commit

Permalink
[FIX] 교수 심사현황/심사결과 api 자신의 심사역할 데이터 추가 (#146)
Browse files Browse the repository at this point in the history
* fix: 교수 심사현황/심사결과 api 자신의 심사역할 데이터 추가

* feat: reviewrRoles 배열로 리턴하도록 변경

* fix: reviewerRoles 배열로 리턴하도록 변경

* fix: reviewerRole 변경

---------

Co-authored-by: chanyeong <60565169+jcy0308@users.noreply.github.com>
  • Loading branch information
hynseok and jcy0308 authored Oct 5, 2024
1 parent 24691a3 commit edd8b72
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 10 deletions.
10 changes: 8 additions & 2 deletions src/modules/reviews/dtos/get-review-final-list.res.dto.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { ApiProperty } from "@nestjs/swagger";
import { Status, Stage } from "@prisma/client";
import { Status, Stage, Role } from "@prisma/client";
import { ReviewDto } from "./review.dto";
import { SearchStatus } from "./search-review.req.dto";
import { ProcessDto } from "./process.dto";

export class GetReviewFinalListResDto {
constructor(review: ReviewDto) {
constructor(review: ReviewDto, process: ProcessDto) {
this.id = review.id;
this.student = review.thesisInfo.process.student.name;
this.department = review.thesisInfo.process.student.department.name;
this.stage = review.thesisInfo.stage;
this.title = review.thesisInfo.title;
this.reviewerRole = process.reviewers.filter((reviewer) => {
if (reviewer.reviewerId === review.reviewer.id) return reviewer;
})[0].role;
if (review.contentStatus == Status.PASS || review.contentStatus == Status.FAIL) {
this.status = SearchStatus.COMPLETE;
} else {
Expand All @@ -27,6 +31,8 @@ export class GetReviewFinalListResDto {
stage: Stage;
@ApiProperty({ description: "논문 제목" })
title: string;
@ApiProperty({ description: "심사위원 타입" })
reviewerRole: Role;
@ApiProperty({ description: "심사 현황", enum: SearchStatus })
status: SearchStatus;
}
5 changes: 4 additions & 1 deletion src/modules/reviews/dtos/get-review-final.res.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from "@nestjs/swagger";
import { Stage, Status } from "@prisma/client";
import { Role, Stage, Status } from "@prisma/client";
import { FileDto } from "src/modules/files/dtos/file.dto";
import { ReviewDto } from "./review.dto";
import { ThesisFileDto } from "./thesis-file.dto";
Expand All @@ -9,6 +9,7 @@ export class GetReviewFinalResDto {
this.id = review.id;
this.student = review.thesisInfo.process.student.name;
this.department = review.thesisInfo.process.student.department.name;
this.reviewerRole = review.reviewerRole;
this.title = review.thesisInfo.title;
this.abstract = review.thesisInfo.abstract;
this.thesisFiles = review.thesisInfo.thesisFiles;
Expand All @@ -24,6 +25,8 @@ export class GetReviewFinalResDto {
title: string;
@ApiProperty({ description: "논문 저자 (학생)" })
student: string;
@ApiProperty({ description: "내 심사위원 타입" })
reviewerRole: Role;
@ApiProperty({ description: "학과/전공" })
department: string;
@ApiProperty({ description: "논문 초록" })
Expand Down
10 changes: 8 additions & 2 deletions src/modules/reviews/dtos/get-review-list.res.dto.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { ApiProperty } from "@nestjs/swagger";
import { Status, Stage } from "@prisma/client";
import { Status, Stage, Role } from "@prisma/client";
import { ReviewDto } from "./review.dto";
import { SearchStatus } from "./search-review.req.dto";
import { ProcessDto } from "./process.dto";

export class GetReviewListResDto {
constructor(review: ReviewDto) {
constructor(review: ReviewDto, process: ProcessDto) {
this.id = review.id;
this.student = review.thesisInfo.process.student.name;
this.department = review.thesisInfo.process.student.department.name;
this.stage = review.thesisInfo.stage;
this.title = review.thesisInfo.title;
this.reviewerRole = process.reviewers.filter((reviewer) => {
if (reviewer.reviewerId === review.reviewer.id) return reviewer;
})[0].role;
if (
(review.contentStatus == Status.PASS || review.contentStatus == Status.FAIL) &&
(review.presentationStatus == Status.PASS || review.presentationStatus == Status.FAIL)
Expand All @@ -30,6 +34,8 @@ export class GetReviewListResDto {
stage: Stage;
@ApiProperty({ description: "논문 제목" })
title: string;
@ApiProperty({ description: "심사위원 타입" })
reviewerRole: Role;
@ApiProperty({ description: "심사 현황", enum: SearchStatus })
status: SearchStatus;
}
5 changes: 4 additions & 1 deletion src/modules/reviews/dtos/get-review.res.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from "@nestjs/swagger";
import { Stage, Status } from "@prisma/client";
import { Role, Stage, Status } from "@prisma/client";
import { FileDto } from "src/modules/files/dtos/file.dto";
import { ReviewDto } from "./review.dto";
import { ThesisFileDto } from "./thesis-file.dto";
Expand All @@ -9,6 +9,7 @@ export class GetReviewResDto {
this.id = review.id;
this.title = review.thesisInfo.title;
this.student = review.thesisInfo.process.student.name;
this.reviewerRole = review.reviewerRole;
this.department = review.thesisInfo.process.student.department.name;
this.abstract = review.thesisInfo.abstract;
this.thesisFiles = review.thesisInfo.thesisFiles;
Expand All @@ -25,6 +26,8 @@ export class GetReviewResDto {
title: string;
@ApiProperty({ description: "논문 저자 (학생)" })
student: string;
@ApiProperty({ description: "내 심사위원 타입" })
reviewerRole: Role;
@ApiProperty({ description: "학과/전공" })
department: string;
@ApiProperty({ description: "논문 초록" })
Expand Down
7 changes: 7 additions & 0 deletions src/modules/reviews/dtos/review.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ThesisFile,
Reviewer,
Summary,
Role,
} from "@prisma/client";
import { ThesisInfoDto } from "./thesis-info.dto";
import { FileDto } from "src/modules/files/dtos/file.dto";
Expand All @@ -29,6 +30,10 @@ export class ReviewDto {
) {
this.id = review.id;
this.thesisInfo = new ThesisInfoDto(review.thesisInfo);
if (review.reviewer && review.thesisInfo)
this.reviewerRole = review.thesisInfo.process.reviewers.filter((reviewer) => {
if (reviewer.reviewerId === review.reviewer.id) return reviewer;
})[0].role;
if (review.reviewer) this.reviewer = new UserDto(review.reviewer);
if (review.file) this.file = new FileDto(review.file);
this.contentStatus = review.contentStatus;
Expand All @@ -43,6 +48,8 @@ export class ReviewDto {
id: number;
@ApiProperty({ description: "논문정보", type: () => ThesisInfoDto })
thesisInfo?: ThesisInfoDto;
@ApiProperty({ description: "내 심사위원 타입", type: () => ThesisInfoDto })
reviewerRole?: Role;
@ApiProperty({ description: "심사위원", type: () => UserDto })
reviewer?: UserDto;
@ApiProperty({ description: "심사정보 파일", type: FileDto })
Expand Down
13 changes: 9 additions & 4 deletions src/modules/reviews/reviews.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { GetCurrentListResDto } from "./dtos/get-current-list.res.dto";
import { GetResultResDto } from "./dtos/get-result.res.dto";
import { readableToBuffer } from "src/common/utils/readable-to-buf";
import { convertHTMLToPDF } from "src/common/utils/convert-html-to-pdf";
import { ProcessDto } from "./dtos/process.dto";

@Injectable()
export class ReviewsService {
Expand Down Expand Up @@ -502,7 +503,9 @@ export class ReviewsService {
},
});
return {
reviews: reviews.map((review) => new GetReviewListResDto(new ReviewDto(review))),
reviews: reviews.map(
(review) => new GetReviewListResDto(new ReviewDto(review), new ProcessDto(review.thesisInfo.process))
),
totalCount: totalCount,
};
}
Expand Down Expand Up @@ -592,7 +595,7 @@ export class ReviewsService {
},
},
})
).map((review) => new GetReviewListResDto(new ReviewDto(review)));
).map((review) => new GetReviewListResDto(new ReviewDto(review), new ProcessDto(review.thesisInfo.process)));

const records = reviews.map((review) => {
const record = {};
Expand Down Expand Up @@ -904,7 +907,9 @@ export class ReviewsService {
},
});
return {
reviews: reviews.map((review) => new GetReviewFinalListResDto(new ReviewDto(review))),
reviews: reviews.map(
(review) => new GetReviewFinalListResDto(new ReviewDto(review), new ProcessDto(review.thesisInfo.process))
),
totalCount: totalCount,
};
}
Expand Down Expand Up @@ -956,7 +961,7 @@ export class ReviewsService {
},
},
})
).map((review) => new GetReviewFinalListResDto(new ReviewDto(review)));
).map((review) => new GetReviewFinalListResDto(new ReviewDto(review), new ProcessDto(review.thesisInfo.process)));
const records = reviews.map((review) => {
const record = {};
record["저자"] = review.student;
Expand Down

0 comments on commit edd8b72

Please sign in to comment.