Skip to content

Commit

Permalink
Merge pull request #64 from Team-KeepGoing/refactor
Browse files Browse the repository at this point in the history
Refactor :: code refactor
  • Loading branch information
miraexhoi authored Jul 3, 2024
2 parents a4d5cee + 1b39b2d commit 71bba86
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package com.keepgoing.keepserver.domain.book.payload.request;

import com.keepgoing.keepserver.domain.book.entity.enums.BookState;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter
public class BookDto {
private long id;
private String bookName;
private String writer;
private String imageUrl;
private String nfcCode;
private LocalDateTime registrationDate;
private LocalDateTime rentDate;
private BookState state;
@Builder
public record BookDto (
Long id,
String bookName,
String writer,
String imageUrl,
String nfcCode,
LocalDateTime registrationDate,
LocalDateTime rentDate,
BookState state
) {
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.keepgoing.keepserver.domain.book.payload.request;

import com.keepgoing.keepserver.domain.book.entity.enums.BookState;
import lombok.Builder;
import lombok.Getter;

@Getter
public class BookRequestDto {
private String name;
private String nfcCode;
private String imageUrl;
private BookState state;
@Builder
public record BookRequestDto (
String name,
String nfcCode,
String imageUrl,
BookState state
){
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
public interface BookRepository extends JpaRepository<Book, Long> {
Book findBookByNfcCode(String NfcCode);
Optional<Book> findBookByNfcCodeContaining(String NfcCode);
Optional<Book> findByBookName(String bookName);
List<Book> findByBorrower(User borrower);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public BaseResponse editDevice(Long id, DeviceEditRequest deviceEditRequest) {
}

public User findUserByEmail(String email) {
return userRepository.findByEmail(email).orElseThrow(() -> new DeviceException(DeviceError.USER_NOT_FOUND));
return userRepository.findByEmail(email)
.orElseThrow(DeviceException::userNotFound);
}

private Device findDeviceById(Long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
@RequestMapping("/rent")
@RequiredArgsConstructor
public class RentController {

private final RentService rentService;

@Operation(summary = "기자재 대여", description = "기자재를 대여합니다.")
@PostMapping("/device")
public BaseResponse rentDevice(@RequestParam String deviceName, @RequestParam String email) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@RequestMapping("/return")
@RequiredArgsConstructor
public class ReturnController {

private final ReturnService returnService;

@Operation(summary = "기자재 반납", description = "기자재 이름과 이메일을 통해 기자재를 반납합니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public BaseResponse findByStudentNum(StudentFindDto studentDto) {
}
}

public BaseResponse editStudent(StudentRequestDto studentDto,Long id) {
public BaseResponse editStudent(StudentRequestDto studentDto, Long id) {
Student studentEntity = studentRepository.findStudentById(id);
if (studentDto.getStudentName() != null) studentEntity.setStudentName(studentDto.getStudentName());
if (studentDto.getPhoneNum() != null) studentEntity.setPhoneNum(studentDto.getPhoneNum());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static BookException bookNotAvailable() {
public static BookException imageUploadFailed() {
return IMAGE_UPLOAD_FAILED;
}
public static BookException invalidborrower() {
public static BookException invalidBorrower() {
return INVALID_BORROWER;
}
}

0 comments on commit 71bba86

Please sign in to comment.