From 2ba18129786ff11a8101d499b2c1d9ffce074c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=84=EC=84=9D?= Date: Fri, 18 Oct 2024 18:36:16 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EB=B0=95=EC=82=AC=EA=B3=BC=EC=A0=95=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?(#152)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: user type PHD 추가 * feat: createPhD API 구현 * fix: 학생 엑셀 업로드 양식에 박사과정 학생 등록 방식 설명 추가 * feat: createPhDExcel API 구현 * feat: PHD UserType에 일부 API 권한 부여 * feat: 연구실적 서비스 로직에 PHD UserType 추가 * fix: 연구실적 DB 구조 수정 * fix: 연구실적 등록 시 지도교수 최대 2명 설정 가능 * fix: 연구실적 엑셀 다운로드 시 학위과정, 지도교수 이름 포함 * fix: 연구실적 지도교수 수정기능 추가 * fix: 박사과정 학생 수정 기능 추가 --------- Co-authored-by: yesjuhee --- .../achievements/achievements.service.ts | 8 ++++++- .../achievements/dtos/achievement.dto.ts | 16 ++++++++++++++ .../dtos/update-achievements.dto.ts | 21 ++++++++++++++++++- .../professors/professors.controller.ts | 2 +- src/modules/students/students.service.ts | 8 +++---- 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/modules/achievements/achievements.service.ts b/src/modules/achievements/achievements.service.ts index 256d9cd..ebec487 100644 --- a/src/modules/achievements/achievements.service.ts +++ b/src/modules/achievements/achievements.service.ts @@ -62,7 +62,7 @@ export class AchievementsService { if (!foundUser) throw new BadRequestException("해당 논문실적은 존재하지 않습니다."); if ((user.type === UserType.STUDENT || user.type === UserType.PHD) && foundUser.userId != user.id) throw new BadRequestException("다른 학생의 논문실적은 수정할수 없습니다."); - const { performance, paperTitle, journalName, ISSN, publicationDate, authorType, authorNumbers } = + const { performance, paperTitle, journalName, ISSN, publicationDate, authorType, authorNumbers, professorIds } = updateAchievementDto; try { return await this.prismaService.achievements.update({ @@ -77,6 +77,12 @@ export class AchievementsService { ...(publicationDate && { publicationDate }), ...(authorType && { authorType }), ...(authorNumbers && { authorNumbers }), + ...(professorIds.length == 0 && { professorId1: null }), + ...(professorIds.length == 0 && { professorId2: null }), + ...(professorIds.length == 1 && { professorId1: professorIds[0] }), + ...(professorIds.length == 1 && { professorId2: null }), + ...(professorIds.length == 2 && { professorId1: professorIds[0] }), + ...(professorIds.length == 2 && { professorId2: professorIds[1] }), }, }); } catch { diff --git a/src/modules/achievements/dtos/achievement.dto.ts b/src/modules/achievements/dtos/achievement.dto.ts index d92d105..7a546f8 100644 --- a/src/modules/achievements/dtos/achievement.dto.ts +++ b/src/modules/achievements/dtos/achievement.dto.ts @@ -13,6 +13,8 @@ export class AchievementDto { this.authorNumbers = achievement.authorNumbers; this.name = achievement.User.name; this.department = achievement.User.department.name; + this.professorId1 = achievement.professorId1; + this.professorId2 = achievement.professorId2; } @ApiProperty({ description: "논문실적 id" }) id: number; @@ -43,6 +45,12 @@ export class AchievementDto { @ApiProperty({ description: "학과" }) department?: string; + + @ApiProperty({ description: "지도교수1" }) + professorId1: number; + + @ApiProperty({ description: "지도교수2" }) + professorId2: number; } export class CreateAchievementResponseDto { @@ -56,6 +64,8 @@ export class CreateAchievementResponseDto { this.authorType = achievement.authorType; this.authorNumbers = achievement.authorNumbers; this.userId = achievement.userId; + this.professorId1 = achievement.professorId1; + this.professorId2 = achievement.professorId2; } @ApiProperty({ description: "논문실적 id" }) id: number; @@ -83,4 +93,10 @@ export class CreateAchievementResponseDto { @ApiProperty({ description: "유저ID" }) userId: number; + + @ApiProperty({ description: "지도교수1" }) + professorId1: number; + + @ApiProperty({ description: "지도교수2" }) + professorId2: number; } diff --git a/src/modules/achievements/dtos/update-achievements.dto.ts b/src/modules/achievements/dtos/update-achievements.dto.ts index fab9055..5e03814 100644 --- a/src/modules/achievements/dtos/update-achievements.dto.ts +++ b/src/modules/achievements/dtos/update-achievements.dto.ts @@ -1,4 +1,14 @@ -import { IsDate, IsEnum, IsInt, IsOptional, IsPositive, IsString } from "class-validator"; +import { + ArrayMaxSize, + ArrayMinSize, + IsArray, + IsDate, + IsEnum, + IsInt, + IsOptional, + IsPositive, + IsString, +} from "class-validator"; import { Author } from "../../../common/enums/author.enum"; import { ApiProperty } from "@nestjs/swagger"; import { Type } from "class-transformer"; @@ -70,4 +80,13 @@ export class UpdateAchievementsDto { @IsInt() @IsPositive() authorNumbers: number; + + @ApiProperty({ description: "지도교수 아이디 리스트", type: [Number], example: "[3, 4]" }) + @IsArray() + @Type(() => Number) + @IsInt({ each: true }) + @IsPositive({ each: true }) + @ArrayMinSize(0) + @ArrayMaxSize(2) + professorIds: number[]; } diff --git a/src/modules/professors/professors.controller.ts b/src/modules/professors/professors.controller.ts index 7bb9e02..b1b3cd2 100644 --- a/src/modules/professors/professors.controller.ts +++ b/src/modules/professors/professors.controller.ts @@ -35,7 +35,7 @@ export class ProfessorsController { summary: "교수 목록 조회", description: "교수 목록 조회", }) - @UseUserTypeGuard([UserType.ADMIN]) + @UseUserTypeGuard([UserType.ADMIN, UserType.STUDENT, UserType.PHD]) @ApiUnauthorizedResponse({ description: "[관리자] 로그인 후 접근 가능" }) @ApiInternalServerErrorResponse({ description: "서버 내부 오류" }) @ApiPaginationOKResponse({ description: "교수 목록 조회 성공", dto: ProfessorDto }) diff --git a/src/modules/students/students.service.ts b/src/modules/students/students.service.ts index fe75832..f724b6c 100644 --- a/src/modules/students/students.service.ts +++ b/src/modules/students/students.service.ts @@ -1239,7 +1239,7 @@ export class StudentsService { const students = await this.prismaService.user.findMany({ where: { - type: UserType.STUDENT, + type: { in: [UserType.STUDENT, UserType.PHD] }, loginId: { contains: studentNumber }, name: { contains: name }, email: { contains: email }, @@ -1254,7 +1254,7 @@ export class StudentsService { const totalCount = await this.prismaService.user.count({ where: { - type: UserType.STUDENT, + type: { in: [UserType.STUDENT, UserType.PHD] }, loginId: { contains: studentNumber }, name: { contains: name }, email: { contains: email }, @@ -1360,7 +1360,7 @@ export class StudentsService { const student = await this.prismaService.user.findUnique({ where: { id: studentId, - type: UserType.STUDENT, + type: { in: [UserType.STUDENT, UserType.PHD] }, deletedAt: null, }, include: { department: true, studentProcess: true }, @@ -1379,7 +1379,7 @@ export class StudentsService { const foundStudent = await this.prismaService.user.findUnique({ where: { id: studentId, - type: UserType.STUDENT, + type: { in: [UserType.STUDENT, UserType.PHD] }, deletedAt: null, }, });