From 2cfd990b0125b91d4be4653ce68d6406f83df228 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Wed, 1 Nov 2023 20:16:56 +0900 Subject: [PATCH 01/73] =?UTF-8?q?chore:=20=EB=A1=9C=EA=B7=B8=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/logback.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 852fbefc4a..a6efc8b390 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -27,7 +27,7 @@ - + \ No newline at end of file From ab537b14fb984d9a2e87e2dfc866540aa1083506 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Wed, 1 Nov 2023 20:19:09 +0900 Subject: [PATCH 02/73] =?UTF-8?q?build:=20thymeleaf=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index b2f544c651..f540d67346 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-jdbc' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:3.1.5' testImplementation 'org.springframework.boot:spring-boot-starter-test' implementation 'com.mysql:mysql-connector-j:8.1.0' // https://mvnrepository.com/artifact/com.wix/wix-embedded-mysql From 143ea8695d1925f9a763a1cdc9a84713be00aba9 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Wed, 1 Nov 2023 20:19:46 +0900 Subject: [PATCH 03/73] =?UTF-8?q?feat:=20voucher=20=EB=B0=9B=EB=8A=94=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A0=84=EC=86=A1=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/VoucherPageController.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java new file mode 100644 index 0000000000..6f228be21e --- /dev/null +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -0,0 +1,28 @@ +package org.programmers.springorder.voucher.controller; + +import org.programmers.springorder.voucher.dto.VoucherResponseDto; +import org.programmers.springorder.voucher.service.VoucherService; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +import java.util.List; + +@Controller +public class VoucherPageController { + + private final VoucherService voucherService; + + public VoucherPageController(VoucherService voucherService) { + this.voucherService = voucherService; + } + + @GetMapping("/vouchers") + public String getVoucherList(Model model) { + List allVoucher = voucherService.getAllVoucher(); + model.addAttribute("voucherList", allVoucher); + return "vouchers"; + } + +} + From f54ae10499e9e41edd9d3121813e6296b09c329e Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Wed, 1 Nov 2023 20:20:58 +0900 Subject: [PATCH 04/73] =?UTF-8?q?refactor:=20voucherResponseDto=20record?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit model에 추가하여 html상에서 사용하기 위해 추가, 필요에 사용하는 곳에서 기존 getter 메서드 변환 --- .../voucher/dto/VoucherResponseDto.java | 22 ++++++------------- .../voucher/service/VoucherServiceTest.java | 4 ++-- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/programmers/springorder/voucher/dto/VoucherResponseDto.java b/src/main/java/org/programmers/springorder/voucher/dto/VoucherResponseDto.java index 1b86398579..d52cfbb00b 100644 --- a/src/main/java/org/programmers/springorder/voucher/dto/VoucherResponseDto.java +++ b/src/main/java/org/programmers/springorder/voucher/dto/VoucherResponseDto.java @@ -5,23 +5,15 @@ import java.util.UUID; -public class VoucherResponseDto{ - private final UUID voucherId; - private final long discountValue; - private final String voucherType; - - private VoucherResponseDto(Voucher voucher) { - this.voucherId = voucher.getVoucherId(); - this.discountValue = voucher.getDiscountValue(); - this.voucherType = voucher.getVoucherType().name(); - } +public record VoucherResponseDto( UUID voucherId, long discountValue, String voucherType){ - public static VoucherResponseDto of(Voucher voucher){ - return new VoucherResponseDto(voucher); - } - public UUID getVoucherId() { - return voucherId; + + public static VoucherResponseDto of(Voucher voucher){ + return new VoucherResponseDto( + voucher.getVoucherId(), + voucher.getDiscountValue(), + voucher.getVoucherType().name()); } @Override diff --git a/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java b/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java index 4f40328ca3..56e4bf29e6 100644 --- a/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java +++ b/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java @@ -70,7 +70,7 @@ void getAllVoucher() { voucherRepository.save(Voucher.toVoucher(uuids.get(3), 2000, VoucherType.FIXED)); List allVoucher = voucherService.getAllVoucher(); - List rs = allVoucher.stream().map(VoucherResponseDto::getVoucherId).toList(); + List rs = allVoucher.stream().map(VoucherResponseDto::voucherId).toList(); assertThat(allVoucher).hasSize(4); assertThat(rs.containsAll(uuids)) @@ -191,7 +191,7 @@ public void customerOwnedVoucherServiceTest() { List customerOwnedVouchers = voucherService.getCustomerOwnedVouchers(customer.getCustomerId()); List foundVoucherId = customerOwnedVouchers .stream() - .map(VoucherResponseDto::getVoucherId) + .map(VoucherResponseDto::voucherId) .toList(); assertThat(customerOwnedVouchers).hasSize(2); From 50e516c3ba1a02e0ab1a63465b2a0b629c0f5567 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Wed, 1 Nov 2023 20:21:28 +0900 Subject: [PATCH 05/73] =?UTF-8?q?feat:=20=EB=AA=A8=EB=93=A0=20voucher?= =?UTF-8?q?=EB=A5=BC=20=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=B3=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/vouchers.html | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/main/resources/templates/vouchers.html diff --git a/src/main/resources/templates/vouchers.html b/src/main/resources/templates/vouchers.html new file mode 100644 index 0000000000..111445f3d3 --- /dev/null +++ b/src/main/resources/templates/vouchers.html @@ -0,0 +1,49 @@ + + + + + + + + Document + + + + +

ALL VOUCHERS

+ + + + + + + + + + + + + + + + + +
#VoucherIdVoucherTypediscountValue
+ + \ No newline at end of file From f84a2eee4afe30eb8d3798578c150312ecea1650 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 14:26:39 +0900 Subject: [PATCH 06/73] =?UTF-8?q?chore:=20docker=20=ED=8F=AC=ED=8A=B8=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EA=B8=B0=EC=A1=B4=203306=20=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=EB=8A=94=20mysql,=203000=EB=B2=88=20=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=EB=8A=94=20react=20default=20=ED=8F=AC=ED=8A=B8?= =?UTF-8?q?=EB=9D=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=203300=ED=8F=AC=ED=8A=B8=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 +- .../org/programmers/springorder/config/jdbc/JdbcConfig.java | 2 +- .../org/programmers/springorder/config/memory/MemoryConfig.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c5e1442e0f..b7c2ecf412 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,7 +3,7 @@ spring: active: default datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/vouchers + url: jdbc:mysql://localhost:3300/vouchers username: root password: 1234 diff --git a/src/test/java/org/programmers/springorder/config/jdbc/JdbcConfig.java b/src/test/java/org/programmers/springorder/config/jdbc/JdbcConfig.java index 3229c89ca6..a2674c9ea9 100644 --- a/src/test/java/org/programmers/springorder/config/jdbc/JdbcConfig.java +++ b/src/test/java/org/programmers/springorder/config/jdbc/JdbcConfig.java @@ -23,7 +23,7 @@ public class JdbcConfig { @Bean public DataSource dataSource() { var dataSource = DataSourceBuilder.create() - .url("jdbc:mysql://localhost:3306/vouchers_test") + .url("jdbc:mysql://localhost:3300/vouchers_test") .username("root") .password("1234") .type(HikariDataSource.class) diff --git a/src/test/java/org/programmers/springorder/config/memory/MemoryConfig.java b/src/test/java/org/programmers/springorder/config/memory/MemoryConfig.java index a42eaee1a4..1a4ca194ae 100644 --- a/src/test/java/org/programmers/springorder/config/memory/MemoryConfig.java +++ b/src/test/java/org/programmers/springorder/config/memory/MemoryConfig.java @@ -21,7 +21,7 @@ public class MemoryConfig { @Bean public DataSource dataSource() { var dataSource = DataSourceBuilder.create() - .url("jdbc:mysql://localhost:3306/vouchers_test") + .url("jdbc:mysql://localhost:3300/vouchers_test") .username("root") .password("1234") .type(HikariDataSource.class) From 90d64ae60feabadb9f3e414d0d36090fd193794c Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:11:07 +0900 Subject: [PATCH 07/73] =?UTF-8?q?feat:=20voucherconsoler=EA=B3=BC=20web=20?= =?UTF-8?q?=EB=B2=84=EC=A0=84=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/VoucherApplication.java | 37 ++++++++++++++----- .../springorder/console/Console.java | 6 ++- .../springorder/console/Input.java | 1 - .../springorder/consts/Message.java | 6 +++ 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/programmers/springorder/VoucherApplication.java b/src/main/java/org/programmers/springorder/VoucherApplication.java index 774fe33a6d..a98ac187d8 100644 --- a/src/main/java/org/programmers/springorder/VoucherApplication.java +++ b/src/main/java/org/programmers/springorder/VoucherApplication.java @@ -1,10 +1,11 @@ package org.programmers.springorder; import org.programmers.springorder.console.Console; +import org.programmers.springorder.consts.ErrorMessage; import org.programmers.springorder.consts.Message; import org.programmers.springorder.customer.controller.CustomerController; import org.programmers.springorder.utils.MenuType; -import org.programmers.springorder.voucher.controller.VoucherController; +import org.programmers.springorder.voucher.controller.VoucherConsoleController; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; @@ -12,19 +13,24 @@ public class VoucherApplication implements CommandLineRunner { private final Console console; - private final VoucherController voucherController; + private final VoucherConsoleController voucherConsoleController; private final CustomerController customerController; - public VoucherApplication(Console console, VoucherController voucherController, CustomerController customerController) { + public VoucherApplication(Console console, VoucherConsoleController voucherConsoleController, CustomerController customerController) { this.console = console; - this.voucherController = voucherController; + this.voucherConsoleController = voucherConsoleController; this.customerController = customerController; } @Override public void run(String... args) { - boolean isRunning = true; + boolean isRunning = true; + boolean isWeb = false; + if(chooseMedia()){ + isWeb = true; + }; while(isRunning) { + if(isWeb) break; MenuType menu = console.inputMenu(); switch (menu) { @@ -32,15 +38,26 @@ public void run(String... args) { isRunning = false; console.printMessage(Message.EXIT_PROGRAM_MESSAGE); } - case CREATE -> voucherController.createVoucher(); - case LIST -> voucherController.getVoucherList(); + case CREATE -> voucherConsoleController.createVoucher(); + case LIST -> voucherConsoleController.getVoucherList(); case BLACK -> customerController.printBlackList(); - case ALLOCATE -> voucherController.giveVoucher(); - case GET_OWNER_VOUCHER -> voucherController.getVouchersOfOwner(); - case DELETE_VOUCHER -> voucherController.deleteVoucher(); + case ALLOCATE -> voucherConsoleController.giveVoucher(); + case GET_OWNER_VOUCHER -> voucherConsoleController.getVouchersOfOwner(); + case DELETE_VOUCHER -> voucherConsoleController.deleteVoucher(); case SEARCH_VOUCHER_OWNER -> customerController.getVoucherOwner(); } } } + private boolean chooseMedia() { + String media = console.chooseMedia(); + if(media.equals("1")){ + return true; + } + if(media.equals("2")){ + return false; + }; + throw new RuntimeException(ErrorMessage.INVALID_VALUE_MESSAGE); + } + } diff --git a/src/main/java/org/programmers/springorder/console/Console.java b/src/main/java/org/programmers/springorder/console/Console.java index 856f9a6352..4c640c4ff6 100644 --- a/src/main/java/org/programmers/springorder/console/Console.java +++ b/src/main/java/org/programmers/springorder/console/Console.java @@ -15,7 +15,6 @@ import java.util.InputMismatchException; import java.util.List; -import java.util.Optional; import java.util.UUID; @Component @@ -122,4 +121,9 @@ public UUID getVoucherId() { public void showCustomer(CustomerResponseDto customer) { printMessage(customer.toString()); } + + public String chooseMedia() { + printMessage(Message.CHOOSING_MEDIA); + return input.getInput(); + } } diff --git a/src/main/java/org/programmers/springorder/console/Input.java b/src/main/java/org/programmers/springorder/console/Input.java index 4facaee99e..298ee57a66 100644 --- a/src/main/java/org/programmers/springorder/console/Input.java +++ b/src/main/java/org/programmers/springorder/console/Input.java @@ -1,6 +1,5 @@ package org.programmers.springorder.console; -import org.programmers.springorder.utils.Validation; import java.util.Scanner; diff --git a/src/main/java/org/programmers/springorder/consts/Message.java b/src/main/java/org/programmers/springorder/consts/Message.java index 6714e0efc7..c8242a649d 100644 --- a/src/main/java/org/programmers/springorder/consts/Message.java +++ b/src/main/java/org/programmers/springorder/consts/Message.java @@ -2,6 +2,12 @@ public class Message { + public static final String CHOOSING_MEDIA = """ + 어떤 방식으로 구동하시겠습니까? + 1. web 방식 + 2. console 방식 + """; + private Message(){} public static final String MENU_SELECT_MESSAGE = """ === Voucher Program === From 2f5e04795cc5d049872261ef76674673c52b2939 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:36:20 +0900 Subject: [PATCH 08/73] =?UTF-8?q?refactor:=20requestDto=EB=A5=BC=20class?= =?UTF-8?q?=20->=20record=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../voucher/dto/VoucherRequestDto.java | 17 +---------------- .../springorder/voucher/model/Voucher.java | 4 ++-- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/programmers/springorder/voucher/dto/VoucherRequestDto.java b/src/main/java/org/programmers/springorder/voucher/dto/VoucherRequestDto.java index 7c7b286721..5bef4ca95e 100644 --- a/src/main/java/org/programmers/springorder/voucher/dto/VoucherRequestDto.java +++ b/src/main/java/org/programmers/springorder/voucher/dto/VoucherRequestDto.java @@ -2,20 +2,5 @@ import org.programmers.springorder.voucher.model.VoucherType; -public class VoucherRequestDto { - private final long discountValue; - private final VoucherType voucherType; - - public VoucherRequestDto(long discountValue, VoucherType voucherType) { - this.discountValue = discountValue; - this.voucherType = voucherType; - } - - public long getDiscountValue() { - return discountValue; - } - - public VoucherType getVoucherType() { - return voucherType; - } +public record VoucherRequestDto(long discountValue, VoucherType voucherType) { } diff --git a/src/main/java/org/programmers/springorder/voucher/model/Voucher.java b/src/main/java/org/programmers/springorder/voucher/model/Voucher.java index d3d48710b0..98ae037261 100644 --- a/src/main/java/org/programmers/springorder/voucher/model/Voucher.java +++ b/src/main/java/org/programmers/springorder/voucher/model/Voucher.java @@ -34,8 +34,8 @@ public static Voucher getVoucher(UUID voucherId, long discountValue, VoucherType } private Voucher(UUID voucherId, VoucherRequestDto voucherRequestDto) { this.voucherId = voucherId; - this.discountValue = voucherRequestDto.getDiscountValue(); - this.voucherType = voucherRequestDto.getVoucherType(); + this.discountValue = voucherRequestDto.discountValue(); + this.voucherType = voucherRequestDto.voucherType(); } public static Voucher of(UUID voucherId, VoucherRequestDto requestDto) { From 888f0962bafdc95437507e4f3308d9cdd4bbce51 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:36:51 +0900 Subject: [PATCH 09/73] =?UTF-8?q?chore:=20console=EB=A1=9C=20=EC=A7=84?= =?UTF-8?q?=ED=96=89=ED=95=98=EB=8A=94=20class=20=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{VoucherController.java => VoucherConsoleController.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/org/programmers/springorder/voucher/controller/{VoucherController.java => VoucherConsoleController.java} (92%) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherConsoleController.java similarity index 92% rename from src/main/java/org/programmers/springorder/voucher/controller/VoucherController.java rename to src/main/java/org/programmers/springorder/voucher/controller/VoucherConsoleController.java index 57542e2631..1bb6c0ebef 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherConsoleController.java @@ -10,12 +10,12 @@ import java.util.UUID; @Controller -public class VoucherController { +public class VoucherConsoleController { private final Console console; private final VoucherService voucherService; - public VoucherController(Console console, VoucherService voucherService) { + public VoucherConsoleController(Console console, VoucherService voucherService) { this.console = console; this.voucherService = voucherService; } From b1063961776f5f27fbebd7dba0ec409b07633c23 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:41:01 +0900 Subject: [PATCH 10/73] =?UTF-8?q?chore:=20=EC=8A=A4=ED=94=84=EB=A7=81=20?= =?UTF-8?q?=EA=B5=AC=EB=8F=99=20=EB=A1=9C=EA=B7=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../programmers/springorder/SpringOrderApplication.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/programmers/springorder/SpringOrderApplication.java b/src/main/java/org/programmers/springorder/SpringOrderApplication.java index fea496bebc..f513e290d4 100644 --- a/src/main/java/org/programmers/springorder/SpringOrderApplication.java +++ b/src/main/java/org/programmers/springorder/SpringOrderApplication.java @@ -7,11 +7,9 @@ @SpringBootApplication public class SpringOrderApplication { - private static final Logger log = LoggerFactory.getLogger(SpringOrderApplication.class); - public static void main(String[] args) { - log.info("Voucher 관리 애플리케이션 구동"); - SpringApplication.run(SpringOrderApplication.class, args).close(); - } + public static void main(String[] args) { + SpringApplication.run(SpringOrderApplication.class, args); + } } From 656ac054b55e65715afe560f5b9cfe41fdc9af53 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:42:21 +0900 Subject: [PATCH 11/73] =?UTF-8?q?feat:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20vou?= =?UTF-8?q?cher=20=ED=8E=98=EC=9D=B4=EC=A7=80=EB=A1=9C=20=EB=84=98?= =?UTF-8?q?=EC=96=B4=EA=B0=80=EB=8A=94=20url=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/voucher/controller/VoucherPageController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java index 6f228be21e..da61d79e3d 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -24,5 +24,9 @@ public String getVoucherList(Model model) { return "vouchers"; } + @GetMapping("/new-voucher") + public String getNewVoucherPage(){ + return "new-voucher"; + } } From e3f8c4d28fb6afc05f08c46fab75b140aae2f20a Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:42:49 +0900 Subject: [PATCH 12/73] =?UTF-8?q?feat:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20vou?= =?UTF-8?q?cher=EB=A5=BC=20=20=EB=93=B1=EB=A1=9D=ED=95=98=EB=8A=94=20api?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../voucher/controller/VoucherPageController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java index da61d79e3d..1068eb07bc 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -1,10 +1,12 @@ package org.programmers.springorder.voucher.controller; +import org.programmers.springorder.voucher.dto.VoucherRequestDto; import org.programmers.springorder.voucher.dto.VoucherResponseDto; import org.programmers.springorder.voucher.service.VoucherService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import java.util.List; @@ -28,5 +30,12 @@ public String getVoucherList(Model model) { public String getNewVoucherPage(){ return "new-voucher"; } + + @PostMapping("/vouchers") + public String createVoucher(VoucherRequestDto voucherRequestDto) { + voucherService.save(voucherRequestDto); + return "redirect:vouchers"; + } + } From fdab3d675bbb35f701a29b47659874c2c20730e8 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:43:23 +0900 Subject: [PATCH 13/73] =?UTF-8?q?feat:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20vou?= =?UTF-8?q?cher=EB=A5=BC=20=EC=83=9D=EC=84=B1=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/new-voucher.html | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/resources/templates/new-voucher.html diff --git a/src/main/resources/templates/new-voucher.html b/src/main/resources/templates/new-voucher.html new file mode 100644 index 0000000000..7180893a70 --- /dev/null +++ b/src/main/resources/templates/new-voucher.html @@ -0,0 +1,51 @@ + + + + + + + + Document + + + + + +
+

MAKE NEW VOUCHER

+ +
+ +
+ + +
+ +
+
+ + \ No newline at end of file From a06c20adf5c280d5ef9b792ca491ea6935f0dc63 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:44:56 +0900 Subject: [PATCH 14/73] refactor: ui refactoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nav 바 변경, ui 개선 --- src/main/resources/templates/vouchers.html | 59 ++++++++++++---------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/main/resources/templates/vouchers.html b/src/main/resources/templates/vouchers.html index 111445f3d3..239d8d3663 100644 --- a/src/main/resources/templates/vouchers.html +++ b/src/main/resources/templates/vouchers.html @@ -5,45 +5,52 @@ - + Document + -

ALL VOUCHERS

- - - - - - - - - - - - - - - - - -
#VoucherIdVoucherTypediscountValue
+
+

ALL VOUCHERS

+ + + + + + + + + + + + + + + + + +
#VoucherIdVoucherTypediscountValue
+
\ No newline at end of file From a903890abfc982f892d95ae9ba139f6cdfbbc390 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Thu, 2 Nov 2023 15:45:16 +0900 Subject: [PATCH 15/73] =?UTF-8?q?chore:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EB=AC=B8=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/programmers/springorder/SpringOrderApplication.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/programmers/springorder/SpringOrderApplication.java b/src/main/java/org/programmers/springorder/SpringOrderApplication.java index f513e290d4..6efd3812a9 100644 --- a/src/main/java/org/programmers/springorder/SpringOrderApplication.java +++ b/src/main/java/org/programmers/springorder/SpringOrderApplication.java @@ -1,7 +1,5 @@ package org.programmers.springorder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; From 06b430cd623248efc98488d07e69c0693fc0e680 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Fri, 3 Nov 2023 10:47:22 +0900 Subject: [PATCH 16/73] =?UTF-8?q?chore:=20voucherService=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../voucher/controller/VoucherConsoleController.java | 4 ++-- .../springorder/customer/service/CustomerServiceTest.java | 6 +++--- .../springorder/voucher/service/VoucherServiceTest.java | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherConsoleController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherConsoleController.java index 1bb6c0ebef..da8a90ac79 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherConsoleController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherConsoleController.java @@ -26,13 +26,13 @@ public void getVoucherList() { public void createVoucher() { VoucherRequestDto request = console.inputVoucherInfo(); - voucherService.save(request); + voucherService.saveNewVoucher(request); console.printMessage(Message.VOUCHER_REGISTERED); } public void giveVoucher(){ GiveVoucherRequestDto requestDto = console.giveVoucherInfo(); - voucherService.update(requestDto.getVoucherId(), requestDto.getCustomerId()); + voucherService.allocateVoucher(requestDto.getVoucherId(), requestDto.getCustomerId()); console.printMessage(Message.VOUCHER_ALLOCATED); } diff --git a/src/test/java/org/programmers/springorder/customer/service/CustomerServiceTest.java b/src/test/java/org/programmers/springorder/customer/service/CustomerServiceTest.java index 766cd5780f..ba73cf7a1b 100644 --- a/src/test/java/org/programmers/springorder/customer/service/CustomerServiceTest.java +++ b/src/test/java/org/programmers/springorder/customer/service/CustomerServiceTest.java @@ -69,7 +69,7 @@ public void findVoucherOwner(){ //when voucherRepository.save(voucher); customerRepository.insert(customer); - voucherService.update(voucherId, customerId); + voucherService.allocateVoucher(voucherId, customerId); UUID customerId1 = customerService.findOwnerOfVoucher(voucherId).getCustomerId(); @@ -88,7 +88,7 @@ public void findVoucherOwnerNoVoucher(){ //when voucherRepository.save(voucher); customerRepository.insert(customer); - voucherService.update(voucherId, customerId); + voucherService.allocateVoucher(voucherId, customerId); assertThatThrownBy(() -> customerService.findOwnerOfVoucher(UUID.randomUUID())) .isInstanceOf(RuntimeException.class) @@ -107,7 +107,7 @@ public void findVoucherOwnerNoOwner(){ //when voucherRepository.save(voucher); customerRepository.insert(customer); -// voucherService.update(voucherId, customerId); +// voucherService.allocateVoucher(voucherId, customerId); assertThatThrownBy(() -> customerService.findOwnerOfVoucher(voucherId)) .isInstanceOf(RuntimeException.class) diff --git a/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java b/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java index 56e4bf29e6..ac202fdb77 100644 --- a/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java +++ b/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java @@ -86,7 +86,7 @@ void saveNewVoucher() { assertThat(beforeSaveVoucher).hasSize(0); //when - voucherService.save(requestDto); + voucherService.saveNewVoucher(requestDto); List allVoucher = voucherService.getAllVoucher(); //then @@ -110,7 +110,7 @@ void allocateVoucherOwner() { //when voucherRepository.save(voucher); customerRepository.insert(customer); - voucherService.update(voucherId, customerId); + voucherService.allocateVoucher(voucherId, customerId); //then Voucher voucherWithOwner = voucherRepository.findById(voucherId).get(); @@ -132,7 +132,7 @@ void allocateVoucherOwnerWithoutValidUser() { customerRepository.insert(customer); //then - Assertions.assertThatThrownBy(() -> voucherService.update(voucherId, UUID.randomUUID())) + Assertions.assertThatThrownBy(() -> voucherService.allocateVoucher(voucherId, UUID.randomUUID())) .isInstanceOf(RuntimeException.class) .hasMessage("해당 고객을 찾을 수 없습니다."); @@ -152,7 +152,7 @@ void allocateVoucherOwnerWithoutValidVoucher() { customerRepository.insert(customer); //then - Assertions.assertThatThrownBy(() -> voucherService.update(UUID.randomUUID(), customerId)) + Assertions.assertThatThrownBy(() -> voucherService.allocateVoucher(UUID.randomUUID(), customerId)) .isInstanceOf(RuntimeException.class) .hasMessage("해당 바우처를 찾을 수 없습니다."); From f0661d547e3dcfbc5c399a5d20ca200d2b14a3a5 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Fri, 3 Nov 2023 10:48:08 +0900 Subject: [PATCH 17/73] =?UTF-8?q?feat:=20voucher=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A1=B0=ED=9A=8C=20api=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../voucher/controller/VoucherPageController.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java index 1068eb07bc..05f46ef448 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -2,13 +2,16 @@ import org.programmers.springorder.voucher.dto.VoucherRequestDto; import org.programmers.springorder.voucher.dto.VoucherResponseDto; +import org.programmers.springorder.voucher.model.Voucher; import org.programmers.springorder.voucher.service.VoucherService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import java.util.List; +import java.util.UUID; @Controller public class VoucherPageController { @@ -33,9 +36,16 @@ public String getNewVoucherPage(){ @PostMapping("/vouchers") public String createVoucher(VoucherRequestDto voucherRequestDto) { - voucherService.save(voucherRequestDto); + voucherService.saveNewVoucher(voucherRequestDto); return "redirect:vouchers"; } + @GetMapping("/vouchers/{voucherId}") + public String getVoucherDetail(@PathVariable UUID voucherId, Model model){ + Voucher voucher = voucherService.getVoucherById(voucherId); + model.addAttribute("voucher", voucher); + return "voucher-detail"; + } + } From 0fa0927384729f12502ea2feb21bf911c460f729 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Fri, 3 Nov 2023 10:52:39 +0900 Subject: [PATCH 18/73] =?UTF-8?q?refactor:=20voucherResponseDto=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=ED=99=98=ED=95=98=EC=97=AC=20model=20=EC=A0=84?= =?UTF-8?q?=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/voucher/controller/VoucherPageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java index 05f46ef448..769dd0858b 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -42,7 +42,7 @@ public String createVoucher(VoucherRequestDto voucherRequestDto) { @GetMapping("/vouchers/{voucherId}") public String getVoucherDetail(@PathVariable UUID voucherId, Model model){ - Voucher voucher = voucherService.getVoucherById(voucherId); + VoucherResponseDto voucher = voucherService.getVoucherById(voucherId); model.addAttribute("voucher", voucher); return "voucher-detail"; } From 9a3745e750fb92c54707b878e126944453166e91 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Fri, 3 Nov 2023 10:52:52 +0900 Subject: [PATCH 19/73] =?UTF-8?q?feat:=20voucher=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../voucher/service/VoucherService.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/programmers/springorder/voucher/service/VoucherService.java b/src/main/java/org/programmers/springorder/voucher/service/VoucherService.java index ea61aaa6c5..aa7fe8263a 100644 --- a/src/main/java/org/programmers/springorder/voucher/service/VoucherService.java +++ b/src/main/java/org/programmers/springorder/voucher/service/VoucherService.java @@ -1,5 +1,6 @@ package org.programmers.springorder.voucher.service; +import org.programmers.springorder.consts.ErrorMessage; import org.programmers.springorder.customer.model.Customer; import org.programmers.springorder.customer.repository.CustomerRepository; import org.programmers.springorder.voucher.dto.VoucherRequestDto; @@ -26,39 +27,45 @@ public VoucherService(VoucherRepository voucherRepository, CustomerRepository cu this.customerRepository = customerRepository; } - public List getAllVoucher(){ + public List getAllVoucher() { return voucherRepository.findAll() .stream() .map(VoucherResponseDto::of) .toList(); } - public void save(VoucherRequestDto voucherDto) { + public void saveNewVoucher(VoucherRequestDto voucherDto) { Voucher voucher = Voucher.of(UUID.randomUUID(), voucherDto); voucherRepository.save(voucher); log.info("등록된 Voucher => iD: {}, type: {}, value: {}", voucher.getVoucherId(), voucher.getVoucherType(), voucher.getDiscountValue()); } - public void update(UUID voucherId, UUID customerId){ + public void allocateVoucher(UUID voucherId, UUID customerId) { Voucher voucher = voucherRepository.findById(voucherId) - .orElseThrow( () -> new RuntimeException("해당 바우처를 찾을 수 없습니다.")); + .orElseThrow(() -> new RuntimeException("해당 바우처를 찾을 수 없습니다.")); Customer customer = customerRepository.findByID(customerId) - .orElseThrow( () -> new RuntimeException("해당 고객을 찾을 수 없습니다.")); + .orElseThrow(() -> new RuntimeException("해당 고객을 찾을 수 없습니다.")); voucherRepository.updateVoucherOwner(voucher, customer); } - public List getCustomerOwnedVouchers(UUID customerId){ + public List getCustomerOwnedVouchers(UUID customerId) { Customer customer = customerRepository.findByID(customerId) - .orElseThrow( () -> new RuntimeException("해당 고객을 찾을 수 없습니다.")); + .orElseThrow(() -> new RuntimeException("해당 고객을 찾을 수 없습니다.")); return voucherRepository.findAllByCustomerId(customer) .stream() .map(VoucherResponseDto::of) .toList(); } - public void deleteVoucher(UUID voucherId){ + public void deleteVoucher(UUID voucherId) { Voucher voucher = voucherRepository.findById(voucherId) .orElseThrow(() -> new RuntimeException("찾으시는 voucher가 존재하지 않습니다.")); voucherRepository.deleteVoucher(voucher); } + + public VoucherResponseDto getVoucherById(UUID voucherId) { + return voucherRepository.findById(voucherId) + .map(VoucherResponseDto::of) + .orElseThrow(() -> new RuntimeException(ErrorMessage.VOUCHER_NOT_EXIST_MESSAGE)); + } } From 8c9d938b975675ccc178925a67198710bb37848d Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Fri, 3 Nov 2023 10:53:27 +0900 Subject: [PATCH 20/73] =?UTF-8?q?refactor:=20voucher=20id=EB=A5=BC=20?= =?UTF-8?q?=EB=88=84=EB=A5=B4=EB=A9=B4=20=EC=83=81=EC=84=B8=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EA=B0=88=20=EC=88=98=20=EC=9E=88=EA=B2=8C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/vouchers.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/templates/vouchers.html b/src/main/resources/templates/vouchers.html index 239d8d3663..bf60afc62d 100644 --- a/src/main/resources/templates/vouchers.html +++ b/src/main/resources/templates/vouchers.html @@ -45,7 +45,7 @@

ALL VOUCHERS

- + From c1b4fc76d2bb9499c979579d647dd1f61d6291b8 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Fri, 3 Nov 2023 10:53:43 +0900 Subject: [PATCH 21/73] =?UTF-8?q?feat:=20voucher=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/voucher-detail.html | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/resources/templates/voucher-detail.html diff --git a/src/main/resources/templates/voucher-detail.html b/src/main/resources/templates/voucher-detail.html new file mode 100644 index 0000000000..74fc07c144 --- /dev/null +++ b/src/main/resources/templates/voucher-detail.html @@ -0,0 +1,54 @@ + + + + + + + + Document + + + + + +
+

VOUCHER-detail

+ + + + + + + + + + + + + + + +
VoucherIdVoucherTypediscountValue
+
+ + \ No newline at end of file From acab01cd34cbcb506d4b6d309134cdfe85d5b589 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Fri, 3 Nov 2023 14:22:16 +0900 Subject: [PATCH 22/73] =?UTF-8?q?feat:=20voucher=20=EC=82=AD=EC=A0=9C=20ap?= =?UTF-8?q?i=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../voucher/controller/VoucherPageController.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java index 769dd0858b..7caeb8cf29 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -2,10 +2,10 @@ import org.programmers.springorder.voucher.dto.VoucherRequestDto; import org.programmers.springorder.voucher.dto.VoucherResponseDto; -import org.programmers.springorder.voucher.model.Voucher; import org.programmers.springorder.voucher.service.VoucherService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -42,10 +42,15 @@ public String createVoucher(VoucherRequestDto voucherRequestDto) { @GetMapping("/vouchers/{voucherId}") public String getVoucherDetail(@PathVariable UUID voucherId, Model model){ - VoucherResponseDto voucher = voucherService.getVoucherById(voucherId); - model.addAttribute("voucher", voucher); - return "voucher-detail"; + VoucherResponseDto voucher = voucherService.getVoucherById(voucherId); + model.addAttribute("voucher", voucher); + return "voucher-detail"; } + @DeleteMapping("/vouchers/{voucherId}") + public String deleteVoucher(@PathVariable UUID voucherId){ + voucherService.deleteVoucher(voucherId); + return "redirect:vouchers"; + } } From 574c0b91fcf0f18e20d4dac476d868d75b0441c8 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sat, 4 Nov 2023 23:59:57 +0900 Subject: [PATCH 23/73] =?UTF-8?q?feat:=20voucher=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/voucher-detail.html | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/resources/templates/voucher-detail.html b/src/main/resources/templates/voucher-detail.html index 74fc07c144..5f967a7135 100644 --- a/src/main/resources/templates/voucher-detail.html +++ b/src/main/resources/templates/voucher-detail.html @@ -13,6 +13,24 @@ margin: 0 50px; } + + @@ -39,6 +57,7 @@

VOUCHER-detail

VoucherId VoucherType discountValue + delete @@ -46,6 +65,7 @@

VOUCHER-detail

+ From a690cd94ed032691a1bc0e66239b32c9ef74643a Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 14:59:17 +0900 Subject: [PATCH 24/73] =?UTF-8?q?feat:=20voucher=20=EC=82=AD=EC=A0=9C=20ap?= =?UTF-8?q?i=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/VoucherPageController.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java index 7caeb8cf29..93b19379a3 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -1,11 +1,13 @@ package org.programmers.springorder.voucher.controller; +import jakarta.servlet.http.HttpServletRequest; import org.programmers.springorder.voucher.dto.VoucherRequestDto; import org.programmers.springorder.voucher.dto.VoucherResponseDto; import org.programmers.springorder.voucher.service.VoucherService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -15,6 +17,7 @@ @Controller public class VoucherPageController { + private static final Logger log = LoggerFactory.getLogger(VoucherPageController.class); private final VoucherService voucherService; @@ -37,20 +40,20 @@ public String getNewVoucherPage(){ @PostMapping("/vouchers") public String createVoucher(VoucherRequestDto voucherRequestDto) { voucherService.saveNewVoucher(voucherRequestDto); - return "redirect:vouchers"; + return "redirect:/vouchers"; } @GetMapping("/vouchers/{voucherId}") - public String getVoucherDetail(@PathVariable UUID voucherId, Model model){ + public String getVoucherDetail(@PathVariable UUID voucherId, Model model, HttpServletRequest request){ VoucherResponseDto voucher = voucherService.getVoucherById(voucherId); model.addAttribute("voucher", voucher); return "voucher-detail"; } - @DeleteMapping("/vouchers/{voucherId}") - public String deleteVoucher(@PathVariable UUID voucherId){ - voucherService.deleteVoucher(voucherId); - return "redirect:vouchers"; + @PostMapping("/vouchers/{voucherId}") + public String deleteVoucher(@PathVariable String voucherId, HttpServletRequest request){ + voucherService.deleteVoucher(UUID.fromString(voucherId)); + return "redirect:/vouchers"; } } From c47a0fda945952efec260887aee4256e9d815e3d Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 15:27:06 +0900 Subject: [PATCH 25/73] =?UTF-8?q?refactor:=20double=20brace=EB=A5=BC=20?= =?UTF-8?q?=EC=9D=B4=EC=9A=A9=ED=95=9C=20HashMap=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20=EB=B6=80=EB=B6=84=20=EB=B3=80=EA=B2=BD=20double=20?= =?UTF-8?q?brace=20=EC=82=AC=EC=9A=A9=20=EC=8B=9C=20=EB=82=B4=EB=B6=80?= =?UTF-8?q?=EC=A0=81=EC=9C=BC=EB=A1=9C=20inner=20class=EB=A5=BC=20?= =?UTF-8?q?=ED=99=9C=EC=9A=A9=ED=95=98=EC=97=AC=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=A9=94=EB=AA=A8=EB=A6=AC=20=EB=88=84?= =?UTF-8?q?=EC=88=98=20=EB=AC=B8=EC=A0=9C=20(=EC=99=B8=EB=B6=80=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=9D=B8=EC=8A=A4=ED=84=B4?= =?UTF-8?q?=EC=8A=A4=EB=A5=BC=20=EC=A7=80=EC=86=8D=EC=A0=81=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=B0=B8=EC=A1=B0=ED=95=B4=EC=84=9C=20=EC=82=AC?= =?UTF-8?q?=EB=9D=BC=EC=A7=80=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/JdbcCustomerRepository.java | 19 ++++++----- .../repository/JdbcVoucherRepository.java | 34 ++++++++++--------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/programmers/springorder/customer/repository/JdbcCustomerRepository.java b/src/main/java/org/programmers/springorder/customer/repository/JdbcCustomerRepository.java index 0a3dd52d8a..98e917670c 100644 --- a/src/main/java/org/programmers/springorder/customer/repository/JdbcCustomerRepository.java +++ b/src/main/java/org/programmers/springorder/customer/repository/JdbcCustomerRepository.java @@ -63,21 +63,22 @@ public Customer insert(Customer customer) { return customer; } - public void clear(){ + public void clear() { jdbcTemplate.getJdbcOperations().update("delete from customers"); } + private Map toParamMap(Customer customer) { - return new HashMap<>() {{ - put("customerId", customer.getCustomerId().toString().getBytes()); - put("customerName", customer.getName()); - put("customerType", customer.getCustomerType().name()); - }}; + Map map = new HashMap<>(); + map.put("customerId", customer.getCustomerId().toString().getBytes()); + map.put("customerName", customer.getName()); + map.put("customerType", customer.getCustomerType().name()); + return map; } private Map findByIdMap(UUID customerId) { - return new HashMap<>() {{ - put("customerId", customerId.toString().getBytes()); - }}; + Map map = new HashMap<>(); + map.put("customerId", customerId.toString().getBytes()); + return map; } static UUID toUUID(byte[] bytes) { diff --git a/src/main/java/org/programmers/springorder/voucher/repository/JdbcVoucherRepository.java b/src/main/java/org/programmers/springorder/voucher/repository/JdbcVoucherRepository.java index ba71c9d076..3fc00bb708 100644 --- a/src/main/java/org/programmers/springorder/voucher/repository/JdbcVoucherRepository.java +++ b/src/main/java/org/programmers/springorder/voucher/repository/JdbcVoucherRepository.java @@ -13,6 +13,7 @@ import java.nio.ByteBuffer; import java.util.*; + @Profile("default") @Repository public class JdbcVoucherRepository implements VoucherRepository { @@ -23,7 +24,8 @@ public class JdbcVoucherRepository implements VoucherRepository { private final String UPDATE_VOUCER_OWNER = "update vouchers set customer_id = UUID_TO_BIN(:customerId) where voucher_id = UUID_TO_BIN(:voucherId)"; private final String FIND_ALL = "select * from vouchers"; private final String FIND_BY_VOUCHER_ID = "select * from vouchers where voucher_id = UUID_TO_BIN(:voucherId)"; - private final String FIND_BY_CUSTOMER_ID= "select * from vouchers where customer_id = UUID_TO_BIN(:customerId)"; + private final String FIND_BY_CUSTOMER_ID = "select * from vouchers where customer_id = UUID_TO_BIN(:customerId)"; + public JdbcVoucherRepository(NamedParameterJdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } @@ -31,7 +33,7 @@ public JdbcVoucherRepository(NamedParameterJdbcTemplate jdbcTemplate) { @Override public Voucher save(Voucher voucher) { int update = jdbcTemplate.update(INSERT, toParamMap(voucher)); - if( update != 1){ + if (update != 1) { throw new RuntimeException("Nothing was inserted"); } return voucher; @@ -44,12 +46,12 @@ public List findAll() { @Override public Optional findById(UUID voucherId) { - try{ + try { return Optional.ofNullable(jdbcTemplate.queryForObject( FIND_BY_VOUCHER_ID, Collections.singletonMap("voucherId", voucherId.toString().getBytes()), voucherRowMapper)); - } catch (EmptyResultDataAccessException e) { + } catch (EmptyResultDataAccessException e) { logger.error("Got empty result", e); return Optional.empty(); } @@ -59,7 +61,7 @@ public Optional findById(UUID voucherId) { @Override public Voucher updateVoucherOwner(Voucher voucher, Customer customer) { int update = jdbcTemplate.update(UPDATE_VOUCER_OWNER, toUpdateOwnerMap(voucher, customer)); - if( update != 1){ + if (update != 1) { throw new RuntimeException("Nothing was inserted"); } return voucher; @@ -80,23 +82,23 @@ public void deleteVoucher(Voucher voucher) { toParamMap(voucher)); } - public void clear(){ + public void clear() { jdbcTemplate.getJdbcOperations().update("delete from vouchers"); } private Map toParamMap(Voucher voucher) { - return new HashMap<>() {{ - put("voucherId", voucher.getVoucherId().toString().getBytes()); - put("discountValue", voucher.getDiscountValue()); - put("voucherType", voucher.getVoucherType().name()); - }}; + Map map = new HashMap<>(); + map.put("voucherId", voucher.getVoucherId().toString().getBytes()); + map.put("discountValue", voucher.getDiscountValue()); + map.put("voucherType", voucher.getVoucherType().name()); + return map; } - private Map toUpdateOwnerMap(Voucher voucher,Customer customer) { - return new HashMap<>() {{ - put("voucherId", voucher.getVoucherId().toString().getBytes()); - put("customerId", customer.getCustomerId().toString().getBytes()); - }}; + private Map toUpdateOwnerMap(Voucher voucher, Customer customer) { + Map map = new HashMap<>(); + map.put("voucherId", voucher.getVoucherId().toString().getBytes()); + map.put("customerId", customer.getCustomerId().toString().getBytes()); + return map; } private final RowMapper voucherRowMapper = (resultSet, rowNum) -> { From 351a4b2102184edc405459483cd31277a31680ae Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 15:37:25 +0900 Subject: [PATCH 26/73] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=EB=90=98=EC=97=88=EA=B1=B0=EB=82=98=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20id=EC=9D=98?= =?UTF-8?q?=20voucher=20=EA=B2=80=EC=83=89=20=EC=8B=9C=20=EB=B3=B4?= =?UTF-8?q?=EC=97=AC=EC=A3=BC=EB=8A=94=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/FileCustomerRepository.java | 2 +- .../controller/VoucherPageController.java | 12 +++- src/main/resources/templates/no-voucher.html | 56 +++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/templates/no-voucher.html diff --git a/src/main/java/org/programmers/springorder/customer/repository/FileCustomerRepository.java b/src/main/java/org/programmers/springorder/customer/repository/FileCustomerRepository.java index cbc4aa7338..0880fbdd16 100644 --- a/src/main/java/org/programmers/springorder/customer/repository/FileCustomerRepository.java +++ b/src/main/java/org/programmers/springorder/customer/repository/FileCustomerRepository.java @@ -55,7 +55,7 @@ public List findAll() { return Collections.unmodifiableList(customerList); } - //TODO: 추후 구현 예정 + @Override public Optional findByID(UUID customerId) { return findAll().stream() diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java index 93b19379a3..b978a6acf4 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -45,15 +45,23 @@ public String createVoucher(VoucherRequestDto voucherRequestDto) { @GetMapping("/vouchers/{voucherId}") public String getVoucherDetail(@PathVariable UUID voucherId, Model model, HttpServletRequest request){ + try { VoucherResponseDto voucher = voucherService.getVoucherById(voucherId); model.addAttribute("voucher", voucher); return "voucher-detail"; + }catch (RuntimeException e){ + return "no-voucher"; + } } @PostMapping("/vouchers/{voucherId}") public String deleteVoucher(@PathVariable String voucherId, HttpServletRequest request){ - voucherService.deleteVoucher(UUID.fromString(voucherId)); - return "redirect:/vouchers"; + try { + voucherService.deleteVoucher(UUID.fromString(voucherId)); + return "redirect:/vouchers"; + } catch (RuntimeException e){ + return "no-voucher"; + } } } diff --git a/src/main/resources/templates/no-voucher.html b/src/main/resources/templates/no-voucher.html new file mode 100644 index 0000000000..df990e4cb0 --- /dev/null +++ b/src/main/resources/templates/no-voucher.html @@ -0,0 +1,56 @@ + + + + + + + + Document + + + + + + + + + + \ No newline at end of file From 6289fe6506d5306d00aa721c5326aeb7c1c8b22e Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 15:46:53 +0900 Subject: [PATCH 27/73] =?UTF-8?q?feat:=20customer=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=9D=84=20=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20api=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CustomerPageController.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java diff --git a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java new file mode 100644 index 0000000000..eae7ac781d --- /dev/null +++ b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java @@ -0,0 +1,30 @@ +package org.programmers.springorder.customer.controller; + +import org.programmers.springorder.console.Console; +import org.programmers.springorder.customer.dto.CustomerResponseDto; +import org.programmers.springorder.customer.service.CustomerService; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +import java.util.List; + +@Controller +public class CustomerPageController { + private final Console console; + + private final CustomerService customerService; + + public CustomerPageController(Console console, CustomerService customerService) { + this.console = console; + this.customerService = customerService; + } + + @GetMapping("/customers") + public String getCustomerListPage(Model model){ + List allCustomers = customerService.getAllCustomers(); + model.addAttribute("customerList", allCustomers); + return "customers"; + } + +} From 5aa2bf230cad14d85bc451a4ce8d56480a654152 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 15:47:11 +0900 Subject: [PATCH 28/73] =?UTF-8?q?feat:=20customer=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=9D=84=20=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EB=A1=9C=EC=A7=81=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/customer/service/CustomerService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/programmers/springorder/customer/service/CustomerService.java b/src/main/java/org/programmers/springorder/customer/service/CustomerService.java index 21c5a3442e..43e659eadd 100644 --- a/src/main/java/org/programmers/springorder/customer/service/CustomerService.java +++ b/src/main/java/org/programmers/springorder/customer/service/CustomerService.java @@ -37,4 +37,11 @@ public CustomerResponseDto findOwnerOfVoucher(UUID voucherId){ .map(CustomerResponseDto::of) .orElseThrow(() -> new RuntimeException("해당 고객을 찾을 수 없습니다.")); } + + public List getAllCustomers() { + return customerRepository.findAll() + .stream() + .map(CustomerResponseDto::of) + .toList(); + } } From d48a364dde6d35f8912fb159104126fd8cc92407 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 15:47:42 +0900 Subject: [PATCH 29/73] =?UTF-8?q?feat:=20customer=20=EB=AA=A9=EB=A1=9D?= =?UTF-8?q?=EC=9D=84=20=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=9E=91=EC=84=B1,=20Customer=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=20=EB=84=A3?= =?UTF-8?q?=EA=B8=B0=20=EC=9C=84=ED=95=9C=20getter=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customer/dto/CustomerResponseDto.java | 8 +++ src/main/resources/templates/customers.html | 56 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/main/resources/templates/customers.html diff --git a/src/main/java/org/programmers/springorder/customer/dto/CustomerResponseDto.java b/src/main/java/org/programmers/springorder/customer/dto/CustomerResponseDto.java index 59a8685cd4..c4ec069a28 100644 --- a/src/main/java/org/programmers/springorder/customer/dto/CustomerResponseDto.java +++ b/src/main/java/org/programmers/springorder/customer/dto/CustomerResponseDto.java @@ -24,6 +24,14 @@ public UUID getCustomerId() { return customerId; } + public String getName() { + return name; + } + + public String getCustomerType() { + return customerType; + } + @Override public String toString() { return "customerId : " + customerId +'\n' + diff --git a/src/main/resources/templates/customers.html b/src/main/resources/templates/customers.html new file mode 100644 index 0000000000..31188c5de2 --- /dev/null +++ b/src/main/resources/templates/customers.html @@ -0,0 +1,56 @@ + + + + + + + + Document + + + + + +
+

Customers

+ + + + + + + + + + + + + + + + + +
#CustomerIdNameCustomerType
+
+ + \ No newline at end of file From b3223fd6850bddc7af2d792f5740467ad83a6c2d Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:22:58 +0900 Subject: [PATCH 30/73] =?UTF-8?q?feat:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20?= =?UTF-8?q?=EA=B3=A0=EA=B0=9D=20=EC=83=9D=EC=84=B1=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=9D=B4=EB=8F=99=20=ED=95=AD=EB=AA=A9=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/customers.html | 1 + src/main/resources/templates/new-voucher.html | 1 + src/main/resources/templates/no-voucher.html | 1 + src/main/resources/templates/voucher-detail.html | 1 + src/main/resources/templates/vouchers.html | 3 ++- 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/resources/templates/customers.html b/src/main/resources/templates/customers.html index 31188c5de2..6f69eace36 100644 --- a/src/main/resources/templates/customers.html +++ b/src/main/resources/templates/customers.html @@ -27,6 +27,7 @@ diff --git a/src/main/resources/templates/new-voucher.html b/src/main/resources/templates/new-voucher.html index 7180893a70..7c7fb1553a 100644 --- a/src/main/resources/templates/new-voucher.html +++ b/src/main/resources/templates/new-voucher.html @@ -27,6 +27,7 @@ diff --git a/src/main/resources/templates/no-voucher.html b/src/main/resources/templates/no-voucher.html index df990e4cb0..6d81482e79 100644 --- a/src/main/resources/templates/no-voucher.html +++ b/src/main/resources/templates/no-voucher.html @@ -45,6 +45,7 @@ diff --git a/src/main/resources/templates/voucher-detail.html b/src/main/resources/templates/voucher-detail.html index 5f967a7135..227b71d0b0 100644 --- a/src/main/resources/templates/voucher-detail.html +++ b/src/main/resources/templates/voucher-detail.html @@ -45,6 +45,7 @@ diff --git a/src/main/resources/templates/vouchers.html b/src/main/resources/templates/vouchers.html index bf60afc62d..6171df6ed8 100644 --- a/src/main/resources/templates/vouchers.html +++ b/src/main/resources/templates/vouchers.html @@ -26,7 +26,8 @@ From 2a623438103875b632430cf102592447440d7709 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:23:30 +0900 Subject: [PATCH 31/73] =?UTF-8?q?chore:=20voucher=20=EC=83=9D=EC=84=B1=20?= =?UTF-8?q?=EC=8B=9C=20=EB=A1=9C=EA=B7=B8=20=EC=B0=8D=ED=9E=88=EB=8A=94=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../programmers/springorder/voucher/service/VoucherService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/programmers/springorder/voucher/service/VoucherService.java b/src/main/java/org/programmers/springorder/voucher/service/VoucherService.java index aa7fe8263a..85546ce08f 100644 --- a/src/main/java/org/programmers/springorder/voucher/service/VoucherService.java +++ b/src/main/java/org/programmers/springorder/voucher/service/VoucherService.java @@ -37,7 +37,6 @@ public List getAllVoucher() { public void saveNewVoucher(VoucherRequestDto voucherDto) { Voucher voucher = Voucher.of(UUID.randomUUID(), voucherDto); voucherRepository.save(voucher); - log.info("등록된 Voucher => iD: {}, type: {}, value: {}", voucher.getVoucherId(), voucher.getVoucherType(), voucher.getDiscountValue()); } public void allocateVoucher(UUID voucherId, UUID customerId) { From 1f0a4145283f4aa97f41292997b5d05606c31b57 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:24:07 +0900 Subject: [PATCH 32/73] =?UTF-8?q?feat:=20=EA=B3=A0=EA=B0=9D=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B0=8F=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customer/controller/CustomerPageController.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java index eae7ac781d..abbeec702e 100644 --- a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java +++ b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java @@ -1,11 +1,13 @@ package org.programmers.springorder.customer.controller; import org.programmers.springorder.console.Console; +import org.programmers.springorder.customer.dto.CustomerRequestDto; import org.programmers.springorder.customer.dto.CustomerResponseDto; import org.programmers.springorder.customer.service.CustomerService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import java.util.List; @@ -27,4 +29,15 @@ public String getCustomerListPage(Model model){ return "customers"; } + @GetMapping("/new-customer") + public String getNewCustomerPage(Model model){ + return "new-customer"; + } + + @PostMapping("/customers") + public String enrollCustomer(CustomerRequestDto requestDto){ + customerService.newCustomer(requestDto); + return "redirect:/customers"; + } + } From ad4ab5822c775f1862539489e46922a33063ce9b Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:24:24 +0900 Subject: [PATCH 33/73] =?UTF-8?q?feat:=20=EA=B3=A0=EA=B0=9D=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9D=84=20=EC=9C=84=ED=95=9C=20dto=20record=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/customer/dto/CustomerRequestDto.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/org/programmers/springorder/customer/dto/CustomerRequestDto.java diff --git a/src/main/java/org/programmers/springorder/customer/dto/CustomerRequestDto.java b/src/main/java/org/programmers/springorder/customer/dto/CustomerRequestDto.java new file mode 100644 index 0000000000..041775376d --- /dev/null +++ b/src/main/java/org/programmers/springorder/customer/dto/CustomerRequestDto.java @@ -0,0 +1,6 @@ +package org.programmers.springorder.customer.dto; + +import org.programmers.springorder.customer.model.CustomerType; + +public record CustomerRequestDto(String name, CustomerType customerType) { +} From fbf567c776c0c00097297d7dd3b41090283a8f92 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:24:37 +0900 Subject: [PATCH 34/73] =?UTF-8?q?feat:=20=EA=B3=A0=EA=B0=9D=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/customer/service/CustomerService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/programmers/springorder/customer/service/CustomerService.java b/src/main/java/org/programmers/springorder/customer/service/CustomerService.java index 43e659eadd..9c46980dc3 100644 --- a/src/main/java/org/programmers/springorder/customer/service/CustomerService.java +++ b/src/main/java/org/programmers/springorder/customer/service/CustomerService.java @@ -1,6 +1,8 @@ package org.programmers.springorder.customer.service; +import org.programmers.springorder.customer.dto.CustomerRequestDto; import org.programmers.springorder.customer.dto.CustomerResponseDto; +import org.programmers.springorder.customer.model.Customer; import org.programmers.springorder.customer.repository.CustomerRepository; import org.programmers.springorder.voucher.model.Voucher; import org.programmers.springorder.voucher.repository.VoucherRepository; @@ -44,4 +46,12 @@ public List getAllCustomers() { .map(CustomerResponseDto::of) .toList(); } + + public void newCustomer(CustomerRequestDto requestDto) { + Customer customer = Customer.toCustomer( + UUID.randomUUID(), + requestDto.name(), + requestDto.customerType()); + customerRepository.insert(customer); + } } From 1df00a54ceaa9d9273ac798d320469389f8b00dc Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:24:50 +0900 Subject: [PATCH 35/73] =?UTF-8?q?feat:=20=EA=B3=A0=EA=B0=9D=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/new-customer.html | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/resources/templates/new-customer.html diff --git a/src/main/resources/templates/new-customer.html b/src/main/resources/templates/new-customer.html new file mode 100644 index 0000000000..6709d8f8c5 --- /dev/null +++ b/src/main/resources/templates/new-customer.html @@ -0,0 +1,52 @@ + + + + + + + + Document + + + + + +
+

MAKE NEW VOUCHER

+ +
+ +
+ + +
+ +
+
+ + \ No newline at end of file From 52b3520fc7aab862df75756fcce68f5abd523a95 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:47:51 +0900 Subject: [PATCH 36/73] =?UTF-8?q?feat:=20customer=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B0=80=EC=A0=B8=EC=98=A4?= =?UTF-8?q?=EA=B8=B0=20api=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CustomerPageController.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java index abbeec702e..049dcfd88f 100644 --- a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java +++ b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java @@ -1,25 +1,28 @@ package org.programmers.springorder.customer.controller; -import org.programmers.springorder.console.Console; import org.programmers.springorder.customer.dto.CustomerRequestDto; import org.programmers.springorder.customer.dto.CustomerResponseDto; import org.programmers.springorder.customer.service.CustomerService; +import org.programmers.springorder.voucher.dto.VoucherResponseDto; +import org.programmers.springorder.voucher.service.VoucherService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import java.util.List; +import java.util.UUID; @Controller public class CustomerPageController { - private final Console console; private final CustomerService customerService; + private final VoucherService voucherService; - public CustomerPageController(Console console, CustomerService customerService) { - this.console = console; + public CustomerPageController(CustomerService customerService, VoucherService voucherService) { this.customerService = customerService; + this.voucherService = voucherService; } @GetMapping("/customers") @@ -29,6 +32,15 @@ public String getCustomerListPage(Model model){ return "customers"; } + @GetMapping("/customers/{customerId}") + public String getCustomerListPage(@PathVariable UUID customerId, Model model){ + CustomerResponseDto customer = customerService.findCustomer(customerId); + List customerOwnedVouchers = voucherService.getCustomerOwnedVouchers(customerId); + model.addAttribute("customer", customer); + model.addAttribute("customerVoucherList", customerOwnedVouchers); + return "customer-detail"; + } + @GetMapping("/new-customer") public String getNewCustomerPage(Model model){ return "new-customer"; From ac9547c3aec00a5733faeb40392a063e8ea7f3f6 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:50:30 +0900 Subject: [PATCH 37/73] =?UTF-8?q?feat:=20=EA=B3=A0=EA=B0=9D=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EB=8A=94=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/customer/service/CustomerService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/programmers/springorder/customer/service/CustomerService.java b/src/main/java/org/programmers/springorder/customer/service/CustomerService.java index 9c46980dc3..96afb8edbd 100644 --- a/src/main/java/org/programmers/springorder/customer/service/CustomerService.java +++ b/src/main/java/org/programmers/springorder/customer/service/CustomerService.java @@ -1,5 +1,6 @@ package org.programmers.springorder.customer.service; +import org.programmers.springorder.consts.ErrorMessage; import org.programmers.springorder.customer.dto.CustomerRequestDto; import org.programmers.springorder.customer.dto.CustomerResponseDto; import org.programmers.springorder.customer.model.Customer; @@ -54,4 +55,10 @@ public void newCustomer(CustomerRequestDto requestDto) { requestDto.customerType()); customerRepository.insert(customer); } + + public CustomerResponseDto findCustomer(UUID customerId){ + return customerRepository.findByID(customerId) + .map(CustomerResponseDto::of) + .orElseThrow(() -> new RuntimeException(ErrorMessage.CUSTOMER_NOT_FOUND)); + } } From 54a0120f8f14e760e694fd4f2a84cea659353983 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:50:56 +0900 Subject: [PATCH 38/73] =?UTF-8?q?feat:=20=EA=B3=A0=EA=B0=9D=EC=9D=84=20?= =?UTF-8?q?=EC=A7=80=20=EB=AA=BB=ED=95=A0=20=EC=8B=9C=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EB=8A=94=20errormessage=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/programmers/springorder/consts/ErrorMessage.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/programmers/springorder/consts/ErrorMessage.java b/src/main/java/org/programmers/springorder/consts/ErrorMessage.java index 219e171bdc..bc59578980 100644 --- a/src/main/java/org/programmers/springorder/consts/ErrorMessage.java +++ b/src/main/java/org/programmers/springorder/consts/ErrorMessage.java @@ -4,6 +4,8 @@ public class ErrorMessage { private ErrorMessage(){} + public static final String CUSTOMER_NOT_FOUND = "등록된 회원이 존재하지 않습니다."; + public static final String VOUCHER_NOT_EXIST_MESSAGE = "등록된 바우처가 존재하지 않습니다."; public static final String EMPTY_VALUE_MESSAGE = "값이 존재하지 않습니다. 다시 입력해주세요."; From f2259de7d175214a1eec79fffefc54f3d13b3ed1 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:51:37 +0900 Subject: [PATCH 39/73] =?UTF-8?q?feat:=20=EA=B3=A0=EA=B0=9D=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=B0=8F=20=EA=B3=A0?= =?UTF-8?q?=EA=B0=9D=20=EC=83=81=EC=84=B8=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=93=A4=EC=96=B4=EA=B0=88=20=EC=88=98=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/customer-detail.html | 79 +++++++++++++++++++ src/main/resources/templates/customers.html | 2 +- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/templates/customer-detail.html diff --git a/src/main/resources/templates/customer-detail.html b/src/main/resources/templates/customer-detail.html new file mode 100644 index 0000000000..040ee25b44 --- /dev/null +++ b/src/main/resources/templates/customer-detail.html @@ -0,0 +1,79 @@ + + + + + + + + Document + + + + + + + +
+

CUSTOMER-detail

+ customerId:
+ customerName:
+ customerType:
+ +

Owned VoucherList

+ + + + + + + + + + + + + + + + +
NameCustomerTypedelete
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/customers.html b/src/main/resources/templates/customers.html index 6f69eace36..bbe1b576d3 100644 --- a/src/main/resources/templates/customers.html +++ b/src/main/resources/templates/customers.html @@ -46,7 +46,7 @@

Customers

- + From d5b64d8a76302fc1a1e5d105b782d6725a3b33af Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:52:49 +0900 Subject: [PATCH 40/73] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20Model=20=EC=9D=B8=EC=88=98=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/customer/controller/CustomerPageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java index 049dcfd88f..a6f62204dc 100644 --- a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java +++ b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java @@ -42,7 +42,7 @@ public String getCustomerListPage(@PathVariable UUID customerId, Model model){ } @GetMapping("/new-customer") - public String getNewCustomerPage(Model model){ + public String getNewCustomerPage(){ return "new-customer"; } From 928a67ec6b31e4a9cdbb316feb45330f1a529be7 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:57:09 +0900 Subject: [PATCH 41/73] =?UTF-8?q?feat:=20blacklist=EB=A5=BC=20=EB=B6=88?= =?UTF-8?q?=EB=9F=AC=EC=98=A4=EB=8A=94=20=ED=8E=98=EC=9D=B4=EC=A7=80=20api?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customer/controller/CustomerPageController.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java index a6f62204dc..63bec313a1 100644 --- a/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java +++ b/src/main/java/org/programmers/springorder/customer/controller/CustomerPageController.java @@ -32,6 +32,13 @@ public String getCustomerListPage(Model model){ return "customers"; } + @GetMapping("/blackCustomers") + public String getBlackCustomerListPage(Model model){ + List allCustomers = customerService.getBlackList(); + model.addAttribute("customerList", allCustomers); + return "customers"; + } + @GetMapping("/customers/{customerId}") public String getCustomerListPage(@PathVariable UUID customerId, Model model){ CustomerResponseDto customer = customerService.findCustomer(customerId); From 320a0f0dfed540cc632f68604ea395a9d09e2bb3 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 16:57:24 +0900 Subject: [PATCH 42/73] =?UTF-8?q?feat:=20black=20list=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EB=9D=BC=EC=9A=B0=ED=8C=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/customer-detail.html | 1 + src/main/resources/templates/customers.html | 1 + src/main/resources/templates/new-customer.html | 1 + src/main/resources/templates/new-voucher.html | 1 + src/main/resources/templates/no-voucher.html | 1 + src/main/resources/templates/voucher-detail.html | 1 + src/main/resources/templates/vouchers.html | 1 + 7 files changed, 7 insertions(+) diff --git a/src/main/resources/templates/customer-detail.html b/src/main/resources/templates/customer-detail.html index 040ee25b44..3251fd8208 100644 --- a/src/main/resources/templates/customer-detail.html +++ b/src/main/resources/templates/customer-detail.html @@ -46,6 +46,7 @@ new-voucher Customer new-customer + black-customers diff --git a/src/main/resources/templates/customers.html b/src/main/resources/templates/customers.html index bbe1b576d3..b4fccbb8b7 100644 --- a/src/main/resources/templates/customers.html +++ b/src/main/resources/templates/customers.html @@ -28,6 +28,7 @@ new-voucher Customer new-customer + black-customers diff --git a/src/main/resources/templates/new-customer.html b/src/main/resources/templates/new-customer.html index 6709d8f8c5..4cfbf3358d 100644 --- a/src/main/resources/templates/new-customer.html +++ b/src/main/resources/templates/new-customer.html @@ -28,6 +28,7 @@ new-voucher Customer new-customer + black-customers diff --git a/src/main/resources/templates/new-voucher.html b/src/main/resources/templates/new-voucher.html index 7c7fb1553a..314c20020c 100644 --- a/src/main/resources/templates/new-voucher.html +++ b/src/main/resources/templates/new-voucher.html @@ -28,6 +28,7 @@ new-voucher Customer new-customer + black-customers diff --git a/src/main/resources/templates/no-voucher.html b/src/main/resources/templates/no-voucher.html index 6d81482e79..7e7ef360b0 100644 --- a/src/main/resources/templates/no-voucher.html +++ b/src/main/resources/templates/no-voucher.html @@ -46,6 +46,7 @@ new-voucher Customer new-customer + black-customers diff --git a/src/main/resources/templates/voucher-detail.html b/src/main/resources/templates/voucher-detail.html index 227b71d0b0..3a9832c547 100644 --- a/src/main/resources/templates/voucher-detail.html +++ b/src/main/resources/templates/voucher-detail.html @@ -46,6 +46,7 @@ new-voucher Customer new-customer + black-customers diff --git a/src/main/resources/templates/vouchers.html b/src/main/resources/templates/vouchers.html index 6171df6ed8..edb40a7e99 100644 --- a/src/main/resources/templates/vouchers.html +++ b/src/main/resources/templates/vouchers.html @@ -28,6 +28,7 @@ new-voucher customer new-customer + black-customers From 6ae254f61c748844bf97c02f76e23a2d52748802 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 22:53:37 +0900 Subject: [PATCH 43/73] =?UTF-8?q?refactor:=20dto=20record=20->=20class?= =?UTF-8?q?=EB=A1=9C=20=EC=9E=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../voucher/dto/VoucherResponseDto.java | 57 +++++++++++++++++-- .../voucher/service/VoucherServiceTest.java | 4 +- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/programmers/springorder/voucher/dto/VoucherResponseDto.java b/src/main/java/org/programmers/springorder/voucher/dto/VoucherResponseDto.java index d52cfbb00b..97e377a91d 100644 --- a/src/main/java/org/programmers/springorder/voucher/dto/VoucherResponseDto.java +++ b/src/main/java/org/programmers/springorder/voucher/dto/VoucherResponseDto.java @@ -2,25 +2,74 @@ import org.programmers.springorder.voucher.model.Voucher; +import java.util.Objects; import java.util.UUID; -public record VoucherResponseDto( UUID voucherId, long discountValue, String voucherType){ +public final class VoucherResponseDto { + private final UUID voucherId; + private final long discountValue; + private final String voucherType; + private final String customerId; + public VoucherResponseDto(UUID voucherId, long discountValue, String voucherType, UUID customerId) { + this.voucherId = voucherId; + this.discountValue = discountValue; + this.voucherType = voucherType; + if (customerId != null) { + this.customerId = customerId.toString(); + } else { + this.customerId = ""; + } + } - public static VoucherResponseDto of(Voucher voucher){ + public static VoucherResponseDto of(Voucher voucher) { return new VoucherResponseDto( voucher.getVoucherId(), voucher.getDiscountValue(), - voucher.getVoucherType().name()); + voucher.getVoucherType().name(), + voucher.getCustomerId()); } @Override public String toString() { return "ID : " + voucherId + '\n' + "Type : " + voucherType + '\n' + - "Value : " + discountValue +'\n'+ + "Value : " + discountValue + '\n' + "=============================="; } + + public UUID getVoucherId() { + return voucherId; + } + + public long getDiscountValue() { + return discountValue; + } + + public String getVoucherType() { + return voucherType; + } + + public String getCustomerId() { + return customerId; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null || obj.getClass() != this.getClass()) return false; + var that = (VoucherResponseDto) obj; + return Objects.equals(this.voucherId, that.voucherId) && + this.discountValue == that.discountValue && + Objects.equals(this.voucherType, that.voucherType) && + Objects.equals(this.customerId, that.customerId); + } + + @Override + public int hashCode() { + return Objects.hash(voucherId, discountValue, voucherType, customerId); + } + } diff --git a/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java b/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java index ac202fdb77..ece2a78f3a 100644 --- a/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java +++ b/src/test/java/org/programmers/springorder/voucher/service/VoucherServiceTest.java @@ -70,7 +70,7 @@ void getAllVoucher() { voucherRepository.save(Voucher.toVoucher(uuids.get(3), 2000, VoucherType.FIXED)); List allVoucher = voucherService.getAllVoucher(); - List rs = allVoucher.stream().map(VoucherResponseDto::voucherId).toList(); + List rs = allVoucher.stream().map(VoucherResponseDto::getVoucherId).toList(); assertThat(allVoucher).hasSize(4); assertThat(rs.containsAll(uuids)) @@ -191,7 +191,7 @@ public void customerOwnedVoucherServiceTest() { List customerOwnedVouchers = voucherService.getCustomerOwnedVouchers(customer.getCustomerId()); List foundVoucherId = customerOwnedVouchers .stream() - .map(VoucherResponseDto::voucherId) + .map(VoucherResponseDto::getVoucherId) .toList(); assertThat(customerOwnedVouchers).hasSize(2); From f3adea98d0bb61f6ae09c237e1d5f008121cc49e Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 22:54:18 +0900 Subject: [PATCH 44/73] =?UTF-8?q?feat:=20default=20home=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20api,=20index.html=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springorder/HomeController.java | 12 ++++ src/main/resources/templates/index.html | 59 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 src/main/java/org/programmers/springorder/HomeController.java create mode 100644 src/main/resources/templates/index.html diff --git a/src/main/java/org/programmers/springorder/HomeController.java b/src/main/java/org/programmers/springorder/HomeController.java new file mode 100644 index 0000000000..38eac24f8b --- /dev/null +++ b/src/main/java/org/programmers/springorder/HomeController.java @@ -0,0 +1,12 @@ +package org.programmers.springorder; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class HomeController { + @GetMapping("/") + public String home(){ + return "index"; + } +} diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000000..93c2897b6b --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,59 @@ + + + + + + + + Document + + + + + + + +
+

Welcome-Voucher-Mangement

+
+ + \ No newline at end of file From e61363d47f278fe636c3e5432032182c682965cd Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 23:05:33 +0900 Subject: [PATCH 45/73] =?UTF-8?q?feat:=20voucher=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=9E=90=20=ED=95=A0=EB=8B=B9=20=ED=99=94=EB=A9=B4=20=EB=B0=8F?= =?UTF-8?q?=20=ED=95=A0=EB=8B=B9=20api=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/VoucherPageController.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java index b978a6acf4..2daaef46f5 100644 --- a/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java +++ b/src/main/java/org/programmers/springorder/voucher/controller/VoucherPageController.java @@ -8,9 +8,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.UUID; @@ -54,10 +52,29 @@ public String getVoucherDetail(@PathVariable UUID voucherId, Model model, HttpSe } } - @PostMapping("/vouchers/{voucherId}") - public String deleteVoucher(@PathVariable String voucherId, HttpServletRequest request){ + @DeleteMapping("/vouchers") + public String deleteVoucher(@RequestParam(name = "voucherId", required = false) UUID voucherId){ try { - voucherService.deleteVoucher(UUID.fromString(voucherId)); + voucherService.deleteVoucher(voucherId); + return "redirect:/vouchers"; + } catch (RuntimeException e){ + return "no-voucher"; + } + } + + @GetMapping("/voucherAllocate/{voucherId}") + public String getVoucherAllocatePage(@PathVariable UUID voucherId, Model model){ + try{ + model.addAttribute("voucherId", voucherId); + return "voucher-allocate"; + }catch (RuntimeException e){ + return "no-voucher"; + } + } + @PostMapping("/voucherAllocate/{voucherId}") + public String giveVoucher(@PathVariable UUID voucherId, @RequestParam UUID customerId){ + try { + voucherService.allocateVoucher(voucherId, customerId); return "redirect:/vouchers"; } catch (RuntimeException e){ return "no-voucher"; From 9c51d7626709e287eb486be3bc0c02c44259c227 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 23:06:05 +0900 Subject: [PATCH 46/73] =?UTF-8?q?feat:=20voucher=20=ED=95=A0=EB=8B=B9=20ui?= =?UTF-8?q?=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/voucher-allocate.html | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/main/resources/templates/voucher-allocate.html diff --git a/src/main/resources/templates/voucher-allocate.html b/src/main/resources/templates/voucher-allocate.html new file mode 100644 index 0000000000..04ab57de87 --- /dev/null +++ b/src/main/resources/templates/voucher-allocate.html @@ -0,0 +1,49 @@ + + + + + + + + Document + + + + +
+

VOUCHER-ALLOCATE

+
+ voucherId : ${voucherId} +
+ + +
+ +
+
+ + + From 55c86a4416d9e1c606121b76000bc362c7f63be9 Mon Sep 17 00:00:00 2001 From: shoeone96 Date: Sun, 5 Nov 2023 23:06:32 +0900 Subject: [PATCH 47/73] =?UTF-8?q?refactor:=20nav=20=EB=B0=94=20home=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/customer-detail.html | 9 +++--- src/main/resources/templates/customers.html | 3 +- .../resources/templates/new-customer.html | 3 +- src/main/resources/templates/new-voucher.html | 4 +-- src/main/resources/templates/no-voucher.html | 3 +- .../resources/templates/voucher-detail.html | 29 +++++++++++++------ src/main/resources/templates/vouchers.html | 12 ++++---- 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/main/resources/templates/customer-detail.html b/src/main/resources/templates/customer-detail.html index 3251fd8208..0473caff40 100644 --- a/src/main/resources/templates/customer-detail.html +++ b/src/main/resources/templates/customer-detail.html @@ -36,13 +36,14 @@