-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feature/product testcode #57
Feature/product testcode #57
Conversation
- flyway์ ์๋ create sequence๋ณด๋ค entity ์ฝ๋์ ์์ฑํ ์ด๋ ธํ ์ด์ ์ผ๋ก ์ํ์ค๊ฐ ์์ฑ๋๊ณ ์๋ ํ์ ํ์ธํ์ฌ sql๋ฌธ ๋ณ๊ฒฝ - ํ ์ด๋ธ ์์ฑ ํ, ์ํ์ค ๋ณ๊ฒฝ sql ์์ฑ ๋ฐฉ์ - sql์ ๊ตฌ๋ถํ๋ ๊ฒ ์ข์ ๊ฒ ๊ฐ์ init ํ์ผ์๋ ํ ์ด๋ธ ์์ฑ ddl๋ง ๋๊ณ ์ํ์ค ๋ณ๊ฒฝ ๋ฐ ์ด๊ธฐ ๊ณตํต์ฝ๋ insert sql์ ํ์ผ ๋ถ๋ฆฌ
์ด์ ์ฌ๊ธฐ์ ๋ฌธ์์ด์ ์ํธํ ํด์ ๋ถ์ฌ๋ฃ์ผ์๋ฉด ๋ฉ๋๋ค. ์ปค๋ฐํ ๋ ์๋ฌธ์ด ๋ ธ์ถ๋์ง ์์๋์ง ํ์ธํ์ธ์.
โฆhPedia into feature/docker
โฆinto feature/myPage_CRUD
โฆinto feature/myPage_CRUD
โฆinto feature/myPage_CRUD
โฆinto feature/myPage_CRUD
@@ -36,7 +37,7 @@ services: | |||
# db-read: | |||
# image: younglong/pg-washpedia:latest | |||
# volumes: | |||
# - postgreEditDB:/var/lib/postgresql/data | |||
# - ./postgreEditDB:/var/lib/postgresql/data | |||
# environment: | |||
# POSTGRES_DB: read_db | |||
# POSTGRES_USER: ${{ secrets.PROJECT_USER }} |
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.
Based on the code patch you provided, here are some of the improvements and bug risks I can identify:
-
The commented batch service image line (line 12) should be uncommented if you want to use a specific image. If you are using a custom image, make sure it is properly defined in the
docker-compose.yml
or specify it using the${IMAGE}
variable. -
Port mapping for the batch service (lines 14-15) seems to be incorrect. Port
8080
should be mapped to8082
instead of mapping8082
to8080
. Adjust it like this:- "8080:8082"
. -
Make sure the necessary dependencies (
db-edit
,db-read
) are available when running the batch service. Verify that they are correctly specified in thedepends_on
section. -
For the
db-read
service (lines 35-37), check if the volume mapping is correct. It currently points to./postgreEditDB
, which may cause issues if the directory doesn't exist. Make sure the path is accurate, and the PostgreSQL data will be properly persisted.
Additionally, it would be helpful to review other parts of the codebase, including Dockerfile, environment variables, and any additional services or functionality not included in the given patch.
@@ -36,7 +36,7 @@ ResponseEntity<ProductDto> findProductById(@PathVariable("id") Long productId) { | |||
.orElse(ResponseEntity.status(HttpStatus.NOT_FOUND).build()); | |||
} | |||
|
|||
@GetMapping("/products/") | |||
@GetMapping("/products") | |||
ResponseEntity<List<ProductDto>> findProductByKeyword(@RequestParam("keyword") String keyword){ | |||
final List<ProductDto> list = productService.getProductListByKeyword(keyword); | |||
|
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.
The code patch you provided is quite small, but here are a few observations:
-
In the "findProductById" method, it's generally good practice to return a more specific error response when a product is not found instead of a generic 404 status. You could consider returning a custom error message or using a more specific HTTP status code.
-
In the "findProductByKeyword" method, consider adding validation for the keyword parameter. For example, you can check if the keyword is empty or null and handle such cases appropriately.
-
It's generally recommended to use plural nouns for resource endpoints. So instead of "/products", you might consider using "/product".
-
Make sure that the "getProductListByKeyword" method in the "productService" does proper error handling for exceptions or edge cases. For example, what happens if the keyword is not found or if an error occurs during the search.
Overall, without seeing the complete context or implementation details, it's difficult to identify any other potential issues or suggest further improvements. However, these points should give you some initial areas to consider for your code review.
@@ -22,7 +22,7 @@ public record ProductDto(Integer productNo, | |||
) { | |||
|
|||
public static ProductDto of( | |||
Integer productNo, | |||
Long productNo, | |||
String productName, | |||
String barcode, | |||
String description, |
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.
Here are some observations and suggestions for your code patch:
-
You changed the type of
productNo
fromInteger
toLong
in theProductDto
record. Make sure this change aligns with the requirements and data types used throughout your application. -
Consider adding input validation checks in the
of
method parameters to ensure they are not null or empty if necessary. This can help prevent potential issues when creating instances ofProductDto
. -
Verify that the new parameters added to the
of
method are correctly assigned to the corresponding fields of theProductDto
record. Ensure the order and variable names match appropriately. -
Double-check that the import statements at the top of your file are correct and necessary for the code you provided.
-
Additionally, it would be helpful to review the rest of the code-base where the
ProductDto
record is being used, along with any methods that accept or return this DTO. Ensure consistency in handling the changes made to theProductDto
record.
Remember to also test your code changes thoroughly to catch any potential bugs or issues that may arise as a result of these modifications.
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.
์์ฝ ๋ฐ ๋ง๋ถ์ด์๋ฉด,
- PR์ ์ ๋ชฉ๊ณผ ๋ด์ฉ์ด ๋งค์น๊ฐ ์ ๋๋ฉด ์ข์ ๊ฒ ๊ฐ์
- fixture monkey ํ ์คํธ ์ฝ๋๋ LGTM!
- entity, dto ๋ด Integer โ Long ์ผ๋ก ๋ณ๊ฒฝ๋ ๋ถ๋ถ๋ค์ flyway๋ก ์ปฌ๋ผ ์ ๋ณด ์ ๋ฐ์ดํธ ํ์
์
๋๋ค..!
(๊ทผ๋ฐ์.. ์ปค๋ฐ ์ด๋ ฅ์ ์ด์ง ๊ผฌ์ธ๊ฑด๊ฐ์..? ใ
ใ
ใ
)
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.
์ดํ์๋ PR์ ๊ตฌ๋ถํด์ ์ฌ๋ ค์ฃผ์๋ ๊ฒ ์ข์ ๊ฒ ๊ฐ์์!
PR ๋ช
๊ณผ ๋ด๋ถ ์์
์ฌํญ์ด ๋ค๋ฅธ ๋ถ๋ถ๋ค์ด ์์ด์ ๋์ค์ ์ด๋ ฅ ๊ด๋ฆฌ๊ฐ ์ด๋ ค์ธ ์๋ ์์ง ์์๊น์!?
module-api/lombok.config
Outdated
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.
๋ด์ฉ์ ๋ํด ๊ฐ๋ตํ๊ฒ ์ค๋ช
ํด์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์~
(์ด ์ค์ ์ด ํ์ํ๊ฒ ๋ ์ด์ ๋๊น์??)
public Member toEntity(MemberDto memberDto) { | ||
return Member.of( | ||
this.memberNo, | ||
this.id, | ||
this.email, | ||
this.password, | ||
this.gender, | ||
this.birthdate | ||
memberDto.memberNo(), | ||
memberDto.id(), | ||
memberDto.email(), | ||
memberDto.password(), | ||
memberDto.gender(), | ||
memberDto.birthdate() | ||
); |
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.
์ด๊ฑฐ ์ด๋๋ก๋ฉด memberDto.toEntity(memberDto) ๊ฐ์ ํํ๋ก ํธ์ถ๋๊ฒ ๋ ๊ฒ ๊ฐ์๋ฐ์
memberDto.toEntity() ํํ๊ฐ ๋ ๋์๋ณด์ฌ์! (๋งค๊ฐ๋ณ์๊ฐ ์๋ฏธ๊ฐ ์์๊น ์ถ์ด์์)
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.
ํ์ธํด๋ดค๋๋ฐ this๋ก ๋ณด๋ด๋ memberDto๋ก ๋ณด๋ด๋ ๋๋ค toEntity(memberDto)๋ก ํด์ค์ผ๋ฉ๋๋ค.
ํ์ ๊ฐ์
, ๋ก๊ทธ์ธ ๊ตฌํํ๋ ๋์์ member์ ๋ณด๋ฅผ ํต์ผ๋ก ๋ฐ์ธ๋ฉ ํ ์ผ์ด ์์ด์ toEntity๋ฅผ ์ฐ์ง ์์๋๋ฐ
์ด๋ฐ ๊ณ ๋ฏผ์ด ์๊ฒ ๊ตฌ๋ ํ๋๊ฑธ ์ด์ ์ผ ์์๋ค์
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.
fixture monkey ์ฌ์ฉ ์์๊ฐ ์๊ฒจ์ ์ข๋ค์ ๐
๋ค์์ ํ๋ฒ ๊ฐ๋ตํ๊ฒ ์ค๋ช
๋ฃ๊ณ ์ถ์ด์!
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.
์ ์ฝ์์ต๋๋ค.
์ํฐํฐ์ Id ํ์
์ Long์ผ๋ก ๋ณ๊ฒฝํ ๊ฒ ํ์ธํ์ด์. SERIAL ํ์
์ด Integer์ Long์ ๋ชจ๋ ์ธ ์ ์๋ ๊ฑฐ๊ตฐ์. ๊ทธ๋ฐ๋ฐ ๊ฒฐ๊ตญ ์ ์๋ฒ์ ๋๋ฌธ์ BIGSERIAL ๋ก ๋ฐ๊ฟ์ผ ํ๋ ๊ฑฐ ์๋๊ฐ ์ถ์ต๋๋ค. flyway ์คํฌ๋ฆฝํธ๋ก ํ์
๋ณ๊ฒฝ์ ํด์ผ ํ ๊ฑฐ ๊ฐ์์.
# ports: | ||
# - "8082:8080" | ||
# - "8082:8082" |
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.
๐๐ป
this.email(), | ||
this.password(), | ||
this.gender(), | ||
this.birthdate() | ||
); | ||
} | ||
|
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.
Overall, the code patch looks fine with a few suggestions for improvement:
-
Data Type: The
memberNo
field inMemberDto
has been changed fromInteger
toLong
. Make sure this change is intentional and aligns with the data type in theMember
entity. -
Redundant Parameters: In the
of
method ofMemberDto
, you can remove the parametersmemberNo
andmemberDto
, as they are not used within the method. -
Method Naming: Instead of having
toEntity()
accept aMemberDto
parameter, it can directly access the fields of the current object. You can omit the parameter and modify the method topublic Member toEntity()
. This aligns with how other methods are written. -
Code Formatting: Ensure consistent indentation and formatting throughout the code. It helps with readability.
Besides these suggestions, ensure that the changes made match the requirements of your application, as I can only provide general code review suggestions based on the given information.
@@ -36,7 +36,7 @@ ResponseEntity<ProductDto> findProductById(@PathVariable("id") Long productId) { | |||
.orElse(ResponseEntity.status(HttpStatus.NOT_FOUND).build()); | |||
} | |||
|
|||
@GetMapping("/products/") | |||
@GetMapping("/products/search") | |||
ResponseEntity<List<ProductDto>> findProductByKeyword(@RequestParam("keyword") String keyword){ | |||
final List<ProductDto> list = productService.getProductListByKeyword(keyword); | |||
|
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.
Based on the provided code patch, here's a brief code review:
-
In the
findProductById
method, the response is handled well by returningResponseEntity.status(HttpStatus.NOT_FOUND).build()
when the product is not found. This ensures that a proper HTTP 404 Not Found response is returned. -
In the
findProductByKeyword
method, the endpoint URL has been changed from/products/
to/products/search
. This change is appropriate if the intention is to have a separate endpoint for searching products instead of retrieving all products. -
It would be helpful to add validation checks for the
keyword
parameter in thefindProductByKeyword
method. Depending on the requirements, you might want to consider handling scenarios where the keyword is empty or null. -
Consider using a pagination mechanism (if applicable) for fetching the list of products. Retrieving all products at once can lead to performance issues if there are a large number of products in the database.
-
Ensure that the underlying
productService.getProductListByKeyword(keyword)
method is implemented correctly and efficiently. Verify if any additional error handling or data validation is required within that method. -
Overall, it's difficult to spot bugs or provide specific improvement suggestions without seeing the complete codebase. A more thorough review may be necessary to identify any potential risks or areas for improvement.
Remember to also consider best practices related to security, exception handling, logging, and testing based on your project requirements.
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.
LGTM. ์ง๋ฌธ ๋จ๊ฒผ์ต๋๋ค
@BeforeEach | ||
void ์ค๋น(WebApplicationContext webApplicationContext) { | ||
fixtureMonkey = FixtureMonkey.builder() | ||
.objectIntrospector(new FailoverIntrospector( |
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.
objectIntrospector ์ FailoverIntrospector ๊ฐ ์ด๋ค ์ญํ ์ ํ๋์?
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.
๋ค์ด๋ฐ ์ถ์ธก๋ง ๋ณด๋ฉด ์ ์๋ ๊ฐ์ฒด์์ฑ์ค๋น์๊ฐ๊ณ ํ์๋ ์คํจ๊ฐ์ด ๋จ์ด์ง๋๊น์ง ๋ง๋ค์ด์ฃผ๋ ์์ฑ์? ๊ฐ์๊ฑฐ ๊ฐ๋ค์
FieldReflectionArbitraryIntrospector.INSTANCE, | ||
ConstructorPropertiesArbitraryIntrospector.INSTANCE, | ||
BeanArbitraryIntrospector.INSTANCE, | ||
BuilderArbitraryIntrospector.INSTANCE |
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.
๊ฐ๊ฐ์ Introspector ๊ฐ ์ด๋ค ์ญํ ์ ํ๋์ง ์๋ ค์ฃผ์ค ์ ์๋์
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.
๊ณ ์ํ์ จ์ต๋๋ค ์ถํ PR์ flyway ํ์ผ ํ๋ ์ถ๊ฐํ์ฌ์ ํ ์ด๋ธ ์ปฌ๋ผ๋ค์ ๋ํ serial4 -> serial8๊น์ง ์ถ๊ฐํด์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค
๐ก Motivation and Context
๐จ Modified
๐ More
์ฌ๊ธฐ์ PR ์ดํ ์ถ๊ฐ๋ก ํด์ผ ํ ์ผ์ ๋ํด์ ์ค๋ช ํด ์ฃผ์ธ์
๋ง์ดํ์ด์ง, ๋ฉ์ธํ์ด์ง ๋๋ฉ์ธ ์ฝ๋, ํ ์คํธ์ฝ๋ ์์ฑ
๐ ์ปค๋ฐ ์ ์ฒดํฌ๋ฆฌ์คํธ
๐ค๐ป PR๋ก ์๋ฃ๋ ์ด์
closes #