Skip to content

Commit

Permalink
Fix: 경로 충돌 해결 및 Recipe - usage컬럼명 변경(#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinheekim committed May 6, 2024
1 parent 8058a34 commit a6e7e12
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public List<Inventory> getAllInventory(){
public Inventory getInventoryById(@PathVariable("inventoryId") Long inventoryId) {
return inventoryService.findById(inventoryId);
}
@GetMapping
@GetMapping("/search")
public List<Inventory> search(@RequestParam(value = "srchText", required = false) String srchText) {
if (srchText != null && !srchText.isEmpty()) {
return inventoryService.searchByName(srchText);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package net.skhu.tastyinventory_be.domain.inventory;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@Table(name = "inventory")
@AllArgsConstructor
@Builder
@Entity
public class Inventory {
@Id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.skhu.tastyinventory_be.domain.inventory;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface InventoryRepository extends JpaRepository<Inventory, Long> {
// Inventory findByName(String name);
List<Inventory> findByNameContaining(String name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public class Recipe {
// private Inventory inventory;

@Column(nullable = false)
private Integer usage; //재료 사용량
private Integer usages; //재료 사용량

@Builder
public Recipe(Integer usage) { //Menu menu, Inventory inventory,
public Recipe(Integer usages) { //Menu menu, Inventory inventory,
// this.menu = menu;
// this.inventory = inventory;
this.usage = usage;
this.usages = usages;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public InventorySaveRequestDto(String name, String unit, String imageUrl) {
}
public Inventory toEntity(){
return Inventory.builder()
.id(id)
.name(name)
.unit(unit)
.imageUrl(imageUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class InventoryService {
public Long save(InventorySaveRequestDto requestDto){
return inventoryRepository.save(requestDto.toEntity()).getId();
}

public List<Inventory> findAll(){
return inventoryRepository.findAll();
}
Expand All @@ -41,6 +42,7 @@ public void update(Long id, InventoryUpdateRequestDto requestDto) {
inventory.update(requestDto.getName(), requestDto.getUnit(), requestDto.getImageUrl());
}


@Transactional
public void delete(Long id) {
Inventory inventory = inventoryRepository.findById(id)
Expand Down

0 comments on commit a6e7e12

Please sign in to comment.