Skip to content

Commit

Permalink
[Refactor] 한줄처방 수정하는 로직 변경 (#155)
Browse files Browse the repository at this point in the history
* [Refactor] 비즈니스로직 성공적으로 동작시 'success' 응답하도록 수정

* [Refactor] 한줄처방 수정 로직에서 키워드도 변경 가능하도록 작성
  • Loading branch information
seonghooni authored May 22, 2024
1 parent 4cd3042 commit 57f2186
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,21 @@ public ResponseEntity<OneLineResponseDto> getOneLinePrescription(@PathVariable(v

@Operation(summary = "한줄처방을 수정할때 요청")
@PutMapping("/{prescriptionId}")
public ResponseEntity<Void> updateOneLinePrescription(@PathVariable(value = "prescriptionId") Long prescriptionId,
public ResponseEntity<String> updateOneLinePrescription(@PathVariable(value = "prescriptionId") Long prescriptionId,
@RequestBody OneLineUpdateDto oneLineUpdateDto,
@AuthenticationPrincipal UserDetails userDetails) {
oneLinePrescriptionService.updateOneLinePrescription(prescriptionId, oneLineUpdateDto, (AuthenticationAdapter) userDetails);

return ResponseEntity.ok().build();
return ResponseEntity.ok("success");
}

@Operation(summary = "한줄처방을 삭제할 때 요청")
@DeleteMapping("/{prescriptionId}")
public ResponseEntity<Void> deleteOneLinePrescription(@PathVariable(value = "prescriptionId") Long prescriptionId,
public ResponseEntity<String> deleteOneLinePrescription(@PathVariable(value = "prescriptionId") Long prescriptionId,
@AuthenticationPrincipal UserDetails userDetails) {
oneLinePrescriptionService.deleteOneLinePrescription(prescriptionId, (AuthenticationAdapter) userDetails);

return ResponseEntity.ok().build();
return ResponseEntity.ok("success");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,6 @@ public void setDescription(String description){
public void setBook(Book book){
this.book = book;
}

public void setKeyword(Keyword keyword) { this.keyword = keyword; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import kr.KWGraduate.BookPharmacy.domain.book.domain.Book;
import kr.KWGraduate.BookPharmacy.domain.client.domain.Client;
import kr.KWGraduate.BookPharmacy.domain.keyword.domain.Keyword;
import kr.KWGraduate.BookPharmacy.domain.onelineprescription.domain.OneLinePrescription;
import lombok.Builder;
import lombok.Data;
Expand All @@ -15,6 +16,7 @@ public class OneLineResponseDto {
private Long id;
private String title;
private String description;
private Keyword keyword;
private String bookTitle;
private String bookIsbn;
private String bookAuthor;
Expand All @@ -25,11 +27,12 @@ public class OneLineResponseDto {
private LocalDate createdDate;

@Builder
public OneLineResponseDto(Long id, String title, String description, String bookTitle, String bookIsbn, String bookAuthor, String bookImageUrl,
public OneLineResponseDto(Long id, String title, String description, Keyword keyword, String bookTitle, String bookIsbn, String bookAuthor, String bookImageUrl,
String bookPublishYear, String bookPublishingHouse) {
this.id = id;
this.title = title;
this.description = description;
this.keyword = keyword;
this.bookTitle = bookTitle;
this.bookIsbn = bookIsbn;
this.bookAuthor = bookAuthor;
Expand Down Expand Up @@ -67,6 +70,7 @@ private OneLineResponseDto setOneLinePrescriptionAttr(OneLinePrescription oneLin
this.id = oneLinePrescription.getId();
this.title = oneLinePrescription.getTitle();
this.description = oneLinePrescription.getDescription();
this.keyword = oneLinePrescription.getKeyword();
this.createdDate = oneLinePrescription.getCreatedDate().toLocalDate();

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void updateOneLinePrescription(Long oneLinePrescriptionId, OneLineUpdateD

oneLinePrescription.setTitle(oneLineUpdateDto.getTitle());
oneLinePrescription.setDescription(oneLineUpdateDto.getDescription());
oneLinePrescription.setKeyword(oneLineUpdateDto.getKeyword());
oneLinePrescription.setBook(book);

oneLinePrescriptionRepository.flush();
Expand Down

0 comments on commit 57f2186

Please sign in to comment.