Skip to content

Commit

Permalink
feat: 참여자 과거력 조회 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
eeseung committed Jun 27, 2024
1 parent d5e5f65 commit 6200bd3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 12 additions & 3 deletions backend/src/patients/patients.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import {
} from '@nestjs/common';
import { PatientsService } from './patients.service';
import { CreatePatientDto } from './dto/create-patient.dto';
import { ApiOperation, ApiResponse } from '@nestjs/swagger';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Department } from 'src/orders/const/department.const';
import { Patients } from './entity/patients.entity';

@ApiTags('참여자')
@Controller('patients')
export class PatientsController {
constructor(private readonly patientsService: PatientsService) {}
Expand Down Expand Up @@ -70,13 +71,21 @@ export class PatientsController {

@Get(':patientId')
@ApiOperation({
summary: '참여자 상세 정보',
summary: '참여자 상세 조회',
})
@ApiResponse({
status: HttpStatus.OK,
description: '참여자 상세 정보 반환',
description: '참여자 상세 조회',
})
async getPatient(@Param('patientId', ParseIntPipe) id: number) {
return this.patientsService.getPatientById(id);
}

@Get(':patientId/histories')
@ApiOperation({
summary: '참여자 과거력 조회',
})
async getPatientHistory(@Param('patientId', ParseIntPipe) patientId: number) {
return this.patientsService.getPatientHistoryById(patientId);
}
}
7 changes: 7 additions & 0 deletions backend/src/patients/patients.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,11 @@ export class PatientsService {
async getPatientById(id: number): Promise<Patients> {
return this.patientsRepository.findOne({ where: { id } });
}

getPatientHistoryById(patientId: number) {
return this.patientsRepository.findOne({
where: { id: patientId },
relations: { history: true },
});
}
}

0 comments on commit 6200bd3

Please sign in to comment.