diff --git a/src/main/java/dev/nmarulo/depensaapp/app/products/dtos/SaveShoppingListProductReq.java b/src/main/java/dev/nmarulo/depensaapp/app/products/dtos/SaveShoppingListProductReq.java index 8bc4108..3219c90 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/products/dtos/SaveShoppingListProductReq.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/products/dtos/SaveShoppingListProductReq.java @@ -7,10 +7,10 @@ public class SaveShoppingListProductReq { private Long productId; - private Integer shoppingListId; + private Long shoppingListId; private Integer unitsPerProduct; - private Integer unitTypeId; + private Long unitTypeId; } diff --git a/src/main/java/dev/nmarulo/depensaapp/app/products/dtos/SaveShoppingListProductRes.java b/src/main/java/dev/nmarulo/depensaapp/app/products/dtos/SaveShoppingListProductRes.java index 219802f..ee13f1c 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/products/dtos/SaveShoppingListProductRes.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/products/dtos/SaveShoppingListProductRes.java @@ -24,7 +24,7 @@ public class SaveShoppingListProductRes { @NoArgsConstructor public static class ShoppingList { - private Integer id; + private Long id; private String name; @@ -48,7 +48,7 @@ public static class Product { @NoArgsConstructor public static class UnitType { - private Integer id; + private Long id; private String name; diff --git a/src/main/java/dev/nmarulo/depensaapp/app/productshoppinglist/ProductHasShoppingListPK.java b/src/main/java/dev/nmarulo/depensaapp/app/productshoppinglist/ProductHasShoppingListPK.java index 401126e..2b3a792 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/productshoppinglist/ProductHasShoppingListPK.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/productshoppinglist/ProductHasShoppingListPK.java @@ -21,10 +21,10 @@ public class ProductHasShoppingListPK implements Serializable { private Long productId; @Column(name = "shopping_list_id", nullable = false) - private Integer shoppingListId; + private Long shoppingListId; @Column(name = "unit_type_id", nullable = false) - private Integer unitTypeId; + private Long unitTypeId; public String toString() {return "ProductHasShoppingListPK(productId=" + this.getProductId() + ", shoppingListId=" + this.getShoppingListId() + ", unitTypeId=" + this.getUnitTypeId() + ")";} diff --git a/src/main/java/dev/nmarulo/depensaapp/app/productshoppinglist/ProductHasShoppingListRepository.java b/src/main/java/dev/nmarulo/depensaapp/app/productshoppinglist/ProductHasShoppingListRepository.java index a9bf8da..0e2dfe0 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/productshoppinglist/ProductHasShoppingListRepository.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/productshoppinglist/ProductHasShoppingListRepository.java @@ -19,13 +19,13 @@ Optional findByShoppingListIdAndUserAndProductId(Integer @Query( "SELECT p FROM ProductHasShoppingList p WHERE p.shoppingList.id = :id AND p.shoppingList.user = :user AND p.product.id IN :productsId") - List findAllByShoppingListIdAndUserAndProductIdIn(Integer id, + List findAllByShoppingListIdAndUserAndProductIdIn(Long id, User user, List productsId); @Query( "SELECT p FROM ProductHasShoppingList p WHERE p.shoppingList.id = :id AND p.shoppingList.user = :user AND p.product.id IN :productsId AND p.unitType.id IN :unitTypesId") - List findAllByShoppingListIdAndUserAndProductIdInAndUnitTypeIdIn(Integer id, + List findAllByShoppingListIdAndUserAndProductIdInAndUnitTypeIdIn(Long id, User user, List productsId, List unitTypesId); diff --git a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingList.java b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingList.java index 90f4f5d..b71ead5 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingList.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingList.java @@ -30,7 +30,7 @@ public class ShoppingList { @GeneratedValue(strategy = GenerationType.IDENTITY) @Id @Column(name = "id", nullable = false) - private Integer id; + private Long id; @Basic @Column(name = "name", length = 250) diff --git a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListAdminController.java b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListAdminController.java index 54b21ce..8f86d76 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListAdminController.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListAdminController.java @@ -14,7 +14,7 @@ @RequiredArgsConstructor @Getter @Tag(name = "Shopping List Admin", description = "Endpoints for managing shopping lists") -public class ShoppingListAdminController extends CrudController { +public class ShoppingListAdminController extends CrudController { private final ShoppingListAdminService service; diff --git a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListAdminService.java b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListAdminService.java index a244cc7..534ce1d 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListAdminService.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListAdminService.java @@ -10,7 +10,7 @@ @Service @RequiredArgsConstructor @Getter -public class ShoppingListAdminService extends CrudServiceImp { +public class ShoppingListAdminService extends CrudServiceImp { private final ShoppingListRepository repository; diff --git a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListController.java b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListController.java index f71d88f..8a812be 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListController.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListController.java @@ -26,7 +26,7 @@ public ResponseEntity findAll(@PageableDefault Pageable } @GetMapping("/{id}") - public ResponseEntity findById(@PathVariable Integer id) { + public ResponseEntity findById(@PathVariable Long id) { return ResponseEntity.ok(this.shoppingListService.findById(id, this.dataRequestScope.getAuthenticationPrincipal())); } @@ -40,8 +40,7 @@ public ResponseEntity findByIdProduct(@PathVari } @DeleteMapping("/{id}/products") - public ResponseEntity deleteProducts(@PathVariable Integer id, - @RequestBody DeleteProductsShoppingListReq request) { + public ResponseEntity deleteProducts(@PathVariable Long id, @RequestBody DeleteProductsShoppingListReq request) { this.shoppingListService.deleteProducts(id, request, this.dataRequestScope.getAuthenticationPrincipal()); return ResponseEntity.noContent() @@ -55,7 +54,7 @@ public ResponseEntity save(@RequestBody SaveShoppingListReq } @PutMapping("/{id}") - public ResponseEntity update(@PathVariable Integer id, + public ResponseEntity update(@PathVariable Long id, @RequestBody UpdateShoppingListReq request) { return ResponseEntity.ok(this.shoppingListService.update(id, request, @@ -63,7 +62,7 @@ public ResponseEntity update(@PathVariable Integer id, } @DeleteMapping("/{id}") - public ResponseEntity delete(@PathVariable Integer id) { + public ResponseEntity delete(@PathVariable Long id) { this.shoppingListService.delete(id, this.dataRequestScope.getAuthenticationPrincipal()); return ResponseEntity.noContent() diff --git a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListRepository.java b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListRepository.java index 347dd19..9d75b88 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListRepository.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListRepository.java @@ -9,10 +9,10 @@ import java.util.Optional; @Repository -public interface ShoppingListRepository extends JpaRepository { +public interface ShoppingListRepository extends JpaRepository { Page findAllByUser(User user, Pageable pageable); - Optional findByIdAndUser(Integer id, User user); + Optional findByIdAndUser(Long id, User user); } diff --git a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListService.java b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListService.java index 2da1ece..b9cc1bb 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListService.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/ShoppingListService.java @@ -34,7 +34,7 @@ public FindAllShoppingListRes findAll(final Pageable pageable, User user) { return ShoppingListMapper.toFindAllShoppingListRes(pageFindAll); } - public FindByIdShoppingListRes findById(Integer id, User user) { + public FindByIdShoppingListRes findById(Long id, User user) { var findById = this.shoppingListRepository.findByIdAndUser(id, user); if (findById.isEmpty()) { @@ -57,7 +57,7 @@ public FindByIdProductShoppingListRest findByIdProduct(Integer id, Long productI return ShoppingListMapper.toFindByIdProductShoppingListRest(productShoppingListOptional.get()); } - public void deleteProducts(Integer id, DeleteProductsShoppingListReq request, User user) { + public void deleteProducts(Long id, DeleteProductsShoppingListReq request, User user) { var shoppingListOptional = this.shoppingListRepository.findByIdAndUser(id, user); if (shoppingListOptional.isEmpty()) { @@ -97,7 +97,7 @@ public SaveShoppingListRes save(SaveShoppingListReq request, User user) { return ShoppingListMapper.toSaveShoppingListRes(save); } - public UpdateShoppingListRes update(Integer id, UpdateShoppingListReq request, User user) { + public UpdateShoppingListRes update(Long id, UpdateShoppingListReq request, User user) { var shoppingListOptional = this.shoppingListRepository.findByIdAndUser(id, user); if (shoppingListOptional.isEmpty()) { @@ -115,7 +115,7 @@ public UpdateShoppingListRes update(Integer id, UpdateShoppingListReq request, U return ShoppingListMapper.toUpdateShoppingListRes(update); } - public void delete(Integer id, User user) { + public void delete(Long id, User user) { var shoppingListOptional = this.shoppingListRepository.findByIdAndUser(id, user); if (shoppingListOptional.isEmpty()) { @@ -128,7 +128,7 @@ public void delete(Integer id, User user) { this.shoppingListRepository.delete(shoppingList); } - private void updateProducts(Integer shoppingListId, + private void updateProducts(Long shoppingListId, List productsReq, User user) { if (productsReq == null || productsReq.isEmpty()) { diff --git a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/dtos/FindAllShoppingListRes.java b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/dtos/FindAllShoppingListRes.java index 6d74e7e..f98dad4 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/dtos/FindAllShoppingListRes.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/shoppinglist/dtos/FindAllShoppingListRes.java @@ -12,7 +12,7 @@ public class FindAllShoppingListRes extends PagingAndSortingRes { +public class UnitTypeAdminController extends CrudController { private final UnitTypeAdminService service; diff --git a/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/UnitTypeAdminService.java b/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/UnitTypeAdminService.java index 6e1400a..8d0d870 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/UnitTypeAdminService.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/UnitTypeAdminService.java @@ -10,7 +10,7 @@ @Service @RequiredArgsConstructor @Getter -public class UnitTypeAdminService extends CrudServiceImp { +public class UnitTypeAdminService extends CrudServiceImp { private final UnitTypeRepository repository; diff --git a/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/UnitTypeRepository.java b/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/UnitTypeRepository.java index 6f6d251..808316e 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/UnitTypeRepository.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/UnitTypeRepository.java @@ -4,4 +4,4 @@ import org.springframework.stereotype.Repository; @Repository -public interface UnitTypeRepository extends JpaRepository {} +public interface UnitTypeRepository extends JpaRepository {} diff --git a/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/dtos/FindAllUnitTypeRes.java b/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/dtos/FindAllUnitTypeRes.java index 8b45f71..9b75cc3 100644 --- a/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/dtos/FindAllUnitTypeRes.java +++ b/src/main/java/dev/nmarulo/depensaapp/app/unitytypes/dtos/FindAllUnitTypeRes.java @@ -10,7 +10,7 @@ public class FindAllUnitTypeRes extends PagingAndSortingRes unitTypePage) private UnitType initUnitType() { final var unitType = new UnitType(); - unitType.setId(FakeTestUtil.randomInteger()); + unitType.setId(FakeTestUtil.randomLong()); unitType.setName(FakeTestUtil.randomWord()); unitType.setCreatedAt(FakeTestUtil.randomPast()); unitType.setUpdatedAt(FakeTestUtil.randomFuture());