Skip to content
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 join #5

Merged
merged 24 commits into from
Dec 7, 2024
Merged

Feature join #5

merged 24 commits into from
Dec 7, 2024

Conversation

CUCU7103
Copy link
Collaborator

๐Ÿ“Œ PR ์ œ๋ชฉ

  • ํšŒ์›๊ฐ€์ž… ๋กœ์ง ๋ฐ ํ”„๋กœ์ ํŠธ ๋กœ๊น… ์„ค์ •

๐Ÿš€ ๋ณ€๊ฒฝ ์‚ฌํ•ญ (Changes)

  1. ํšŒ์›๊ฐ€์ž… ๋กœ์ง ์ž‘์„ฑ
  2. ํšŒ์›๊ฐ€์ž… ์‹œ ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” ํ•˜์—ฌ ์ €์žฅ
  3. ํšŒ์›๊ฐ€์ž… ๋กœ์ง ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
  4. ํ”„๋กœ์ ํŠธ ๋กœ๊น… ์„ค์ • ์ง„ํ–‰
    • log4j2 ์ ์šฉ
    • p6spy ์ ์šฉ

๐Ÿ’ฅ ๊ด€๋ จ ์ด์Šˆ (Related Issues)

๐Ÿ’ฌ ๋ฆฌ๋ทฐ ์š”๊ตฌ์‚ฌํ•ญ

๐Ÿšด ์ฒดํฌ๋ฆฌ์ŠคํŠธ (Checklist)

  • else ํ‚ค์›Œ๋“œ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ธฐ
  • getter/setter/property๋ฅผ ์“ฐ์ง€ ์•Š๊ธฐ
  • ํ•œ ์ค„์— ์ ์„ ํ•˜๋‚˜๋งŒ ์ฐ๊ธฐ (๋””๋ฏธํ„ฐ์˜ ๋ฒ•์น™)
  • ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ์—ฌ๋ถ€
  • ๋„ค์ด๋ฒ„ ์ฝ”๋“œ ์ปจ๋ฒค์…˜ ์ค€์ˆ˜์—ฌ๋ถ€

jpa,db ์—ฐ๊ฒฐ์„ ์œ„ํ•œ ์˜์กด์„ฑ ์ฃผ์ž… ๋ฐ ์„ค์ • ์ง„ํ–‰๊ณผ ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ„ฐ๋ฆฌ๋ช…์—
์˜คํƒ€๋ฅผ ๋ฐœ๊ฒฌํ•˜์—ฌ ์ˆ˜์ •ํ•จ.
ํšŒ์›๊ฐ€์ž… ๊ธฐ๋Šฅ์— ํ•„์š”ํ•œ entity , repository ,dto ๋“ฑ ํด๋ž˜์Šค ์ƒ์„ฑํ›„ ๊ธฐ๋Šฅ ๊ตฌํ˜„ํ•จ
ResponseEntity์˜ ์‘๋‹ต ๋ฉ”์‹œ์ง€๋ฅผ ์ปค์Šคํ…€ํ•˜๊ธฐ ์œ„ํ•œ ํด๋ž˜์Šค ์ƒ์„ฑ ๋ฐ ํšŒ์›๊ฐ€์ž…์‹œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์•”ํ˜ธํ™” ํ•˜๊ธฐ
์œ„ํ•œ ํด๋ž˜์Šค ์ƒ์„ฑ
P6spy ์ ์šฉ์„ ์œ„ํ•œ ํด๋ž˜์Šค ์ƒ์„ฑ ๋ฐ application.yml ์„ค์ • ์ง„ํ–‰
๋กœ๊ทธ ํ”„๋ ˆ์ž„ ์›Œํฌ๋ฅผ logback์—์„œ log4j2๋กœ ๋ณ€๊ฒฝํ•จ.
Testcontainer๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜์žˆ๋„๋ก  ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•˜๊ณ  ์‹ค์ œ๋กœ ๋™์ž‘ํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
ํšŒ์› ๊ฐ€์ž… ํ…Œ์ŠคํŠธ ๋กœ์ง ์ž‘์„ฑ ๋ฐ application-test.yml ํŒŒ์ผ ์„ค์ • ๋ณ€๊ฒฝ ์ง„ํ–‰
๋ถˆํ•„์š”ํ•œ ์ฝ”๋“œ์™€ ์–ด๋…ธํ…Œ์ด์…˜ ์ œ๊ฑฐ ๋ฐ ๋ˆ„๋ฝ๋œ ์–ด๋…ธํ…Œ์ด์…˜ ์†์„ฑ ์ถ”๊ฐ€
rest doc ์ ์šฉํ•˜๋ฉด์„œ ๋ถˆํ•„์š”ํ•œ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์‚ญ์ œ ์ง„ํ–‰
์ปจํŠธ๋กค๋Ÿฌ์˜ ๋ฐ˜ํ™˜๊ฐ’๊ณผ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์—์„œ ์ž˜๋ชป๋œ ๊ฐ’์„ ์ „๋‹ฌํ•˜๊ณ  ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ถ€๋ถ„์„ ํ™•์ธํ•˜์—ฌ

์ˆ˜์ • ์ง„ํ–‰ํ•จ
@CUCU7103 CUCU7103 requested a review from f-lab-jd November 22, 2024 04:40
@CUCU7103 CUCU7103 self-assigned this Nov 22, 2024
Copy link
Collaborator

@f-lab-jd f-lab-jd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค! ๋ฆฌ๋ทฐ๋“œ๋ฆฐ ๋‚ด์šฉ ํ™•์ธ ํ›„ ๋‹ต๋ณ€ ๋ถ€ํƒ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค~

src/main/resources/application.yml Show resolved Hide resolved
src/main/resources/log4j2-spring.xml Show resolved Hide resolved
build.gradle Show resolved Hide resolved
build.gradle Show resolved Hide resolved
UserMapper์˜ ์œ„์น˜๋ฅผ global์—์„œ User ๋„๋ฉ”์ธ ํ•˜์œ„๋กœ ์ด๋™ ๋ฐ ๋ถˆํ•„์š”ํ•œ ์–ด๋…ธํ…Œ์ด์…˜ ์‚ญ์ œ
๋งค์ง๋„˜๋ฒ„๋ฅผ ์ƒ์ˆ˜๋กœ ๋ณ€๊ฒฝํ•จ
์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” api ์‚ญ์ œ ์ง„ํ–‰ํ•จ
Message ํด๋ž˜์Šค ์ œ๊ฑฐ์™€ ์ด์— ๋”ฐ๋ฅธ ์ฝ”๋“œ ์ˆ˜์ •
DTO ํด๋ž˜์Šค ๋ช…์นญ ๋ณ€๊ฒฝ ๋ฐ ์–ด๋…ธํ…Œ์ด์…˜ ์ˆ˜์ •
builder์—์„œ Mapper ์‚ฌ์šฉ์œผ๋กœ ๋ณ€๊ฒฝ ๋ฐ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๋กœ์ง ์‚ญ์ œ
๊ณ ์ • ๊ฐ’์œผ๋กœ ์ž…๋ ฅ๋˜์–ด์ง€๋Š” ๊ฐ’์„ enum ํด๋ž˜์Šค๋กœ ๊ด€๋ฆฌํ•˜๋„๋ก ๋ณ€๊ฒฝํ•จ
๋ถˆํ•„์š”ํ•œ ์„ค์ •์„ ์‚ญ์ œํ•จ
enum type์œผ๋กœ ๋ณ€๊ฒฝ๋œ ์ปฌ๋Ÿผ์œผ๋กœ ์ธํ•œ ์ˆ˜์ •
ํด๋ž˜์Šค๋ช… ๋ณ€๊ฒฝ์œผ๋กœ ์ธํ•œ ์ˆ˜์ • ์ง„ํ–‰
private final UserService userService;

@PostMapping("/user")
public ResponseEntity<Object> getUser(@Valid @RequestBody UserCreateRequest dto) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@

try {
UserCreateResponse result = userService.createUser(dto);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("user", result);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@

@Getter
public class UserCreateRequest {
@NotBlank
String userId;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@

import spring.academyPlatform.user.dto.UserCreateRequest;
import spring.academyPlatform.user.dto.UserCreateResponse;

@Component
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@

package spring.academyPlatform.user.model;

public enum TypeCode {
student, teacher;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@

@NotBlank
String userName;
@NotBlank
TypeCode userType;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@

import lombok.Builder;
import lombok.Getter;
import spring.academyPlatform.user.model.TypeCode;
import spring.academyPlatform.user.model.YnCode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@

YnCode ํด๋ž˜์Šค ํŒจํ‚ค์ง€ ์ด๋™ ๋ฐ TypeCode ํด๋ž˜์Šค UserTypeCode๋กœ ๋ช…์นญ ๋ณ€๊ฒฝํ•จ
๊ธฐ์กด Message ํด๋ž˜์Šค๋ฅผ return ๊ฐ’์œผ๋กœ ๋ฐ›๋Š” ๋กœ์ง์—์„œ dto ํด๋ž˜์Šค๋ฅผ ๋ฐ›๋Š” ๋กœ์ง์œผ๋กœ ๋ณ€๊ฒฝํ•จ.
๊ธฐ์กดtype ์—์„œ enum type์œผ๋กœ์˜ ๋ณ€๊ฒฝ์— ๋”ฐ๋ฅธ  ๋กœ์ง ์ˆ˜์ • ๋ฐ ๋ณ€ํ™˜ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
dto ํด๋ž˜์Šค์— ๋ˆ„๋ฝ๋œ ์ ‘๊ทผ์ œ์–ด์ž๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  enum type์œผ๋กœ ์˜ ๋ณ€๊ฒฝ ์ง„ํ–‰
Copy link
Collaborator

@f-lab-jd f-lab-jd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ‘

@CUCU7103 CUCU7103 merged commit b94e40c into develop Dec 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants