Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
22f78fb
[FEAT] 자가진단표 api 구현
kdy2224 Apr 5, 2025
a9df269
[REFACT] 자가진단표 api 리팩토링
kdy2224 Apr 6, 2025
f304e4c
[CHORE] 오타 수정
kdy2224 Apr 6, 2025
1514b96
[REFACT] user api 리팩토링
kdy2224 Apr 7, 2025
4fc707e
[REFACT] 증상 목록 조회 api 수정
kdy2224 Apr 7, 2025
83cedcd
[REFACT] 자가진단표 api 컨버터 수정
kdy2224 Apr 7, 2025
da1e282
[CHORE] 사소한 코드 수정
kdy2224 Apr 7, 2025
9ae2386
[TEMP] 임시저장
kdy2224 Apr 19, 2025
366b76c
[REFACT] 자가진단표 api 피드백 반영
kdy2224 Apr 19, 2025
d52b4cb
[REFACT] @UserId 로 변경
kdy2224 Apr 19, 2025
1e77e1a
[CHORE] SelfDiagnosisController, SymptomController 에 스웨거 세부 설정 추가
kdy2224 Apr 22, 2025
205f8ab
[CHORE] 리뷰/피드백 반영
kdy2224 Apr 23, 2025
7d1a5c6
Merge remote-tracking branch 'ouch-cs/main' into feat/#36/self-diagnosis
kdy2224 Apr 23, 2025
92e9546
[CHORE] 불필요한 코드, 파일 삭제
kdy2224 Apr 23, 2025
3a8b337
[REFACT] selfDiagnosisService 의 self diagnosis 조회 쿼리 메서드 변경
kdy2224 Apr 23, 2025
8ea9137
[REFACT] 피드백/리뷰 반영
kdy2224 Apr 23, 2025
7b0763b
[CHORE] 피드백/리뷰 반영
kdy2224 Apr 23, 2025
19142e7
Merge remote-tracking branch 'ouch-cs/main' into feat/#36/self-diagnosis
kdy2224 Apr 24, 2025
5406415
Merge remote-tracking branch 'ouch-cs/main' into feat/#36/self-diagnosis
kdy2224 Apr 25, 2025
2c087be
[CHORE] SelfSymptom -> DiagnosisSymptom(이름변경)에 따른 수정사항 수정
kdy2224 Apr 25, 2025
f6969f9
[CHORE] SelfDiagnosisConverter 일부 메서드 이름 수정
kdy2224 Apr 26, 2025
cb44a53
[REFACT] 자가진단 수정하는 경우 tobuilder에서 user값을 받을 필요 없음, createAt 또한 엔티티 어노…
99hyuk Apr 27, 2025
e5cfa6c
[REFACT] 변수명 수정
99hyuk Apr 27, 2025
7346d74
[REFACT] SelfDiagnosis 엔티티 내 @SuperBuilder -> @Builder 로 수정 (상속 없음)
99hyuk Apr 27, 2025
67b38e9
[REFACT] BaseEntity에 빌더 패턴 필요 없음
99hyuk Apr 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.onebridge.ouch.apiPayload.code.error;

import org.springframework.http.HttpStatus;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum DiagnosisErrorCode implements ErrorCode {

USER_NOT_FOUND(HttpStatus.NOT_FOUND, "DIAGNOSIS400", "User not found."),
SYMPTOM_NOT_FOUND(HttpStatus.NOT_FOUND, "DIAGNOSIS401", "Symptom not found."),
DIAGNOSIS_NOT_FOUND(HttpStatus.NOT_FOUND, "DIAGNOSIS402", "Diagnosis not found."),
SYMPTOM_ALREADY_ADDED(HttpStatus.BAD_REQUEST, "DIAGNOSIS403", "Symptom already added."),
;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

설명 한글로 바꿔주세요. 그리고 USER_NOT_FOUND는 CommonErrorCode 파일에 이미 있으므로 거기서 가져와서 쓰면 좋을 것 같습니다. 유저 관련은 CommonErrorCode로 다른 코드 다 바꿔주세요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

반영했습니다:)


private final HttpStatus httpStatus;
private final String code;
private final String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.onebridge.ouch.apiPayload.code.error;

import org.springframework.http.HttpStatus;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum UserErrorCode implements ErrorCode {

USER_NOT_FOUND(HttpStatus.NOT_FOUND, "USER400", "User not found."),
;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

UserErrorCode 파일은 일단 없에주세요

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

반영했습니다:)


private final HttpStatus httpStatus;
private final String code;
private final String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.onebridge.ouch.controller.selfDiagnosis;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.onebridge.ouch.apiPayload.ApiResponse;
import com.onebridge.ouch.dto.selfDiagnosis.request.AddSymptomsToDiagnosisRequest;
import com.onebridge.ouch.dto.selfDiagnosis.request.DiagnosisCreateRequest;
import com.onebridge.ouch.dto.selfDiagnosis.request.DiagnosisUpdateRequest;
import com.onebridge.ouch.dto.selfDiagnosis.response.DiagnosisCreateResponseDetailed;
import com.onebridge.ouch.dto.selfDiagnosis.response.DiagnosisUpdateResponse;
import com.onebridge.ouch.dto.selfDiagnosis.response.GetDiagnosisByUserIdResponse;
import com.onebridge.ouch.dto.selfDiagnosis.response.GetDiagnosisResponse;
import com.onebridge.ouch.dto.selfDiagnosis.response.GetSymptomsOfDiagnosisResponse;
import com.onebridge.ouch.security.authorization.UserId;
import com.onebridge.ouch.service.selfDiagnosis.SelfDiagnosisService;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/self-diagnosis")
@RequiredArgsConstructor
public class SelfDiagnosisController {

private final SelfDiagnosisService selfDiagnosisService;

//자가진단표 생성
@PostMapping
public ResponseEntity<ApiResponse<DiagnosisCreateResponseDetailed>> createDiagnosis( //request dto 에 userid 지우기
@RequestBody @Valid DiagnosisCreateRequest request,
@UserId Long userId
) {
DiagnosisCreateResponseDetailed response = selfDiagnosisService.createDiagnosis(request, userId);
return ResponseEntity.ok(ApiResponse.created(response));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Post하는 데 응답이 필요 없어서 DiagnosisCreateResponseDetailed 파일 지워주시고, ResponseEntity.ok(ApiResponse.successWithNoData()); 리턴하시면 될 것 같습니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

반영했습니다:)


//(자가진단표)id로 자가진단표 조회
@GetMapping("/{diagnosisId}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

유저 정보를 파싱하는 식으로 하시지 않으셨는데, 특정 유저가 자기의 특정 자가진단을 보는 것을 의도하셨으면 밑처럼 @AuthenticationPrincipal 통해 유저 정보를 받아와야 합니다

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

확인했습니다

public ResponseEntity<ApiResponse<GetDiagnosisResponse>> getDiagnosisById(
@PathVariable Long diagnosisId,
@UserId Long userId
) {
GetDiagnosisResponse response = selfDiagnosisService.getDiagnosis(diagnosisId, userId);
return ResponseEntity.ok(ApiResponse.success(response));
}

//사용자 모든 자가진단표 조회
@GetMapping
public ResponseEntity<ApiResponse<List<GetDiagnosisByUserIdResponse>>> getAllDiagnosisByUserId(
@UserId Long userId
) {
List<GetDiagnosisByUserIdResponse> list = selfDiagnosisService.getAllDiagnosisByUserId(userId);
return ResponseEntity.ok(ApiResponse.success(list));
}

//자가진단표 삭제
@DeleteMapping("/{diagnosisId}")
public ResponseEntity<ApiResponse<Void>> deleteDiagnosis(@PathVariable Long diagnosisId,
@UserId Long userId
) {
selfDiagnosisService.deleteDiagnosis(diagnosisId, userId);
return ResponseEntity.ok(ApiResponse.successWithNoData());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

자기 자가진단만 삭제할 수 있도록 유저 정보를 파싱해서 받아야 합니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

확인했습니다


//특정 자가진단표의 증상 목록 조회
@GetMapping("/{diagnosisId}/symptoms")
public ResponseEntity<ApiResponse<GetSymptomsOfDiagnosisResponse>> getSymptomsOfDiagnosis(
@PathVariable Long diagnosisId,
@UserId Long userId
) {
GetSymptomsOfDiagnosisResponse response = selfDiagnosisService.getSymptomsOfDiagnosis(diagnosisId, userId);
return ResponseEntity.ok(ApiResponse.success(response));
}

//자가진단표 수정
@PutMapping("/{diagnosisId}")
public ResponseEntity<ApiResponse<DiagnosisUpdateResponse>> updateDiagnosis(@PathVariable Long diagnosisId,
@RequestBody @Valid DiagnosisUpdateRequest request,
@UserId Long userId
) {
DiagnosisUpdateResponse response = selfDiagnosisService.updateDiagnosis(diagnosisId, userId, request);
return ResponseEntity.ok(ApiResponse.success(response));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

여기도 응답 없에주세요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

반영했습니다:)


//자가진단표에 증상 추가
@PostMapping("/{diagnosisId}/symptoms")
public ResponseEntity<ApiResponse<Void>> addSymptomsToSelfDiagnosis(@PathVariable Long diagnosisId,
@RequestBody @Valid AddSymptomsToDiagnosisRequest request,
@UserId Long userId
) {
selfDiagnosisService.addSymptomsToSelfDiagnosis(diagnosisId, request, userId);
return ResponseEntity.ok(ApiResponse.successWithNoData());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이것도 유저 정보를 받는 식으로 하셔야 합니다. 그래야 보안상으로 안전합니다.
URI도 /{diagnosisId}/symptoms으로 바꾸시면 좋을 것 같습니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

확인했습니다

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.onebridge.ouch.controller.symptom;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.onebridge.ouch.apiPayload.ApiResponse;
import com.onebridge.ouch.dto.symptom.response.GetSymptomResponse;
import com.onebridge.ouch.service.symptom.SymptomService;

import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/symptoms")
@RequiredArgsConstructor
public class SymptomController {

private final SymptomService symptomService;

//증상 목록 조회
@GetMapping
public ResponseEntity<ApiResponse<List<GetSymptomResponse>>> getSymptomsList() {
List<GetSymptomResponse> list = symptomService.getSymptomsList();
return ResponseEntity.ok(ApiResponse.success(list));
}
}
Original file line number Diff line number Diff line change
@@ -1,83 +1,58 @@
package com.onebridge.ouch.controller.user;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.onebridge.ouch.dto.MessageResponse;
import com.onebridge.ouch.dto.MessageResponseDetailed;
import com.onebridge.ouch.dto.user.request.MypageUserInfoUpdateRequest;
import com.onebridge.ouch.dto.user.response.MypageUserInfoResponse;
import com.onebridge.ouch.apiPayload.ApiResponse;
import com.onebridge.ouch.dto.user.response.UserInfoResponse;
import com.onebridge.ouch.security.userDetail.OuchUserDetails;
import com.onebridge.ouch.service.user.UserService;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api")
@RequestMapping("/user")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

users로 바꿔주세요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

반영했습니다:)

@RequiredArgsConstructor
public class UserController {

private final UserService userService;

public UserController(UserService userService) {
this.userService = userService;
}

//유저 조회(테스트용)
@GetMapping("/users/{userId}")
public UserInfoResponse getUserInfo(@PathVariable Long userId) {
return userService.getUserInfo(userId);
// @GetMapping("/{userId}") //테스트를 위해 주석으로 남겨두겠습니다.
@GetMapping
public ResponseEntity<ApiResponse<UserInfoResponse>> getUserInfo(
// @PathVariable Long userId
@AuthenticationPrincipal OuchUserDetails userDetails) {
Long userId = userDetails.getDatabaseId();
UserInfoResponse response = userService.getUserInfo(userId);
return ResponseEntity.ok(ApiResponse.success(response));
}

//유저 탈퇴(비활성화)
@PatchMapping("/users/{userId}")
public ResponseEntity<?> deactivateUser(@PathVariable Long userId) {
// @PatchMapping("/{userId}")
@PatchMapping
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

delete로 바꿔주세요. 바꿔도 저희 내부 로직은 그대로이고, 프론트엔드가 의미를 직관적으로 이해하는 게 중요해서 그렇습니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

반영했습니다:)

public ResponseEntity<ApiResponse<Void>> deactivateUser(
// @PathVariable Long userId
@AuthenticationPrincipal OuchUserDetails userDetails) {
Long userId = userDetails.getDatabaseId();
userService.deactivateUser(userId);
MessageResponse body = new MessageResponse("Your account has been deactivated.");
HttpHeaders header = new HttpHeaders();
header.add(HttpHeaders.CONTENT_TYPE, "application/json");

return new ResponseEntity<>(body, header, HttpStatus.OK);
return ResponseEntity.ok(ApiResponse.successWithNoData());
}

//유저 삭제(테스트용)
@DeleteMapping("/users/{userId}")
public ResponseEntity<?> deleteUser(@PathVariable Long userId) {
// @DeleteMapping("/{userId}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

삭제 API는 없어도 될 것 같습니다. 없에주시면 감사하겠습니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이에 맞춰서 서비스 로직도 수정해주세요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

반영했습니다:)

@DeleteMapping
public ResponseEntity<ApiResponse<Void>> deleteUser(
// @PathVariable Long userId
@AuthenticationPrincipal OuchUserDetails userDetails) {
Long userId = userDetails.getDatabaseId();
userService.deleteUser(userId);
MessageResponse body = new MessageResponse("Your account has been deleted.");
HttpHeaders header = new HttpHeaders();
header.add(HttpHeaders.CONTENT_TYPE, "application/json");

return new ResponseEntity<>(body, header, HttpStatus.OK);
}

//마이페이지(내 정보) 조회
@GetMapping("/mypage/users/{userId}")
public MypageUserInfoResponse myPageGetUserInfo(@PathVariable Long userId) {
return userService.myPageGetUserInfo(userId);
}

//내 정보 수정 (사용자로부터 모든 필드의 값을 받아 put 요청 처리)
@PutMapping("/mypage/users/{userId}")
public ResponseEntity<MessageResponseDetailed<String>> myPageUpdateUserInfo(@PathVariable Long userId,
@RequestBody @Valid MypageUserInfoUpdateRequest request) {
// System.out.println("userId = " + userId);
userService.myPageUpdateUserInfo(userId, request);
MessageResponseDetailed<String> body = new MessageResponseDetailed<>(
true,
"COMMON200",
"요청이 성공적으로 처리되었습니다.",
"유저 정보가 성공적으로 수정되었습니다."
);
return ResponseEntity.ok(body);
return ResponseEntity.ok(ApiResponse.successWithNoData());
}
}

Expand Down
109 changes: 109 additions & 0 deletions src/main/java/com/onebridge/ouch/converter/SelfDiagnosisConverter.java
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dto <-> 엔티티 양방향 변환을 의도하신 걸로 보이는데, 전반적으로 메소드명을 2를 붙여서 구분하기 보단 좀 더 직관적으로 바꾸시면 좋을 것 같습니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

확인했습니다

Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package com.onebridge.ouch.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

import com.onebridge.ouch.domain.SelfDiagnosis;
import com.onebridge.ouch.domain.Symptom;
import com.onebridge.ouch.domain.User;
import com.onebridge.ouch.domain.mapping.SelfSymptom;
import com.onebridge.ouch.domain.mapping.compositeKey.DiagnosisSymptomPK;
import com.onebridge.ouch.dto.selfDiagnosis.request.DiagnosisCreateRequest;
import com.onebridge.ouch.dto.selfDiagnosis.request.DiagnosisUpdateRequest;
import com.onebridge.ouch.dto.selfDiagnosis.response.DiagnosisCreateResponse;
import com.onebridge.ouch.dto.selfDiagnosis.response.DiagnosisCreateResponseDetailed;
import com.onebridge.ouch.dto.selfDiagnosis.response.DiagnosisUpdateResponse;
import com.onebridge.ouch.dto.selfDiagnosis.response.GetDiagnosisByUserIdResponse;
import com.onebridge.ouch.dto.selfDiagnosis.response.GetDiagnosisResponse;
import com.onebridge.ouch.dto.selfDiagnosis.response.GetSymptomsOfDiagnosisResponse;

@Component
public class SelfDiagnosisConverter {

public DiagnosisUpdateResponse diagnosisToDiagnosisUpdateResponse(SelfDiagnosis updatedDiagnosis) {
List<String> symptoms = new ArrayList<>();
for (SelfSymptom symptom : updatedDiagnosis.getSelfSymptomList()) {
symptoms.add(symptom.getSymptom().getName());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

List symptoms = new ArrayList<>();
for (SelfSymptom symptom : updatedDiagnosis.getSelfSymptomList()) {
symptoms.add(symptom.getSymptom().getName());
}
이 코드가 굉장히 많이 반복되는데 메소드를 따로 뽑아내도 좋을 것 같습니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

반영했습니다:)

return new DiagnosisUpdateResponse(updatedDiagnosis.getId(), updatedDiagnosis.getVisitType(), symptoms,
updatedDiagnosis.getDuration(), updatedDiagnosis.getPainSeverity(), updatedDiagnosis.getAdditionalNote(),
updatedDiagnosis.getCreatedAt().toString());
}

public DiagnosisCreateResponseDetailed diagnosisToDiagnosisCreateResponseDetailed(SelfDiagnosis diagnosis) {
List<String> symotimList = new ArrayList<>();
for (SelfSymptom symptom : diagnosis.getSelfSymptomList()) {
symotimList.add(symptom.getSymptom().getName());
}
return new DiagnosisCreateResponseDetailed(diagnosis.getId(),
diagnosis.getVisitType(), symotimList, diagnosis.getDuration(), diagnosis.getPainSeverity(),
diagnosis.getAdditionalNote(), diagnosis.getCreatedAt().toString());
}

public DiagnosisCreateResponse diagnosisToDiagnosisCreateResponse(SelfDiagnosis diagnosis) {
return new DiagnosisCreateResponse(diagnosis.getId(), "Self-diagnosis submitted successfully.");
}

public GetDiagnosisResponse diagnosisToGetDiagnosisResponse(SelfDiagnosis diagnosis) {
List<String> selfSymotimList = new ArrayList<>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

리스트 변수명이 잘못된 것 같습니다. symtomList로 고쳐야 할 것 같아요

Copy link
Copy Markdown
Contributor Author

@kdy2224 kdy2224 Apr 23, 2025

Choose a reason for hiding this comment

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

넵 바꾸는게 맞는거 같습니다:)

for (SelfSymptom symptom : diagnosis.getSelfSymptomList()) {
selfSymotimList.add(symptom.getSymptom().getName());
}
return new GetDiagnosisResponse(diagnosis.getUser().getId(), diagnosis.getVisitType(), selfSymotimList,
diagnosis.getDuration(),
diagnosis.getPainSeverity(), diagnosis.getAdditionalNote(), diagnosis.getCreatedAt().toString());
}

public GetDiagnosisByUserIdResponse diagnosisToGetDiagnosisByUserIdResponse(SelfDiagnosis diagnosis) {
List<String> selfSymotimList = new ArrayList<>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

리스트 변수명이 잘못된 것 같습니다. symtomList로 고쳐야 할 것 같아요

Copy link
Copy Markdown
Contributor Author

@kdy2224 kdy2224 Apr 23, 2025

Choose a reason for hiding this comment

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

아 바꾸는게 맞는거 같습니다!

for (SelfSymptom symptom : diagnosis.getSelfSymptomList()) {
selfSymotimList.add(symptom.getSymptom().getName());
}
return new GetDiagnosisByUserIdResponse(diagnosis.getId(), diagnosis.getVisitType(), selfSymotimList,
diagnosis.getDuration(), diagnosis.getPainSeverity(), diagnosis.getAdditionalNote(),
diagnosis.getCreatedAt().toString());
}

public GetSymptomsOfDiagnosisResponse diagnosisToGetSymptomsOfDiagnosisResponse(SelfDiagnosis diagnosis) {
List<String> symptoms = new ArrayList<>();
for (SelfSymptom symptom : diagnosis.getSelfSymptomList()) {
symptoms.add(symptom.getSymptom().getName());
}
return new GetSymptomsOfDiagnosisResponse(symptoms);
}

public SelfDiagnosis DiagnosisCreateRequestToSelfDiagnosis(DiagnosisCreateRequest request, User user) {
return SelfDiagnosis.builder()
.user(user)
.visitType(request.getVisitType())
.selfSymptomList(new ArrayList<>())
.duration(request.getDuration())
.painSeverity(request.getPainSeverity())
.additionalNote(request.getAdditionalNote())
.build();
}

public SelfSymptom SelfSymptomWithSelfDiagnosis(SelfDiagnosis selfDiagnosis, Symptom foundSymptom) {
return SelfSymptom.builder()
.selfDiagnosis(selfDiagnosis)
.symptom(foundSymptom)
.diagnosisSymptomPk(new DiagnosisSymptomPK(selfDiagnosis.getId(),
foundSymptom.getId()))
.build();
}

public SelfDiagnosis DiagnosisUpdateRequestToSelfDiagnosis(SelfDiagnosis diagnosis, User user,
DiagnosisUpdateRequest request) {
return diagnosis.toBuilder()
.user(user)
.visitType(request.getVisitType())
.selfSymptomList(new ArrayList<>())
.duration(request.getDuration())
.painSeverity(request.getPainSeverity())
.additionalNote(request.getAdditionalNote())
.createdAt(diagnosis.getCreatedAt())
.build();
}
}
Loading