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

[Merge] joonseo - #9 #12

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

[Merge] joonseo - #9 #12

wants to merge 7 commits into from

Conversation

xunxxoie
Copy link
Contributor

@xunxxoie xunxxoie commented Nov 5, 2024

๐Ÿ“‹ ์ด์Šˆ ๋ฒˆํ˜ธ

close #9

๐Ÿ›  ๊ตฌํ˜„ ์‚ฌํ•ญ

  1. 3์ฃผ์ฐจ ๋ฐœํ‘œ์ž๋ฃŒ ์—…๋ฐ์ดํŠธ
  2. API ๋ช…์„ธ์„œ (Swagger)
  3. Controller Layer + Service Layer (๋ณธ๊ฒฉ ๊ฐœ๋ฐœ ์‹œ์ž‘)

๐Ÿ“š ๋ž˜ํผ๋Ÿฐ์Šค

https://mangkyu.tistory.com/223
https://mingyum119.tistory.com/308
https://www.youtube.com/watch?v=o5rspNdJ-fE

๋Šฆ๊ฒŒ ์˜ฌ๋ ค์„œ ๋ฏธ์•ˆํ•ฉ๋‹ˆ๋‹ค.. ๐Ÿฅฒ

@xunxxoie xunxxoie self-assigned this Nov 5, 2024
Comment on lines +17 to +19
@Schema(description = "ํˆฌ๋‘ ์กฐํšŒ๋ฅผ ์š”์ฒญํ•œ ์œ ์ € ์•„์ด๋””", example = "1")
@NotBlank @Email
private Long userId;

Choose a reason for hiding this comment

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

Long ํ˜•์‹์ด๋ผ @Email์„ ์จ๋„ ์ ์šฉ์ด ์•ˆ๋ ๊ฑฐ์•ผ.

annotationProcessor 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'

Choose a reason for hiding this comment

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

์ด๊ฒŒ ๋ญ์•ผ?

@NotBlank @Email
private Long userId;

@DateTimeFormat(pattern = "yyyyMMdd")
Copy link
Member

Choose a reason for hiding this comment

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

์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ์Šคํ„ฐ๋””๋ฅผ ์ง„ํ–‰ํ•˜์ง€ ์•Š์•˜์ง€๋งŒ, ์ฝ”๋“œ์—์„œ ๋‹ค ํ•ด๋†จ๋Š”๋ฐ, ์ด๋ถ€๋ถ„๋งŒ ๋น ์ ธ์žˆ์–ด์„œ์š”!
๋งŒ์•ฝ ์—ฌ๊ธฐ์„œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ๋ฅผ ํ•ด์•ผ ํ•œ๋‹ค๋ฉด ์–ด๋–ค ์–ด๋…ธํ…Œ์ด์…˜์„ ๋„ฃ๋Š”๊ฒŒ ์ ์ ˆํ• ์ง€ ์ƒ๊ฐํ•ด๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!

private String description;

@Schema(description = "๋งˆ๊ฐ์ผ", example = "YYYY-MM-DD")
@NotBlank
Copy link
Member

Choose a reason for hiding this comment

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

LocalDateTime์„ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌํ•  ๋•Œ @Not Blank๊ฐ€ ์ œ๋Œ€๋กœ ์ ์šฉ๋˜๋Š”์ง€ ํ•œ๋ฒˆ ๋” ์ฒดํฌํ•ด๋ณด๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!

if(completed)
this.completed = false;

this.completed = true;
Copy link
Member

Choose a reason for hiding this comment

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

else ์—†์ด ์ž‘์„ฑํ•˜๋ฉด, ๋ชจ๋“ ๊ฒŒ true ๋๋‚  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!
๋˜ํ•œ, boolean ํ˜•ํƒœ๋ผ๋ฉด,
this.completed = !this.completed๋กœ ๋‚˜ํƒ€๋‚ด๋„ ๋ฉ๋‹ˆ๋‹ค!

})
@DeleteMapping
public ResponseEntity<ResponseDto<Boolean>> deleteTodo(@Valid@RequestBody TodoDeleteRequestDto request){
Boolean isSucceed = todoService.deleteTodo(request);
Copy link

Choose a reason for hiding this comment

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

api ๋ช…์„ธ์„œ์—์„œ๋Š” ์‚ญ์ œ ์‹คํŒจ ์‹œ 401๋กœ ๋˜์–ด์žˆ๋Š”๋ฐ, ์—ฌ๊ธฐ์„œ ๊ฒฐ๊ณผ ๊ฐ’์œผ๋กœ ๋ฐ›์€ ์‚ญ์ œ ์„ฑ๊ณต ์—ฌ๋ถ€๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ๊ทธ๋ƒฅ 200 ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฉด ๊ฒฐ๊ณผ๋ฅผ ๋ฐ›์„ ํ•„์š”๊ฐ€ ์—†๋Š” ๊ฒƒ ์•„๋‹Œ๊ฐ€ ์‹ถ๋„ค์š”~
๊ทธ๋ฆฌ๊ณ  ์‚ญ์ œ ๋กœ์ง ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ธฐ๋ฉด 401์„ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ํ•œ๋‹ค๋ฉด, ๊ทธ ์™ธ์˜ ์ด์œ ๋กœ ์‚ญ์ œ๋ฅผ ์‹คํŒจํ•œ ๊ฒฝ์šฐ์—์„œ ์‚ญ์ œ ์„ฑ๊ณต ์—ฌ๋ถ€๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์•Œ ํ•„์š”๊ฐ€ ์—†์ง€ ์•Š๋‚˜ ์‹ถ์Šต๋‹ˆ๋‹ค.

@ApiResponse(responseCode = "401", description = "ํˆฌ๋‘ ๊ฐ€์ ธ์˜ค๊ธฐ ์‹คํŒจ : ๊ถŒํ•œ ์—†์Œ")
})
@GetMapping("/{userId}")
public ResponseEntity<ResponseDto<List<TodoResponseDto>>> getAllTodo(@PathVariable Long userId){
Copy link

Choose a reason for hiding this comment

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

userId๋Š” Todo์— ๋Œ€ํ•œ ์‹๋ณ„์ž๊ฐ€ ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— PathVariable ์‚ฌ์šฉํ•˜๋Š” ๊ฑด ์ ํ•ฉํ•˜์ง€ ์•Š์•„ ๋ณด์—ฌ์š”

.priority(todo.getPriority())
.completed(todo.getCompleted())
.build();
}
Copy link

Choose a reason for hiding this comment

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

์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ(from)์„ ์‚ฌ์šฉ ์ค‘์ด๋‹ˆ๊นŒ Builder์— ๋Œ€ํ•œ ์ ‘๊ทผ ์ œ์–ด์ž๋ฅผ private์ด๋‚˜ protected๋กœ ์‚ฌ์šฉํ•ด๋„ ๋  ๊ฒƒ ๊ฐ™์•„์š”

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.

[Docs] 3์ฃผ์ฐจ ๋ฐœํ‘œ์ž๋ฃŒ ์—…๋กœ๋“œ
4 participants