-
Notifications
You must be signed in to change notification settings - Fork 170
[5기 - 송인재] Spring Boot Part3 Weekly Mission 제출합니다. #971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
IjjS
wants to merge
82
commits into
prgrms-be-devcourse:IjjS
Choose a base branch
from
IjjS:main
base: IjjS
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 78 commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
d404a92
chore: add spring-boot-web dependency
IjjS c943839
feat: implement profile conditions
IjjS 52604fe
refactor: apply profile conditions usage
IjjS 7712ce8
feat: add voucher rest controller
IjjS 9eeab54
refactor: decide to add percentage mark in formatter
IjjS 4bba969
refactor: make VoucherResponse a record
IjjS 29353f9
enhance: add createdAt to Voucher
IjjS 1b9c323
chore: reset file
IjjS b39904f
feat: tell if the input is the same type of the voucher
IjjS a46bb32
feat: add findByType in repositories
IjjS 85a4cfa
feat: implement findByType service
IjjS 7a3e0e8
feat: map to find vouchers by type
IjjS 5b9f5aa
feat: implemented to find vouchers by createdAt
IjjS cb5e395
feat: tell the info regarding createdAt from Voucher
IjjS f141525
feat: add api endpoint to find vouchers by createdAt
IjjS 0d7498b
refactor: improve readability
IjjS 48bb995
refactor: edit request variables to be close to primitive for validation
IjjS 2fd2330
chore: add spring boot validation dependency
IjjS de91ea5
enhance: validate the create request from the controller
IjjS d0cee1d
enhance: add not null validation to SearchCreatedAtRequest
IjjS d0d6c67
chore: add jackson xml dataformat
IjjS c741401
enhance: produce responses in both json and xml
IjjS e45343f
feat: add controller advice to handle exceptions
IjjS 8ab774c
enhance: elaborate the validation messages
IjjS a1f83b4
enhance: attach response status
IjjS 29e4fae
fix: convert LocalDateTime to String
IjjS fbf474c
fix: apply the addition of createdAt
IjjS 8b6dce1
fix: apply the change of parameters of CreateRequest
IjjS f8e9c7d
chore: add thymeleaf dependency
IjjS ef8f2d5
feat: implement read all vouchers controller for web
IjjS 5e84284
feat: implement vouchers view
IjjS f6132aa
feat: implement find voucher by id controller for web
IjjS 1b70792
feat: implement home page
IjjS c06ba66
refactor: retrieve primitive types for parameters of dto
IjjS 5ff79eb
refactor: find voucher type regardless of the string form
IjjS 4687ebe
enhance: add validation to UpdateVoucherRequest
IjjS f82fb08
refactor: simplify finding voucher type process to avoid exception
IjjS 70074b4
feat: implement update controller
IjjS 042bc35
feat: implement voucher view to be enabled for update
IjjS 347ffdb
feat: create empty voucher for thymeleaf
IjjS f3a6e48
feat: implement create voucher controller
IjjS eb7873a
enhance: enhance voucher view to work for creation
IjjS 528539b
feat: implement delete voucher controller
IjjS 3f88909
enhance: add delete functionality to voucher view
IjjS 3a0fe24
feat: add deleted view
IjjS 4c010ac
feat: add onclick event callback for creation of a voucher
IjjS 851139d
fix: close the form element
IjjS 8c9b70f
feat: implement customer admin controllers
IjjS 76ab655
style: specify title for deleted view
IjjS 764ed32
enhance: add back to list button
IjjS 5a243d7
feat: add back to home button
IjjS cd56a54
feat: add button to move to customers view
IjjS e7be225
refactor: remove unused statements
IjjS 71989c6
enhance: add empty constructor of Customer
IjjS 6120d16
feat: add similar views to that for vouchers
IjjS 3e0e65f
style: update overall style
IjjS 4d6b853
refactor: remove unnecessary empty list creation
IjjS 39ef1a3
refactor: fix header to be selective
IjjS 7729514
refactor: fix to use constants defined
IjjS b1134f5
refactor: directly load the data in Map structure
IjjS 404d65f
refactor: track unknown exception
IjjS 0d0e732
refactor: confirm the use of blacklist file only in file profile
IjjS 8561a13
refactor: clear exception type
IjjS 7da230f
feat: implement delete all vouchers using db
IjjS ba7d722
refactor: separate the concern to maintain the depth to 1
IjjS d2fdeb3
refactor: apply ParametrizedTest for repetitive tests
IjjS b46faf4
fix: revert exception causing variable
IjjS fae3d1b
style: fix minor view style
IjjS 775ab6d
enhance: enable controllers for only web condition
IjjS 609c3c7
feat: add general advice for thymeleaf error page
IjjS c245c62
fix: disable name to be blank
IjjS 40cbeed
chore: create dockerfile and update to proper mysql url
IjjS d38611f
enhance: advise only RestControllers
IjjS e9fd577
chore: add init.sql for Dockerfile building
IjjS c1b6ca7
enhance: add transactional
IjjS 98d87e8
enhance: enable general advice to advise only admin controllers
IjjS 249bd53
refactor: merge find all api end points into one
IjjS 58ba532
refactor: remove unnecessary request param
IjjS 46ff569
refactor: remove unnecessary request param
IjjS 2d85816
feat: handle unexpected error
IjjS 34aecf0
fix: fix the improper http response status
IjjS a413117
Merge branch 'main' of https://github.com/IjjS/springboot-basic
IjjS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| FROM mysql:latest | ||
|
|
||
| ENV MYSQL_ROOT_PASSWORD=1234 | ||
| ENV MYSQL_DATABASE=voucher_management | ||
|
|
||
| COPY ./init.sql /docker-entrypoint-initdb.d/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| CREATE TABLE customers ( | ||
| customer_id BINARY(16) PRIMARY KEY, | ||
| name VARCHAR(30) NOT NULL, | ||
| customer_type VARCHAR(10) NOT NULL default 'NORMAL' | ||
| ); | ||
|
|
||
| CREATE TABLE vouchers ( | ||
| voucher_id BINARY(16) PRIMARY KEY, | ||
| created_at DATETIME NOT NULL, | ||
| discount_value DECIMAL NOT NULL, | ||
| voucher_type VARCHAR(10) NOT NULL, | ||
| customer_id BINARY(16), | ||
| FOREIGN KEY (customer_id) REFERENCES customers(customer_id) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/com/programmers/vouchermanagement/advice/ExceptionMessage.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.programmers.vouchermanagement.advice; | ||
|
|
||
| public class ExceptionMessage { | ||
| private final String message; | ||
|
|
||
| public ExceptionMessage(String message) { | ||
| this.message = message; | ||
| } | ||
|
|
||
| public String getMessage() { | ||
| return message; | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/programmers/vouchermanagement/advice/GeneralAdvice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.programmers.vouchermanagement.advice; | ||
|
|
||
| import java.util.NoSuchElementException; | ||
|
|
||
| import org.springframework.ui.Model; | ||
| import org.springframework.validation.BindingResult; | ||
| import org.springframework.validation.FieldError; | ||
| import org.springframework.web.bind.MethodArgumentNotValidException; | ||
| import org.springframework.web.bind.annotation.ControllerAdvice; | ||
| import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
|
||
| import com.programmers.vouchermanagement.advice.annotation.AdminController; | ||
|
|
||
| @ControllerAdvice(annotations = AdminController.class) | ||
| public class GeneralAdvice { | ||
|
|
||
| @ExceptionHandler({IllegalArgumentException.class, NoSuchElementException.class, RuntimeException.class}) | ||
| public String renderErrorPage(RuntimeException exception, Model model) { | ||
| model.addAttribute("message", exception.getMessage()); | ||
| return "error"; | ||
| } | ||
|
|
||
| @ExceptionHandler(MethodArgumentNotValidException.class) | ||
| public String handleInvalidMethodArgumentException(BindingResult bindingResult, Model model) { | ||
| FieldError error = bindingResult.getFieldErrors() | ||
| .get(0); | ||
| String message = error.getField() + " exception - " + error.getDefaultMessage(); | ||
| model.addAttribute("message", message); | ||
| return "error"; | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
src/main/java/com/programmers/vouchermanagement/advice/RestAdvice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.programmers.vouchermanagement.advice; | ||
|
|
||
| import java.util.NoSuchElementException; | ||
|
|
||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.validation.BindingResult; | ||
| import org.springframework.validation.FieldError; | ||
| import org.springframework.web.bind.MethodArgumentNotValidException; | ||
| import org.springframework.web.bind.annotation.ExceptionHandler; | ||
| import org.springframework.web.bind.annotation.ResponseStatus; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
| import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
|
||
| @RestControllerAdvice(annotations = RestController.class) | ||
| public class RestAdvice { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RuntimeException으로 예상치 못한 예외를 방어해보면 어떨까요? |
||
|
|
||
| @ExceptionHandler(MethodArgumentNotValidException.class) | ||
| @ResponseStatus(HttpStatus.BAD_REQUEST) | ||
| public ExceptionMessage handleInvalidMethodArgumentException(BindingResult bindingResult) { | ||
| FieldError error = bindingResult.getFieldErrors() | ||
| .get(0); | ||
| String message = error.getField() + " exception - " + error.getDefaultMessage(); | ||
| return new ExceptionMessage(message); | ||
| } | ||
|
|
||
| @ExceptionHandler(IllegalArgumentException.class) | ||
| @ResponseStatus(HttpStatus.BAD_REQUEST) | ||
| public ExceptionMessage handleIllegalArgumentException(IllegalArgumentException exception) { | ||
| return new ExceptionMessage(exception.getMessage()); | ||
| } | ||
|
|
||
| @ExceptionHandler(NoSuchElementException.class) | ||
| @ResponseStatus(HttpStatus.NOT_FOUND) | ||
| public ExceptionMessage handleNoSuchElementException(NoSuchElementException exception) { | ||
| return new ExceptionMessage(exception.getMessage()); | ||
| } | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
src/main/java/com/programmers/vouchermanagement/advice/annotation/AdminController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.programmers.vouchermanagement.advice.annotation; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| import org.springframework.stereotype.Controller; | ||
|
|
||
| @Target(ElementType.TYPE) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Documented | ||
| @Controller | ||
| public @interface AdminController { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/programmers/vouchermanagement/configuration/profiles/ConsoleCondition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.programmers.vouchermanagement.configuration.profiles; | ||
|
|
||
| import org.springframework.context.annotation.Condition; | ||
| import org.springframework.context.annotation.ConditionContext; | ||
| import org.springframework.core.type.AnnotatedTypeMetadata; | ||
|
|
||
| public class ConsoleCondition implements Condition { | ||
| @Override | ||
| public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
| return context.getEnvironment().matchesProfiles("dev", "file", "jdbc"); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
...ain/java/com/programmers/vouchermanagement/configuration/profiles/DBEnabledCondition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.programmers.vouchermanagement.configuration.profiles; | ||
|
|
||
| import org.springframework.context.annotation.Condition; | ||
| import org.springframework.context.annotation.ConditionContext; | ||
| import org.springframework.core.type.AnnotatedTypeMetadata; | ||
|
|
||
| public class DBEnabledCondition implements Condition { | ||
| @Override | ||
| public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
| return context.getEnvironment().matchesProfiles("jdbc", "web"); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
...n/java/com/programmers/vouchermanagement/configuration/profiles/FileEnabledCondition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.programmers.vouchermanagement.configuration.profiles; | ||
|
|
||
| import org.springframework.context.annotation.Condition; | ||
| import org.springframework.context.annotation.ConditionContext; | ||
| import org.springframework.core.type.AnnotatedTypeMetadata; | ||
|
|
||
| public class FileEnabledCondition implements Condition { | ||
| @Override | ||
| public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
| return context.getEnvironment().matchesProfiles("file", "test"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공통된 애가 있으면 좋을거 같아요!