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

[Refactor] 한줄처방 수정하는 로직 변경 #155

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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