From 5e09acd5c96700a32cb72e6a28a1ffa40006f24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg-Christian=20M=C3=BCller?= Date: Sun, 17 Mar 2024 12:06:22 +0100 Subject: [PATCH 1/3] Initial --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index c59a9aed6..a02e6bf2f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.2 + 3.2.3 guru.springframework @@ -14,7 +14,7 @@ spring-6-rest-mvc spring-6-rest-mvc - 17 + 21 From b6a85d3d78615e4498ee65aad57632db8cba2a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg-Christian=20M=C3=BCller?= Date: Sun, 17 Mar 2024 13:06:25 +0100 Subject: [PATCH 2/3] Project Lombok Pojos --- .../spring6restmvc/model/Beer.java | 23 +++++++++++++++++++ .../spring6restmvc/model/BeerStyle.java | 8 +++++++ 2 files changed, 31 insertions(+) create mode 100644 src/main/java/guru/springframework/spring6restmvc/model/Beer.java create mode 100644 src/main/java/guru/springframework/spring6restmvc/model/BeerStyle.java diff --git a/src/main/java/guru/springframework/spring6restmvc/model/Beer.java b/src/main/java/guru/springframework/spring6restmvc/model/Beer.java new file mode 100644 index 000000000..d1cc96aae --- /dev/null +++ b/src/main/java/guru/springframework/spring6restmvc/model/Beer.java @@ -0,0 +1,23 @@ +package guru.springframework.spring6restmvc.model; + +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.UUID; + +/** + * Created by jt, Spring Framework Guru. + */ +@Data +public class Beer { + private UUID id; + private Integer version; + private String beerName; + private BeerStyle beerStyle; + private String upc; + private Integer quantityOnHand; + private BigDecimal price; + private LocalDateTime createdDate; + private LocalDateTime updateDate; +} diff --git a/src/main/java/guru/springframework/spring6restmvc/model/BeerStyle.java b/src/main/java/guru/springframework/spring6restmvc/model/BeerStyle.java new file mode 100644 index 000000000..78a1b30df --- /dev/null +++ b/src/main/java/guru/springframework/spring6restmvc/model/BeerStyle.java @@ -0,0 +1,8 @@ +package guru.springframework.spring6restmvc.model; + +/** + * Created by jt, Spring Framework Guru. + */ +public enum BeerStyle { + LAGER, PILSNER, STOUT, GOSE, PORTER, ALE, WHEAT, IPA, PALE_ALE, SAISON +} From 71f37d86d8e37e288a1da7d011f0335bbe8936cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg-Christian=20M=C3=BCller?= Date: Sun, 17 Mar 2024 13:16:04 +0100 Subject: [PATCH 3/3] Project Lombok Builder Pattern --- .../spring6restmvc/model/Beer.java | 2 ++ .../spring6restmvc/services/BeerService.java | 13 +++++++++ .../services/BeerServiceImpl.java | 28 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 src/main/java/guru/springframework/spring6restmvc/services/BeerService.java create mode 100644 src/main/java/guru/springframework/spring6restmvc/services/BeerServiceImpl.java diff --git a/src/main/java/guru/springframework/spring6restmvc/model/Beer.java b/src/main/java/guru/springframework/spring6restmvc/model/Beer.java index d1cc96aae..1aed54c28 100644 --- a/src/main/java/guru/springframework/spring6restmvc/model/Beer.java +++ b/src/main/java/guru/springframework/spring6restmvc/model/Beer.java @@ -1,5 +1,6 @@ package guru.springframework.spring6restmvc.model; +import lombok.Builder; import lombok.Data; import java.math.BigDecimal; @@ -9,6 +10,7 @@ /** * Created by jt, Spring Framework Guru. */ +@Builder @Data public class Beer { private UUID id; diff --git a/src/main/java/guru/springframework/spring6restmvc/services/BeerService.java b/src/main/java/guru/springframework/spring6restmvc/services/BeerService.java new file mode 100644 index 000000000..70ef7fdd3 --- /dev/null +++ b/src/main/java/guru/springframework/spring6restmvc/services/BeerService.java @@ -0,0 +1,13 @@ +package guru.springframework.spring6restmvc.services; + +import guru.springframework.spring6restmvc.model.Beer; + +import java.util.UUID; + +/** + * Created by jt, Spring Framework Guru. + */ +public interface BeerService { + + Beer getBeerById(UUID id); +} diff --git a/src/main/java/guru/springframework/spring6restmvc/services/BeerServiceImpl.java b/src/main/java/guru/springframework/spring6restmvc/services/BeerServiceImpl.java new file mode 100644 index 000000000..d094b3198 --- /dev/null +++ b/src/main/java/guru/springframework/spring6restmvc/services/BeerServiceImpl.java @@ -0,0 +1,28 @@ +package guru.springframework.spring6restmvc.services; + +import guru.springframework.spring6restmvc.model.Beer; +import guru.springframework.spring6restmvc.model.BeerStyle; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.UUID; + +/** + * Created by jt, Spring Framework Guru. + */ +public class BeerServiceImpl implements BeerService { + @Override + public Beer getBeerById(UUID id) { + return Beer.builder() + .id(id) + .version(1) + .beerName("Galaxy Cat") + .beerStyle(BeerStyle.PALE_ALE) + .upc("12356") + .price(new BigDecimal("12.99")) + .quantityOnHand(122) + .createdDate(LocalDateTime.now()) + .updateDate(LocalDateTime.now()) + .build(); + } +}