Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week3 최종 보고 #21

Merged
merged 34 commits into from
Sep 24, 2024
Merged

Week3 최종 보고 #21

merged 34 commits into from
Sep 24, 2024

Conversation

20jcode
Copy link
Contributor

@20jcode 20jcode commented Sep 23, 2024

돌봄다리 서비스는 요양원에서 사용하며, 요양보호사들의 차트 작성을 돕고,

작성된 차트를 기반으로 보호자에게 입소자(돌봄 대상자)들에 대한 기록을 전송해주는 서비스입니다.

일정보다 늦게 제출하게되어 죄송하다는 말씀을 드리며, 앞으로는 이런 일이 없도록 하겠습니다!!

프로젝트 관련 몇가지 질문이 있는데요,

  1. 팀원들의 실력을 잘 모르는 상태에서 어떤 식으로 개발 파트를 분배하고 이를 관리하는 것이 효율적인지 여쭤봅니다.

  2. 예외 핸들링을 어떤 방식으로 하면 좋을 지에 대해서 여쭤봅니다.

감사합니당

pykido and others added 30 commits September 20, 2024 01:29
- 식별자, 생성/수정일자, 삭제 상태값 등의 공통 필드를 baseEntity로 정의
- 청결, 식사 관련 필드는 임베디드 타입으로 선언
- chart와 신체활동(bodyNote)는 일대일 연관관계 설정
- 혈압 관련 필드는 임베디드 타입으로 관리
feat: baseEntity 삭제 함수 추가
mogld and others added 4 commits September 23, 2024 14:05
[관리자 페이지] 돌봄대상자, 요양보호사 도메인 CRUD
* feat: guardians

* feat: #8 guardians 코드리뷰 반영

* fix: chart 도메인 부분 수정

* refactor: guardian 폴더 분리, exception 등 코드리뷰 반영

* fix: chart is_active 수정
@pykido pykido changed the title Week3 코드 리뷰 PR 차트 작성 구현 - 직접 입력하기 Sep 23, 2024
@pykido pykido changed the title 차트 작성 구현 - 직접 입력하기 Week3 최종 보고 Sep 23, 2024
@pykido pykido self-requested a review September 23, 2024 12:26
@pykido pykido added the 📃 docs 문서 작성 및 수정 label Sep 23, 2024
Copy link

@cheol-95 cheol-95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요~
프로젝트 설정 및 기본적인 비즈니스 로직까지 작성하셨군요 👍

코드는 전반적으로 잘 작성하셨습니다!
추가로 개발 초기부터 컨트롤러 레이어에 Swagger를 적용하는것도 고려해보세요!

고생하셨습니다!


Q. 팀원들의 실력을 잘 모르는 상태에서 어떤 식으로 개발 파트를 분배하고 이를 관리하는 것이 효율적인지 여쭤봅니다.

일단 현업이 아닌 지금 상태에서는 각 팀원이 어떤 부분에 관심이 있는지 파악하는 과정이 필요합니다. 처음부터 기능을 나누어 개발하기 보다는 강점이 있거나 관심있는 분야, 혹은 경헙해보고 싶은 작업을 진행하는 게 좋습니다. 예를 들어 누군가는 DB 관련 작업을, 누군가는 인증 관련 작업, 누군가는 인프라 관리쪽에 관심이 있을 수 있으니 니즈를 파악하고 업무를 분배하는것이 좋습니다.

코드 리뷰나 페어 프로그래밍을 통해 서로 피드백을 주고받는 것도 좋은 방법입니다. 이렇게 하면 실력 차이를 줄이고, 팀 전체의 협업 능력을 높이는 데 도움이 됩니다. 정기적인 피드백 세션을 통해 진행 상황을 점검하고, 문제를 미리 파악해 나가는 것도 효과적입니다.

가장 중요한 것은 작업이 끝난 후에 각자가 맡은 일을 어떻게 해결하였는지 PR이나 문서, 화상회의로 공유하는 시간을 꼭 가져야 합니다. 멘티분들은 현업에 뛰어들기 위하여 위에서 언급한 모든 기술(DB, 인프라 등)을 경험하는 것이 중요하기 때문에 자신이 작업하면서 겪었던 이슈와 그것을 해결한 경험을 공유하는것이 중요합니다.


Q. 예외 핸들링을 어떤 방식으로 하면 좋을 지에 대해서 여쭤봅니다.

Step2에서 진행한 방식대로 전역 예외 처리 핸들러를 사용하고, 커스텀 예외 클래스, 에러 코드 정의, 그리고 에러 응답 포맷을 정의하면 될 것 같습니다.

[전체 흐름]

  1. 애플리케이션에서 예외가 발생하면, 그 예외가 GlobalExceptionHandler에서 가로채집니다.
  2. 발생한 예외가 BusinessException인 경우, 해당 예외에 미리 정의된 ErrorCode를 참조하여 적절한 에러 메시지와 상태 코드를 반환합니다.
  3. ErrorCode에서 정의한 메시지와 상태 코드를 기반으로 ErrorResponse 객체를 생성하고, 이를 클라이언트에게 응답으로 돌려줍니다.


@SpringBootApplication
@EnableJpaAuditing

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnableJpaAuditing를 사용하여 엔티티 생성, 수정 시간을 자동으로 관리하는군요 👍

Comment on lines +46 to +53
@PutMapping("/{guardianId}/update")
public ResponseEntity<GuardiansResponse> updateGuardianAuth(
@PathVariable("guardianId") Long guardianId,
@Valid @RequestBody GuardiansRequest guardiansRequest) {
GuardiansResponse guardiansResponse = guardiansService.updateGuardianById(guardianId,
guardiansRequest);
return ResponseEntity.ok(guardiansResponse);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PUT을 사용하였으니 path에는 update를 제거해도 될 것 같습니다.

Comment on lines +55 to +60
@PutMapping("/{guardianId}/delete")
public ResponseEntity<Void> deleteGuardianAuth(
@PathVariable("guardianId") Long guardianId) {
guardiansService.deleteGuardianById(guardianId);
return ResponseEntity.noContent().build();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PUT대신 DELETE를 사용하고 path에는 delete를 제거해도 될 것 같습니다.

Comment on lines +30 to +37
@PutMapping("/{guardianId}")
public ResponseEntity<GuardiansResponse> updateGuardianInfo(
@PathVariable("guardianId") Long guardianId,
@Valid @RequestBody GuardiansRequest guardiansRequest) {
GuardiansResponse guardiansResponse = guardiansService.updateGuardianById(guardianId,
guardiansRequest);
return ResponseEntity.ok(guardiansResponse);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

권한 처리는 없어도 될까요?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스프링 시큐리티를 활용하여 @PreAuthorize 어노테이션으로 컨트롤러 단에서 권한 처리를 하려고 현재 개발중입니다!

import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1/guardians")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REST API 버전을 URL 경로 /v1/... 에 직접 하드코딩하지 말고, 프로퍼티 파일 등을 사용하여 유연하게 처리하는 것이 좋습니다.

Comment on lines +36 to +42
@Transactional(readOnly = true)
public CareworkerResponseDTO getCareworkerById(Long id) {
Careworker careworker = careworkerRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("요양보호사를 찾을 수 없습니다."));
return toResponseDTO(careworker);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalArgumentException은 일반적인 용도로 사용하기에는 부적절합니다. 더 구체적이고 의미 있는 예외 클래스를 만들어 사용하는 것이 좋습니다.

Comment on lines +57 to +58
Careworker careworker = careworkerRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("요양보호사를 찾을 수 없습니다."));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 코드가 중복되는데, 코드 분리를 고려해보세요.

Comment on lines +68 to +69
Careworker careworker = careworkerRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("요양보호사를 찾을 수 없습니다."));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 코드가 중복되는데, 코드 분리를 고려해보세요.

Comment on lines +44 to +50
public CareworkerResponseDTO createCareworker(CareworkerRequestDTO careworkerRequestDTO) {
Careworker careworker = new Careworker(
careworkerRequestDTO.getInstitutionId(),
careworkerRequestDTO.getName(),
careworkerRequestDTO.getEmail(),
careworkerRequestDTO.getPhone()
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이메일이나 전화번호와 같은 필드에 대해 중복 검사를 추가하는 것이 좋습니다.

Comment on lines +52 to +56
private void phoneNumberExists(String phone) {
if(guardiansRepository.existsByPhone(phone)){
throw new IllegalArgumentException("존재하는 전화번호입니다.");
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

명확한 에러를 정의하고 throw하는게 좋아보입니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📃 docs 문서 작성 및 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants