-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from UPbrella/dev
0.5.0 release-dev
- Loading branch information
Showing
15 changed files
with
446 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/upbrella/be/rent/exception/CannotBeRentedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package upbrella.be.rent.exception; | ||
|
||
public class CannotBeRentedException extends RuntimeException { | ||
|
||
public CannotBeRentedException(String message) { | ||
|
||
super(message); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/upbrella/be/store/controller/LockerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package upbrella.be.store.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import upbrella.be.rent.service.LockerService; | ||
import upbrella.be.store.dto.request.CreateLockerRequest; | ||
import upbrella.be.store.dto.request.UpdateLockerRequest; | ||
import upbrella.be.store.dto.response.AllLockerResponse; | ||
import upbrella.be.util.CustomResponse; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class LockerController { | ||
|
||
private final LockerService lockerService; | ||
|
||
@GetMapping("/admin/lockers") | ||
public ResponseEntity<CustomResponse<AllLockerResponse>> getLockers() { | ||
|
||
AllLockerResponse lockers = lockerService.findAll(); | ||
|
||
return ResponseEntity | ||
.ok() | ||
.body(new CustomResponse<>( | ||
"success", | ||
200, | ||
"보관함 조회 성공", | ||
lockers)); | ||
} | ||
|
||
@PostMapping("/admin/lockers") | ||
public ResponseEntity<CustomResponse<Void>> createLocker(@RequestBody CreateLockerRequest request) { | ||
|
||
lockerService.createLocker(request); | ||
|
||
return ResponseEntity | ||
.ok() | ||
.body(new CustomResponse<>( | ||
"success", | ||
200, | ||
"보관함 생성 성공", | ||
null)); | ||
} | ||
|
||
@PatchMapping("/admin/lockers/{lockerId}") | ||
public ResponseEntity<CustomResponse<Void>> updateLocker(@PathVariable Long lockerId, @RequestBody UpdateLockerRequest request) { | ||
|
||
lockerService.updateLocker(lockerId, request); | ||
|
||
return ResponseEntity | ||
.ok() | ||
.body(new CustomResponse<>( | ||
"success", | ||
200, | ||
"보관함 업데이트 성공", | ||
null)); | ||
} | ||
|
||
@DeleteMapping("/admin/lockers/{lockerId}") | ||
public ResponseEntity<CustomResponse<Void>> deleteLocker(@PathVariable Long lockerId) { | ||
|
||
lockerService.deleteLocker(lockerId); | ||
|
||
return ResponseEntity | ||
.ok() | ||
.body(new CustomResponse<>( | ||
"success", | ||
200, | ||
"보관함 삭제 성공", | ||
null)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/upbrella/be/store/controller/LockerExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package upbrella.be.store.controller; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
import upbrella.be.util.CustomErrorResponse; | ||
|
||
@RestControllerAdvice | ||
public class LockerExceptionHandler { | ||
|
||
@ExceptionHandler(IllegalArgumentException.class) | ||
public ResponseEntity<CustomErrorResponse> nonExistingStoreDetail(IllegalArgumentException ex) { | ||
|
||
return ResponseEntity | ||
.badRequest() | ||
.body(new CustomErrorResponse( | ||
"bad request", | ||
400, | ||
ex.getMessage())); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/upbrella/be/store/dto/request/CreateLockerRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package upbrella.be.store.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CreateLockerRequest { | ||
|
||
private long storeId; | ||
private String secretKey; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/upbrella/be/store/dto/request/UpdateLockerRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package upbrella.be.store.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class UpdateLockerRequest { | ||
|
||
private long storeId; | ||
private String secretKey; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/upbrella/be/store/dto/response/AllLockerResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package upbrella.be.store.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AllLockerResponse { | ||
|
||
private List<SingleLockerResponse> lockers; | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/upbrella/be/store/dto/response/SingleLockerResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package upbrella.be.store.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import upbrella.be.rent.entity.Locker; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SingleLockerResponse { | ||
|
||
private long id; | ||
private long storeMetaId; | ||
private String secretKey; | ||
|
||
public static SingleLockerResponse fromLocker(Locker locker) { | ||
|
||
return SingleLockerResponse.builder() | ||
.id(locker.getId()) | ||
.storeMetaId(locker.getStoreMeta().getId()) | ||
.secretKey(locker.getSecretKey()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.