-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
834aacf
commit 320a7f3
Showing
5 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...java/net/skhu/tastyinventory_be/controller/inventoryVolume/InventoryVolumeController.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,33 @@ | ||
package net.skhu.tastyinventory_be.controller.inventoryVolume; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import net.skhu.tastyinventory_be.domain.inventoryVolume.InventoryVolume; | ||
import net.skhu.tastyinventory_be.dto.InventoryVolumeRequestDto; | ||
import net.skhu.tastyinventory_be.service.inventoryVolume.InventoryVolumeService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/inventory-volume") | ||
@RestController | ||
public class InventoryVolumeController { | ||
|
||
private final InventoryVolumeService inventoryVolumeService; | ||
|
||
@PostMapping | ||
public ResponseEntity<?> createInventoryVolume(@RequestBody InventoryVolumeRequestDto requestDto) { | ||
InventoryVolume inventoryVolume = inventoryVolumeService.create(requestDto); | ||
return ResponseEntity.ok().body(inventoryVolume); | ||
} | ||
@PutMapping("{id}") | ||
public ResponseEntity<?> updateInventoryVolume(@PathVariable("id") Long id, @RequestBody InventoryVolumeRequestDto requestDto) { | ||
InventoryVolume inventoryVolume = inventoryVolumeService.update(id, requestDto); | ||
return ResponseEntity.ok().body(inventoryVolume); | ||
} | ||
|
||
@GetMapping("{id}") | ||
public ResponseEntity<?> getInventoryVolume(@PathVariable("id") Long id) { | ||
InventoryVolume inventoryVolume = inventoryVolumeService.findById(id); | ||
return ResponseEntity.ok().body(inventoryVolume); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...ain/java/net/skhu/tastyinventory_be/domain/inventoryVolume/InventoryVolumeRepository.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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package net.skhu.tastyinventory_be.domain.inventoryVolume; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface InventoryVolumeRepository extends JpaRepository<InventoryVolume, Long> { | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/net/skhu/tastyinventory_be/dto/InventoryVolumeRequestDto.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,37 @@ | ||
package net.skhu.tastyinventory_be.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.Date; | ||
|
||
@Getter | ||
public class InventoryVolumeRequestDto { | ||
private Date weekStart; | ||
private Integer friInventory; | ||
private Integer sunInventory; | ||
private Integer monOrder; | ||
private Integer tueOrder; | ||
private Integer wedOrder; | ||
private Integer thuOrder; | ||
private Integer friOrder; | ||
private Integer satOrder; | ||
private Integer sunOrder; | ||
private Long inventoryId; | ||
|
||
@Builder | ||
public InventoryVolumeRequestDto(Date weekStart, Integer friInventory, Integer sunInventory, Integer monOrder, | ||
Integer tueOrder, Integer wedOrder, Integer thuOrder, Integer friOrder, Integer satOrder, Integer sunOrder, Long inventoryId){ | ||
this.weekStart = weekStart; | ||
this.friInventory = friInventory; | ||
this.sunInventory = sunInventory; | ||
this.monOrder = monOrder; | ||
this.tueOrder = tueOrder; | ||
this.wedOrder = wedOrder; | ||
this.thuOrder = thuOrder; | ||
this.satOrder = satOrder; | ||
this.friOrder = friOrder; | ||
this.sunOrder = sunOrder; | ||
this.inventoryId = inventoryId; | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
src/main/java/net/skhu/tastyinventory_be/service/inventoryVolume/InventoryVolumeService.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,35 @@ | ||
package net.skhu.tastyinventory_be.service.inventoryVolume; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import net.skhu.tastyinventory_be.domain.inventoryVolume.InventoryVolume; | ||
import net.skhu.tastyinventory_be.domain.inventoryVolume.InventoryVolumeRepository; | ||
import net.skhu.tastyinventory_be.dto.InventoryVolumeRequestDto; | ||
import net.skhu.tastyinventory_be.exception.model.NotFoundException; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import static net.skhu.tastyinventory_be.exception.ErrorCode.REQUEST_VALIDATION_EXCEPTION; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class InventoryVolumeService { | ||
|
||
@Autowired // μ΄λ Έν μ΄μ νμΈ | ||
private final InventoryVolumeRepository inventoryVolumeRepository; | ||
|
||
public InventoryVolume create(InventoryVolumeRequestDto requestDto) { | ||
InventoryVolume inventoryVolume = new InventoryVolume(); | ||
return inventoryVolume; | ||
} | ||
|
||
public InventoryVolume update(Long id, InventoryVolumeRequestDto requestDto) { | ||
InventoryVolume inventoryVolume = findById(id); | ||
return inventoryVolume; | ||
} | ||
|
||
public InventoryVolume findById(Long id) { | ||
return inventoryVolumeRepository.findById(id) | ||
.orElseThrow(() -> new NotFoundException(REQUEST_VALIDATION_EXCEPTION, "Inventory volume not found with id: ")); //μλ¬ μ½λ λ§λμ§ νμΈ | ||
} | ||
|
||
} |