Skip to content

Commit

Permalink
[FIX] 박사과정 관련 기능 수정 (#152)
Browse files Browse the repository at this point in the history
* 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 <juhee0924@g.skku.edu>
  • Loading branch information
hynseok and yesjuhee authored Oct 18, 2024
1 parent 652b44e commit 2ba1812
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/modules/achievements/achievements.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions src/modules/achievements/dtos/achievement.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,6 +45,12 @@ export class AchievementDto {

@ApiProperty({ description: "학과" })
department?: string;

@ApiProperty({ description: "지도교수1" })
professorId1: number;

@ApiProperty({ description: "지도교수2" })
professorId2: number;
}

export class CreateAchievementResponseDto {
Expand All @@ -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;
Expand Down Expand Up @@ -83,4 +93,10 @@ export class CreateAchievementResponseDto {

@ApiProperty({ description: "유저ID" })
userId: number;

@ApiProperty({ description: "지도교수1" })
professorId1: number;

@ApiProperty({ description: "지도교수2" })
professorId2: number;
}
21 changes: 20 additions & 1 deletion src/modules/achievements/dtos/update-achievements.dto.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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[];
}
2 changes: 1 addition & 1 deletion src/modules/professors/professors.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
8 changes: 4 additions & 4 deletions src/modules/students/students.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
Expand Down Expand Up @@ -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 },
Expand All @@ -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,
},
});
Expand Down

0 comments on commit 2ba1812

Please sign in to comment.