Skip to content

Test#1

Open
s0ooo0k wants to merge 5 commits into
developfrom
test
Open

Test#1
s0ooo0k wants to merge 5 commits into
developfrom
test

Conversation

@s0ooo0k
Copy link
Copy Markdown
Owner

@s0ooo0k s0ooo0k commented May 2, 2025

  • ๋ชจ์ง‘๊ธ€ ๊ด€๋ จ ๊ธฐ๋Šฅ ์ถ”๊ฐ€

Summary by CodeRabbit

  • ์‹ ๊ทœ ๊ธฐ๋Šฅ

    • ๊ฒŒ์‹œ๊ธ€(ํฌ์ŠคํŠธ) ๋“ฑ๋ก, ์ „์ฒด ์กฐํšŒ, ์ƒ์„ธ ์กฐํšŒ API๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
    • ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ ์‹œ ์Šคํ‚ฌ(๊ธฐ์ˆ ) ์ •๋ณด๋ฅผ ํ•จ๊ป˜ ์ €์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์กฐํšŒ ์‹œ ์—ฐ๊ด€๋œ ์Šคํ‚ฌ ๋ชฉ๋ก๊ณผ ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ์ •๋ณด(์ถ”ํ›„ ๊ตฌํ˜„ ์˜ˆ์ •)๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๊ฐœ์„  ๋ฐ ๋ณ€๊ฒฝ

    • ๊ฒŒ์‹œ๊ธ€ ์—”ํ‹ฐํ‹ฐ์— ์š”๊ตฌ ์„ฑ๊ฒฉ(requirementPersonality) ํ•„๋“œ์™€ ์Šคํ‚ฌ ์—ฐ๊ด€๊ด€๊ณ„๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
    • ์Šคํ‚ฌ, ๊ฒŒ์‹œ๊ธ€, ์ง€์› ๊ด€๋ จ ํŒจํ‚ค์ง€ ๊ตฌ์กฐ๊ฐ€ ์„ธ๋ถ„ํ™”๋˜์–ด ๊ด€๋ฆฌ๊ฐ€ ์šฉ์ดํ•ด์กŒ์Šต๋‹ˆ๋‹ค.
  • ๋ฒ„๊ทธ ์ˆ˜์ •

    • ์ผ๋ถ€ ํŒจํ‚ค์ง€ ๋ฐ import ๊ฒฝ๋กœ ์˜ค๋ฅ˜๊ฐ€ ์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

s0ooo0k added 5 commits May 2, 2025 11:15
- PostRequestDTO โ†’ Post ๋ณ€ํ™˜ ๋กœ์ง toEntity(User)๋กœ ์œ„์ž„
- ๋ชจ์ง‘๊ธ€ ๋“ฑ๋ก ์‹œ Skill ์กด์žฌ ์—ฌ๋ถ€ ํ™•์ธ ํ›„ ์—†์œผ๋ฉด ์ƒ์„ฑ
- PostResponseDTO, PostDetailDTO ์‘๋‹ต ๊ตฌ์กฐ ํ†ต์ผ
- ๋ชจ์ง‘๊ธ€ ๋“ฑ๋ก/์กฐํšŒ ์‹œ Post โ†’ Skill ๋ฆฌ์ŠคํŠธ ์—ฐ๊ฒฐ ์ฒ˜๋ฆฌ
- ํ˜„์žฌ ์ฐธ์—ฌ์ž ์ˆ˜(currentCount)๋Š” TODO๋กœ ์ถ”ํ›„ ๊ตฌํ˜„ ์˜ˆ์ •
- ๋ชจ์ง‘๊ธ€ ์ƒ์„ฑ ๋ฐ ์กฐํšŒ ๊ธฐ๋Šฅ ๊ด€๋ จ ๊ตฌํ˜„ ํŒŒ์ผ ์ถ”๊ฐ€ ์—…๋กœ๋“œ
- PostRepository์— ์ฟผ๋ฆฌ ๊ธฐ๋ฐ˜ fetch join ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
- Post ๊ฒŒ์‹œ๊ธ€ ์กฐํšŒ ์‹œ ๋ฐœ์ƒํ•˜๋Š” N+1 ๋ฌธ์ œ ํ•ด๊ฒฐ
- Repository ํŒจํ‚ค์ง€๋ช… ์˜คํƒ€ ์ˆ˜์ •
- findByWithSkills() ์ฟผ๋ฆฌ์— WHERE p.id = :id ์กฐ๊ฑด ๋ˆ„๋ฝ
- ๊ฐ™์€ ๊ฒŒ์‹œ๋ฌผ๋งŒ ๋ฐ˜ํ™˜๋˜๋˜ ๋ฌธ์ œ ํ•ด๊ฒฐ
Repository owner deleted a comment from coderabbitai Bot May 2, 2025
Repository owner deleted a comment from coderabbitai Bot May 2, 2025
@s0ooo0k
Copy link
Copy Markdown
Owner Author

s0ooo0k commented May 2, 2025

@coderabbitai review

Repository owner deleted a comment from coderabbitai Bot May 2, 2025
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 12

๐Ÿ”ญ Outside diff range comments (2)
src/main/java/aibe/hosik/apply/controller/ApplyController.java (1)

1-15: โš ๏ธ Potential issue

์ปจํŠธ๋กค๋Ÿฌ์— ์—”๋“œํฌ์ธํŠธ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€ ํ•„์š”
ํ˜„์žฌ ApplyController๊ฐ€ ์ƒ์„ฑ๋งŒ ๋˜์–ด ์žˆ๊ณ , ์‹ค์ œ ์ง€์›(Apply) ๋“ฑ๋ก/์กฐํšŒ ๋“ฑ์˜ REST API ๋ฉ”์„œ๋“œ๊ฐ€ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด๋Œ€๋กœ ๋ฐฐํฌํ•˜๋ฉด ๊ธฐ๋Šฅ์ด ์ œ๊ณต๋˜์ง€ ์•Š์œผ๋ฏ€๋กœ, CRUD ๊ด€๋ จ ํ•ธ๋“ค๋Ÿฌ ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด ์ฃผ์„ธ์š”.

src/main/java/aibe/hosik/apply/service/ApplyService.java (1)

1-13: ๐Ÿ’ก Verification agent

๐Ÿงฉ Analysis chain

์„œ๋น„์Šค ํด๋ž˜์Šค์— ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค

ApplyService ํด๋ž˜์Šค๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์–ด ์žˆ์ง€๋งŒ, ํ˜„์žฌ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ชจ์ง‘๊ธ€ ๊ด€๋ จ ๊ธฐ๋Šฅ์ด ์ถ”๊ฐ€๋˜์—ˆ๋‹ค๋ฉด ์ง€์›์„œ(Apply) ๊ด€๋ จ ์ฒ˜๋ฆฌ ๋กœ์ง๋„ ํ•„์š”ํ•  ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋ฉ๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด, ์ง€์›์„œ ์ œ์ถœ, ์ง€์›์„œ ์กฐํšŒ, ์ง€์› ์ƒํƒœ ๋ณ€๊ฒฝ ๋“ฑ์˜ ๋ฉ”์„œ๋“œ๊ฐ€ ๊ตฌํ˜„๋˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.


๐Ÿ Script executed:

#!/bin/bash
# ApplyController์—์„œ ApplyService๋ฅผ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋Š”์ง€ ํ™•์ธ
echo "Checking how ApplyService is used in ApplyController..."
fd -t f ApplyController.java | xargs cat

Length of output: 603


ApplyService์— ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค

ํ˜„์žฌ ApplyService๋Š” ApplyRepository๋งŒ ์ฃผ์ž…๋ฐ›๊ณ  ์žˆ์œผ๋ฉฐ, ์‹ค์ œ CRUD๋‚˜ ์ƒํƒœ ๋ณ€๊ฒฝ ๋กœ์ง์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฉ”์„œ๋“œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์ด๋กœ ์ธํ•ด ApplyController์—์„œ๋„ ํ˜ธ์ถœ ๊ฐ€๋Šฅํ•œ ์—”๋“œํฌ์ธํŠธ๊ฐ€ ์ „ํ˜€ ๊ตฌํ˜„๋˜์ง€ ์•Š์€ ์ƒํƒœ์ž…๋‹ˆ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์€ ํ•ต์‹ฌ ๊ธฐ๋Šฅ์„ ์„œ๋น„์Šค ๋ ˆ์ด์–ด์— ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”:

  • ์ง€์›์„œ ์ œ์ถœ ๋ฉ”์„œ๋“œ (์˜ˆ: createApply(...))
  • ์ง€์›์„œ ๋‹จ๊ฑด ์กฐํšŒ ๋ฉ”์„œ๋“œ (์˜ˆ: getApplyById(...))
  • ์ง€์›์„œ ๋ชฉ๋ก ์กฐํšŒ ๋ฉ”์„œ๋“œ (์˜ˆ: listApplies(...))
  • ์ง€์› ์ƒํƒœ ๋ณ€๊ฒฝ ๋ฉ”์„œ๋“œ (์˜ˆ: updateApplyStatus(...))
๐Ÿงน Nitpick comments (15)
src/main/java/aibe/hosik/post/dto/MatchedUserDTO.java (1)

3-5: ๋ฏธ์‚ฌ์šฉ import ์ œ๊ฑฐ ๊ถŒ์žฅ
Post์™€ List๊ฐ€ ํ•ด๋‹น DTO์—์„œ ์‚ฌ์šฉ๋˜์ง€ ์•Š๊ณ  ์žˆ์–ด ์ฝ”๋“œ ๊ฐ€๋…์„ฑ๊ณผ ์œ ์ง€๋ณด์ˆ˜๋ฅผ ์œ„ํ•ด ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/apply/entity/Apply.java (1)

28-32: ๊ด€๊ณ„ ๋งคํ•‘์— @joincolumn ์ถ”๊ฐ€ ๊ถŒ์žฅ
@ManyToOne ํ•„๋“œ์— ๋ช…์‹œ์ ์ธ @JoinColumn(name = "...")์„ ์ถ”๊ฐ€ํ•˜๋ฉด DB ์ปฌ๋Ÿผ ์ด๋ฆ„์ด ๋ช…ํ™•ํ•ด์ง€๊ณ , ํ–ฅํ›„ ๋ฆฌํŒฉํ† ๋ง ์‹œ ์‹ค์ˆ˜๋ฅผ ์ค„์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/analysis/Analysis.java (1)

29-30: ๊ด€๊ณ„ ๋งคํ•‘์— @joincolumn ์ถ”๊ฐ€ ๊ถŒ์žฅ
@ManyToOne(fetch = FetchType.LAZY) ํ•„๋“œ์—๋„ @JoinColumn(name = "apply_id")์™€ ๊ฐ™์€ ๋ช…์‹œ์  ์„ค์ •์„ ์ถ”๊ฐ€ํ•˜๋ฉด ์Šคํ‚ค๋งˆ ์ดํ•ด๋„๊ฐ€ ๋†’์•„์ง‘๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/skill/cotnroller/SkillController.java (1)

3-15: ์ปจํŠธ๋กค๋Ÿฌ์— ์—”๋“œํฌ์ธํŠธ๊ฐ€ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค

SkillController ํด๋ž˜์Šค๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์–ด ์žˆ์ง€๋งŒ, ํ˜„์žฌ ์–ด๋–ค ์—”๋“œํฌ์ธํŠธ๋„ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ”„๋กœ์ ํŠธ ์„ค๋ช…์— ๋”ฐ๋ฅด๋ฉด ๋ชจ์ง‘๊ธ€ ๊ด€๋ จ ๊ธฐ๋Šฅ์ด ์ถ”๊ฐ€๋œ๋‹ค๊ณ  ํ–ˆ๋Š”๋ฐ, ์Šคํ‚ฌ ๊ด€๋ จ API๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š์„๊นŒ์š”?

์˜ˆ๋ฅผ ๋“ค์–ด, ์Šคํ‚ฌ ๋ชฉ๋ก์„ ์กฐํšŒํ•˜๋Š” API๋‚˜ ํŠน์ • ์Šคํ‚ฌ์„ ๊ฒ€์ƒ‰ํ•˜๋Š” API ๋“ฑ์ด ๊ตฌํ˜„๋˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

ํ•„์š”ํ•˜์‹œ๋‹ค๋ฉด ๊ธฐ๋ณธ์ ์ธ CRUD ์—”๋“œํฌ์ธํŠธ ๊ตฌํ˜„์„ ์ œ์•ˆํ•ด ๋“œ๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/skill/service/SkillService.java (1)

1-13: ์„œ๋น„์Šค ํด๋ž˜์Šค์— ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค

SkillService ํด๋ž˜์Šค๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์–ด ์žˆ์ง€๋งŒ, ํ˜„์žฌ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์ด ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ชจ์ง‘๊ธ€ ๊ด€๋ จ ๊ธฐ๋Šฅ์—์„œ ์Šคํ‚ฌ ์ •๋ณด๋ฅผ ์ฒ˜๋ฆฌํ•˜๋ ค๋ฉด ์ ์–ด๋„ ๊ธฐ๋ณธ์ ์ธ ์Šคํ‚ฌ CRUD ๋กœ์ง์ด ๊ตฌํ˜„๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์Šคํ‚ฌ ๋“ฑ๋ก, ์กฐํšŒ, ์ˆ˜์ •, ์‚ญ์ œ ๋“ฑ์˜ ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ํŠนํžˆ SkillRepository์— ์ƒˆ๋กœ ์ถ”๊ฐ€๋œ findByName ๋ฉ”์„œ๋“œ๋ฅผ ํ™œ์šฉํ•˜๋Š” ์„œ๋น„์Šค ๋ฉ”์„œ๋“œ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

public class SkillService {
  private final SkillRepository skillRepository;
  
+ public List<Skill> getAllSkills() {
+   return skillRepository.findAll();
+ }
+
+ public Optional<Skill> getSkillByName(String name) {
+   return skillRepository.findByName(name);
+ }
+
+ public Skill saveSkill(Skill skill) {
+   return skillRepository.save(skill);
+ }
}
src/main/java/aibe/hosik/skill/repository/SkillRepository.java (1)

9-9: ์Šคํ‚ฌ ์ด๋ฆ„์œผ๋กœ ์กฐํšŒํ•˜๋Š” ๋ฉ”์„œ๋“œ๊ฐ€ ์ž˜ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค

findByName ๋ฉ”์„œ๋“œ๊ฐ€ ์ถ”๊ฐ€๋œ ๊ฒƒ์€ ์ข‹์€ ๋ณ€๊ฒฝ์ž…๋‹ˆ๋‹ค. Optional์„ ๋ฐ˜ํ™˜ ํƒ€์ž…์œผ๋กœ ์‚ฌ์šฉํ•œ ๊ฒƒ๋„ ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ฉ”์„œ๋“œ๋Š” ๋ชจ์ง‘๊ธ€์— ์—ฐ๊ฒฐ๋œ ์Šคํ‚ฌ์„ ์กฐํšŒํ•  ๋•Œ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉ๋  ๊ฒƒ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค.

ํ•œ ๊ฐ€์ง€ ์ œ์•ˆ์œผ๋กœ, ์—ฌ๋Ÿฌ ์Šคํ‚ฌ ์ด๋ฆ„์œผ๋กœ ํ•œ๊บผ๋ฒˆ์— ์Šคํ‚ฌ์„ ์กฐํšŒํ•˜๋Š” ๋ฉ”์„œ๋“œ๋„ ์ถ”๊ฐ€ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ชจ์ง‘๊ธ€์„ ๋“ฑ๋กํ•  ๋•Œ ์—ฌ๋Ÿฌ ์Šคํ‚ฌ์„ ํ•œ๋ฒˆ์— ์ฒ˜๋ฆฌํ•ด์•ผ ํ•  ์ƒํ™ฉ์ด ์žˆ์„ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

public interface SkillRepository extends JpaRepository<Skill, Long> {
    Optional<Skill> findByName(String skillName);
+   
+   @Query("SELECT s FROM Skill s WHERE s.name IN :skillNames")
+   List<Skill> findByNameIn(List<String> skillNames);
}
src/main/java/aibe/hosik/skill/repository/PostSkillRepository.java (1)

16-17: ์˜คํƒ€ ์ˆ˜์ • ์ œ์•ˆ

์ฃผ์„์— ์ž‘์€ ์˜คํƒ€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

-    // Post ID๋กœ ํ•ด๋‹น ๊ธ€๊ณผ ์—ฐ๊ด€๋œ ๋ชจ๋“  ์Šคํ‚ฌ ์ด๋ฅด ์ง์ ‘ ์กฐํšŒ
+    // Post ID๋กœ ํ•ด๋‹น ๊ธ€๊ณผ ์—ฐ๊ด€๋œ ๋ชจ๋“  ์Šคํ‚ฌ ์ด๋ฆ„ ์ง์ ‘ ์กฐํšŒ
src/main/java/aibe/hosik/post/service/PostService.java (1)

13-13: ๋ฐ˜ํ™˜ ํƒ€์ž… ๊ฒ€ํ†  ์ œ์•ˆ

createPost ๋ฉ”์„œ๋“œ๊ฐ€ ํ˜„์žฌ Entity ๊ฐ์ฒด๋ฅผ ์ง์ ‘ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ์„œ๋น„์Šค ๊ณ„์ธต์—์„œ๋Š” Entity ๋Œ€์‹  DTO๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์€ ๊ด€ํ–‰์ž…๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๊ณ„์ธต ๊ฐ„ ๊ฒฐํ•ฉ๋„๋ฅผ ๋‚ฎ์ถ”๊ณ  API ์‘๋‹ต์ด ๋‚ด๋ถ€ ๋ฐ์ดํ„ฐ ๋ชจ๋ธ ๋ณ€๊ฒฝ์— ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

-  Post createPost(PostRequestDTO dto, User user);
+  PostResponseDTO createPost(PostRequestDTO dto, User user);
src/main/java/aibe/hosik/post/dto/PostResponseDTO.java (1)

18-28: ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ๊ฐœ์„  ์ œ์•ˆ

๋ฉ”์„œ๋“œ ํŒŒ๋ผ๋ฏธํ„ฐ์—์„œ List<String> skills์™€ Integer currentCount ์‚ฌ์ด์˜ ๊ณต๋ฐฑ์ด ๋ˆ„๋ฝ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ null ์ฒดํฌ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ๋” ๊ฒฌ๊ณ ํ•œ ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

-    public static PostResponseDTO from(Post post,List<String> skills, Integer currentCount) {
+    public static PostResponseDTO from(Post post, List<String> skills, Integer currentCount) {
+        if (post == null) {
+            throw new IllegalArgumentException("Post cannot be null");
+        }
         return new PostResponseDTO(post.getId(),
                 post.getImage(),
                 post.getTitle(),
                 post.getContent(),
                 post.getCategory().toString(),
-                skills,
+                skills != null ? skills : List.of(),
                 post.getHeadCount(),
-                currentCount
+                currentCount != null ? currentCount : 0
         );
     }
src/main/java/aibe/hosik/post/repository/PostRepository.java (1)

15-16: ์ฃผ์„ ์ฝ”๋“œ ์ •๋ฆฌ ์ œ์•ˆ

์ฃผ์„ ์ฒ˜๋ฆฌ๋œ @EntityGraph ์ฝ”๋“œ๊ฐ€ ๋‚จ์•„์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ฝ”๋“œ๋Š” ํ˜„์žฌ ์‚ฌ์šฉ๋˜์ง€ ์•Š๊ณ  ์žˆ์œผ๋ฉฐ, ๋ฏธ๋ž˜์— ๋Œ€์•ˆ์œผ๋กœ ์‚ฌ์šฉํ•  ๊ณ„ํš์ด ์—†๋‹ค๋ฉด ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์„ ๋†’์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

-    // Post ์กฐํšŒ ์‹œ postSkills, skill ์—”ํ‹ฐํ‹ฐ ์ฆ‰์‹œ ๋กœ๋”ฉ ์ง€์ •
-    //@EntityGraph(attributePaths = {"postSkills", "postSkills.skill"})
+    // Post ์กฐํšŒ ์‹œ postSkills, skill ์—”ํ‹ฐํ‹ฐ ์ฆ‰์‹œ ๋กœ๋”ฉ
-    // PostDetail ์กฐํšŒ ์‹œ ์ฆ‰์‹œ ๋กœ๋”ฉ ์ง€์ •
-    //@EntityGraph(attributePaths = {"postSkills", "postSkills.skill"})
+    // PostDetail ์กฐํšŒ ์‹œ ์ฆ‰์‹œ ๋กœ๋”ฉ

Also applies to: 20-21

src/main/java/aibe/hosik/post/dto/PostRequestDTO.java (1)

24-36: toEntity ๋ฉ”์„œ๋“œ์—์„œ ์Šคํ‚ฌ ๋งคํ•‘ ์ฒ˜๋ฆฌ ํ•„์š”

ํ˜„์žฌ toEntity ๋ฉ”์„œ๋“œ๋Š” ์‚ฌ์šฉ์ž ์ •๋ณด๋งŒ ์„ค์ •ํ•˜๊ณ  ์Šคํ‚ฌ ์ •๋ณด๋Š” ์„ค์ •ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์Šคํ‚ฌ ๋งคํ•‘์€ ์„œ๋น„์Šค ๊ณ„์ธต์—์„œ ๋ณ„๋„๋กœ ์ฒ˜๋ฆฌ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ฑ…์ž„์„ DTO ๋‚ด๋ถ€๋กœ ๊ฐ€์ ธ์™€์„œ ์บก์Аํ™”ํ•˜๋Š” ๊ฒƒ์ด ๋” ์ข‹์€ ์„ค๊ณ„์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ ํ˜„์žฌ User ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ ํ•„์š”ํ•œ๋ฐ, ์ด๋กœ ์ธํ•ด ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์–ด๋ ค์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 public Post toEntity(User user) {
     return Post.builder()
             .title(title())
             .content(content())
             .headCount(headCount())
             .image(image())
             .requirementPersonality(requirementPersonality())
             .endedAt(endedAt())
             .category(category())
             .type(type())
             .user(user)
             .build();
 }
+
+ // ์Šคํ‚ฌ ์—”ํ‹ฐํ‹ฐ ๋งคํ•‘์„ ์œ„ํ•œ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
+ public List<PostSkill> createPostSkills(Post post, List<Skill> skills) {
+     return skills.stream()
+             .map(skill -> PostSkill.builder()
+                     .post(post)
+                     .skill(skill)
+                     .build())
+             .collect(Collectors.toList());
+ }
src/main/java/aibe/hosik/post/dto/PostDetailDTO.java (1)

10-26: ํ•„๋“œ ์„ค๋ช…์„ ์œ„ํ•œ JavaDoc ์ถ”๊ฐ€ ํ•„์š”

PostDetailDTO์˜ ๊ฐ ํ•„๋“œ์— ๋Œ€ํ•œ ์„ค๋ช…์ด ๋ถ€์กฑํ•ฉ๋‹ˆ๋‹ค. ํŠนํžˆ matchedUsers์— ๋Œ€ํ•œ ์ฃผ์„์ด ์žˆ์ง€๋งŒ ๋‹ค๋ฅธ ํ•„๋“œ์— ๋Œ€ํ•œ ์„ค๋ช…์€ ์—†์Šต๋‹ˆ๋‹ค. ๊ฐ ํ•„๋“œ์˜ ๋ชฉ์ ๊ณผ ์˜๋ฏธ๋ฅผ ๋ช…ํ™•ํžˆ ํ•˜๊ธฐ ์œ„ํ•ด JavaDoc ์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

 /**
+ * ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์ •๋ณด๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” DTO
+ * ๊ฒŒ์‹œ๊ธ€์˜ ๊ธฐ๋ณธ ์ •๋ณด, ์นดํ…Œ๊ณ ๋ฆฌ, ํƒ€์ž…, ์Šคํ‚ฌ ๋ชฉ๋ก, ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ๋ชฉ๋ก์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.
+ */
 public record PostDetailDTO(
+        /** ๊ฒŒ์‹œ๊ธ€ ID */
         Long id,
+        /** ๊ฒŒ์‹œ๊ธ€ ์ œ๋ชฉ */
         String title,
+        /** ๊ฒŒ์‹œ๊ธ€ ๋‚ด์šฉ */
         String content,
+        /** ๋ชจ์ง‘ ์ธ์› ์ˆ˜ */
         Integer headCount,
+        /** ์ด๋ฏธ์ง€ URL */
         String image,
+        /** ํ•„์š”ํ•œ ์„ฑ๊ฒฉ ํŠน์„ฑ */
         String requirementPersonality,
+        /** ๋ชจ์ง‘ ์ข…๋ฃŒ์ผ */
         LocalDate endedAt,

+        /** ๊ฒŒ์‹œ๊ธ€ ์นดํ…Œ๊ณ ๋ฆฌ (๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜๋จ) */
         String category,
+        /** ๊ฒŒ์‹œ๊ธ€ ํƒ€์ž… (๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜๋จ) */
         String type,

+        /** ์š”๊ตฌ๋˜๋Š” ์Šคํ‚ฌ ๋ชฉ๋ก */
         List<String> skills,

         // ํ˜„์žฌ ์„ ํƒ๋œ ๋ชฉ๋ก ๋ณด์—ฌ์ฃผ๊ธฐ
+        /** ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ๋ชฉ๋ก */
         List<MatchedUserDTO> matchedUsers
 ) {
src/main/java/aibe/hosik/post/service/PostServiceImpl.java (1)

28-47: getAllPosts ๋ฉ”์„œ๋“œ ์ตœ์ ํ™” ๋ฐ ์ฃผ์„ ๊ฐœ์„ 

ํ˜„์žฌ getAllPosts ๋ฉ”์„œ๋“œ์—๋Š” ๋ช‡ ๊ฐ€์ง€ ๊ฐœ์„ ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค:

  1. TODO ์ฃผ์„์ด ์žˆ๋Š”๋ฐ, ํ˜„์žฌ ์ฐธ์—ฌ์ž ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•˜๋Š” ๊ตฌํ˜„์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
  2. ์ŠคํŠธ๋ฆผ ์—ฐ์‚ฐ ์ฒด์ธ์—์„œ .collect(Collectors.toList())๋Š” Java 16๋ถ€ํ„ฐ toList()๋กœ ๋Œ€์ฒดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ๋ฉ”์„œ๋“œ ์„ค๋ช… ์ฃผ์„์ด ์žˆ์ง€๋งŒ, JavaDoc ํ˜•์‹์œผ๋กœ ๊ฐœ์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
-  // PostResponseDTO๋ฅผ ํ†ตํ•ด ์ „์ฒด ๊ฒŒ์‹œ๊ธ€(Post)๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค
+  /**
+   * PostResponseDTO๋ฅผ ํ†ตํ•ด ์ „์ฒด ๊ฒŒ์‹œ๊ธ€(Post)๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
+   * ํ•œ ๋ฒˆ์˜ ์ฟผ๋ฆฌ๋กœ ๊ฒŒ์‹œ๊ธ€๊ณผ ๊ด€๋ จ ์Šคํ‚ฌ์„ ํ•จ๊ป˜ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
+   *
+   * @return ๋ชจ๋“  ๊ฒŒ์‹œ๊ธ€ ์ •๋ณด๊ฐ€ ๋‹ด๊ธด PostResponseDTO ๋ชฉ๋ก
+   */
   @Override
   public List<PostResponseDTO> getAllPosts() {
     // findAllWithSkills๋กœ ํ•œ ๋ฒˆ์— fetch(post, postSkills, skill)
     List<Post> posts = postRepository.findAllWithSkills();

     return posts.stream()
             .map(post -> {
               // fetch๋œ postSkills์—์„œ skill ์ถ”์ถœ
               List<String> skills = post.getPostSkills().stream()
                       .map(s -> s.getSkill().getName())
-                      .collect(Collectors.toList());
+                      .toList();

               // TODO : ํ˜„์žฌ ์ฐธ์—ฌ์ž ์ˆ˜ ๊ณ„์‚ฐ
+              // ์ฐธ์—ฌ์ž ์ˆ˜ ๊ณ„์‚ฐ ๋กœ์ง ๊ตฌํ˜„ ํ•„์š”
               Integer currentCount = 0;

               // DTO ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ํ™œ์šฉ
               return PostResponseDTO.from(post, skills, currentCount);
-            }).collect(Collectors.toList());
+            }).toList();
   }
src/main/java/aibe/hosik/post/controller/PostController.java (2)

22-22: ๋ถˆํ•„์š”ํ•œ ์ฃผ์„์„ ์ œ๊ฑฐํ•˜์„ธ์š”.

"ํ…Œ์ŠคํŠธ"๋ผ๋Š” ์ฃผ์„์€ ์ฝ”๋“œ์— ํŠน๋ณ„ํ•œ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜์ง€ ์•Š์œผ๋ฉฐ ๋ถˆํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๋ช…ํ™•ํ•œ ๋‚ด์šฉ์ด ์—†๋Š” ์ฃผ์„์€ ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

- // ํ…Œ์ŠคํŠธ

1-28: API ๋ฌธ์„œํ™” ๊ฐ•ํ™”๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

Swagger ํƒœ๊ทธ์™€ ๊ธฐ๋ณธ์ ์ธ API ๋ฌธ์„œํ™”๊ฐ€ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€๋งŒ, ์š”์ฒญ ๋ฐ ์‘๋‹ต์— ๋Œ€ํ•œ ๋” ์ž์„ธํ•œ ๋ฌธ์„œํ™”๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ํŠนํžˆ ์š”์ฒญ ํŒŒ๋ผ๋ฏธํ„ฐ์™€ ์‘๋‹ต ํ•„๋“œ์— ๋Œ€ํ•œ ์„ค๋ช…์ด ๋ˆ„๋ฝ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

Swagger ์• ๋…ธํ…Œ์ด์…˜์„ ํ™•์žฅํ•˜์—ฌ API ๋ฌธ์„œํ™”๋ฅผ ๊ฐ•ํ™”ํ•˜์„ธ์š”:

@Operation(summary="๋ชจ์ง‘๊ธ€ ๋“ฑ๋ก", description="๋ชจ์ง‘๊ธ€์„ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.")
+ @ApiResponses(value = {
+     @ApiResponse(responseCode = "200", description = "๋ชจ์ง‘๊ธ€ ๋“ฑ๋ก ์„ฑ๊ณต",
+         content = { @Content(mediaType = "application/json",
+             schema = @Schema(implementation = PostResponseDTO.class)) }),
+     @ApiResponse(responseCode = "400", description = "์ž˜๋ชป๋œ ์š”์ฒญ"),
+     @ApiResponse(responseCode = "401", description = "์ธ์ฆ ์‹คํŒจ")
+ })
@PostMapping
๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 4d39b8c and 0c90910.

๐Ÿ“’ Files selected for processing (22)
  • build.gradle (1 hunks)
  • src/main/java/aibe/hosik/analysis/Analysis.java (1 hunks)
  • src/main/java/aibe/hosik/apply/controller/ApplyController.java (1 hunks)
  • src/main/java/aibe/hosik/apply/entity/Apply.java (1 hunks)
  • src/main/java/aibe/hosik/apply/repository/ApplyRepository.java (1 hunks)
  • src/main/java/aibe/hosik/apply/service/ApplyService.java (1 hunks)
  • src/main/java/aibe/hosik/post/PostController.java (0 hunks)
  • src/main/java/aibe/hosik/post/PostRepository.java (0 hunks)
  • src/main/java/aibe/hosik/post/PostService.java (0 hunks)
  • src/main/java/aibe/hosik/post/controller/PostController.java (1 hunks)
  • src/main/java/aibe/hosik/post/dto/MatchedUserDTO.java (1 hunks)
  • src/main/java/aibe/hosik/post/dto/PostDetailDTO.java (1 hunks)
  • src/main/java/aibe/hosik/post/dto/PostRequestDTO.java (1 hunks)
  • src/main/java/aibe/hosik/post/dto/PostResponseDTO.java (1 hunks)
  • src/main/java/aibe/hosik/post/entity/Post.java (3 hunks)
  • src/main/java/aibe/hosik/post/repository/PostRepository.java (1 hunks)
  • src/main/java/aibe/hosik/post/service/PostService.java (1 hunks)
  • src/main/java/aibe/hosik/post/service/PostServiceImpl.java (1 hunks)
  • src/main/java/aibe/hosik/skill/cotnroller/SkillController.java (1 hunks)
  • src/main/java/aibe/hosik/skill/repository/PostSkillRepository.java (1 hunks)
  • src/main/java/aibe/hosik/skill/repository/SkillRepository.java (1 hunks)
  • src/main/java/aibe/hosik/skill/service/SkillService.java (1 hunks)
๐Ÿ’ค Files with no reviewable changes (3)
  • src/main/java/aibe/hosik/post/PostRepository.java
  • src/main/java/aibe/hosik/post/PostController.java
  • src/main/java/aibe/hosik/post/PostService.java
๐Ÿงฐ Additional context used
๐Ÿงฌ Code Graph Analysis (1)
src/main/java/aibe/hosik/post/controller/PostController.java (4)
src/main/java/aibe/hosik/apply/controller/ApplyController.java (1)
  • Slf4j (9-15)
src/main/java/aibe/hosik/apply/service/ApplyService.java (1)
  • Slf4j (8-13)
src/main/java/aibe/hosik/skill/service/SkillService.java (1)
  • Slf4j (8-13)
src/main/java/aibe/hosik/skill/cotnroller/SkillController.java (1)
  • Slf4j (9-15)
๐Ÿ”‡ Additional comments (9)
src/main/java/aibe/hosik/post/dto/MatchedUserDTO.java (1)

7-13: DTO ์ •์˜๊ฐ€ ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค
๋ ˆ์ฝ”๋“œ๋ฅผ ์ด์šฉํ•ด ๋ถˆ๋ณ€ ๊ฐ์ฒด๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ์ •์˜ํ•œ ์ ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/apply/entity/Apply.java (1)

1-1: ํŒจํ‚ค์ง€ ๊ตฌ์กฐ ๋ณ€๊ฒฝ ํ™•์ธ๋จ
Apply ์—”ํ‹ฐํ‹ฐ๊ฐ€ aibe.hosik.apply.entity๋กœ ์ด๋™ํ•œ ๊ฒƒ์ด ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/analysis/Analysis.java (1)

3-3: import ํŒจํ‚ค์ง€ ๊ฒฝ๋กœ ์—…๋ฐ์ดํŠธ ํ™•์ธ๋จ
Apply์˜ ํŒจํ‚ค์ง€ ๊ฒฝ๋กœ ๋ณ€๊ฒฝ์— ๋งž์ถฐ import๋ฅผ ์ˆ˜์ •ํ•œ ๊ฒƒ์ด ์˜ฌ๋ฐ”๋ฆ…๋‹ˆ๋‹ค.

build.gradle (1)

27-29: Spring Security ์˜์กด์„ฑ ํ™œ์„ฑํ™” ์ ์ ˆ
spring-boot-starter-security๋ฅผ ํ™œ์„ฑํ™”ํ•˜์—ฌ @AuthenticationPrincipal์„ ์‚ฌ์šฉํ•˜๋Š” ์ปจํŠธ๋กค๋Ÿฌ ์ธ์ฆ ๊ธฐ๋Šฅ์„ ์ง€์›ํ•˜๋„๋ก ํ•œ ๊ฒƒ์ด ํƒ€๋‹นํ•ฉ๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/skill/repository/PostSkillRepository.java (1)

1-19: Repository ๊ตฌํ˜„์ด ์ž˜ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค!

PostSkill ์—”ํ‹ฐํ‹ฐ์— ๋Œ€ํ•œ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๊ตฌํ˜„์ด ์ ์ ˆํ•˜๊ฒŒ ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‘ ๊ฐ€์ง€ ์ฟผ๋ฆฌ ๋ฉ”์†Œ๋“œ๊ฐ€ ์ œ๊ณต๋˜๋ฉฐ:

  1. findByPost - ํŠน์ • Post ์—”ํ‹ฐํ‹ฐ์™€ ์—ฐ๊ด€๋œ ๋ชจ๋“  PostSkill ์กฐํšŒ
  2. findSkillByPostId - Post ID๋กœ ์—ฐ๊ด€๋œ ์Šคํ‚ฌ ์ด๋ฆ„๋“ค์„ ์ง์ ‘ ์กฐํšŒํ•˜๋Š” JPQL ์ฟผ๋ฆฌ

์ด๋Š” Post์™€ Skill ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ํšจ๊ณผ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/post/service/PostService.java (1)

1-15: ์„œ๋น„์Šค ์ธํ„ฐํŽ˜์ด์Šค ์„ค๊ณ„๊ฐ€ ๋ช…ํ™•ํ•ฉ๋‹ˆ๋‹ค

PostService ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ๋ช…ํ™•ํ•˜๊ฒŒ ์ •์˜๋˜์–ด ์žˆ์œผ๋ฉฐ, ํ•„์š”ํ•œ ํ•ต์‹ฌ ๊ธฐ๋Šฅ๋“ค(๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก ์กฐํšŒ, ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ, ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์กฐํšŒ)์„ ํฌํ•จํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. DTO ๊ฐ์ฒด๋ฅผ ์ž…์ถœ๋ ฅ์— ์‚ฌ์šฉํ•˜์—ฌ ๊ณ„์ธต ๊ฐ„ ์ฑ…์ž„ ๋ถ„๋ฆฌ๊ฐ€ ์ž˜ ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/post/dto/PostResponseDTO.java (1)

1-29: DTO ์„ค๊ณ„๊ฐ€ ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค

Java ๋ ˆ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ถˆ๋ณ€ ๋ฐ์ดํ„ฐ ๊ฐ์ฒด๋กœ PostResponseDTO๋ฅผ ๊ตฌํ˜„ํ•œ ๊ฒƒ์€ ์ข‹์€ ์ ‘๊ทผ ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ from์„ ์‚ฌ์šฉํ•˜์—ฌ ์—”ํ‹ฐํ‹ฐ์—์„œ DTO๋กœ์˜ ๋ณ€ํ™˜์„ ๋ช…ํ™•ํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/post/repository/PostRepository.java (1)

1-23: ์ฟผ๋ฆฌ ์ตœ์ ํ™”๊ฐ€ ์ž˜ ๊ตฌํ˜„๋˜์—ˆ์Šต๋‹ˆ๋‹ค

JOIN FETCH๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ N+1 ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ์ตœ์ ํ™”๋œ ์ฟผ๋ฆฌ๋ฅผ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค. DISTINCT๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ค‘๋ณต์„ ์ œ๊ฑฐํ•œ ๊ฒƒ๋„ ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค. ์—”ํ‹ฐํ‹ฐ ๊ฐ„ ๊ด€๊ณ„๋ฅผ ํšจ์œจ์ ์œผ๋กœ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/post/controller/PostController.java (1)

40-41: TODO ์ฝ”๋ฉ˜ํŠธ ํ•ด๊ฒฐ ๋ฐ ๋ช…ํ™•ํ•œ ๋ฉ”์„œ๋“œ ์ž‘์„ฑ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

"currentCount ๋กœ์ง ๊ตฌํ˜„ ํ›„ ๋ณ€ํ™˜"์ด๋ผ๋Š” TODO ์ฝ”๋ฉ˜ํŠธ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ๊ธฐ๋Šฅ์ด ์™„์ „ํžˆ ๊ตฌํ˜„๋˜์ง€ ์•Š์•˜์Œ์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ๊ฐ€๋Šฅํ•œ ๋นจ๋ฆฌ ์ด ๋กœ์ง์„ ๊ตฌํ˜„ํ•˜๊ฑฐ๋‚˜, ์ง„ํ–‰ ์ค‘์ธ ์ž‘์—…์ด๋ผ๋ฉด ์ข€ ๋” ์ž์„ธํ•œ ์„ค๋ช…๊ณผ ์˜ˆ์ƒ ์™„๋ฃŒ ์‹œ์ ์„ ์ฃผ์„์— ์ถ”๊ฐ€ํ•˜์„ธ์š”.

๋˜ํ•œ, 0์„ ํ•˜๋“œ์ฝ”๋”ฉํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค ์˜๋ฏธ ์žˆ๋Š” ์ƒ์ˆ˜๋‚˜ ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ๋กœ ๋Œ€์ฒดํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค:

- PostResponseDTO responseDTO = PostResponseDTO.from(createPost, skills, 0);
+ // TODO: currentCount ๋กœ์ง ๊ตฌํ˜„ - 2023-xx-xx๊นŒ์ง€ ๊ตฌํ˜„ ์˜ˆ์ •
+ PostResponseDTO responseDTO = PostResponseDTO.from(createPost, skills, getInitialCount());

// ํด๋ž˜์Šค ๋‚ด์— ๋‹ค์Œ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
private int getInitialCount() {
  return 0; // ํ–ฅํ›„ ๋กœ์ง์œผ๋กœ ๋Œ€์ฒด ์˜ˆ์ •
}

@@ -1,5 +1,6 @@
package aibe.hosik.skill;
package aibe.hosik.skill.cotnroller;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

โš ๏ธ Potential issue

ํŒจํ‚ค์ง€ ์ด๋ฆ„์— ์˜คํƒ€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค

ํŒจํ‚ค์ง€ ์ด๋ฆ„์ด aibe.hosik.skill.cotnroller๋กœ ๋˜์–ด ์žˆ๋Š”๋ฐ, ์ •ํ™•ํ•œ ์ŠคํŽ ๋ง์€ aibe.hosik.skill.controller์ž…๋‹ˆ๋‹ค. ํŒจํ‚ค์ง€ ์ด๋ฆ„์˜ ์˜คํƒ€๋Š” ์ถ”ํ›„์— ์ž„ํฌํŠธ ๋ฌธ์ œ๋ฅผ ์ผ์œผํ‚ฌ ์ˆ˜ ์žˆ์œผ๋‹ˆ ์ˆ˜์ •ํ•ด์ฃผ์„ธ์š”.

-package aibe.hosik.skill.cotnroller;
+package aibe.hosik.skill.controller;
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
package aibe.hosik.skill.cotnroller;
package aibe.hosik.skill.controller;

Comment on lines +7 to +8
// post id๋กœ ์ง€์›์„œ ์กฐํšŒ

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

์ฝ”๋ฉ˜ํŠธ๋งŒ ์žˆ๊ณ  ์‹ค์ œ ๋ฉ”์„œ๋“œ ๊ตฌํ˜„์ด ์—†์Šต๋‹ˆ๋‹ค

"post id๋กœ ์ง€์›์„œ ์กฐํšŒ"๋ผ๋Š” ์ฝ”๋ฉ˜ํŠธ๊ฐ€ ์žˆ์ง€๋งŒ ์‹ค์ œ ๋ฉ”์„œ๋“œ๊ฐ€ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ชจ์ง‘๊ธ€๊ณผ ์ง€์›์„œ ๊ฐ„์˜ ์—ฐ๊ด€๊ด€๊ณ„๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ด ๊ธฐ๋Šฅ์ด ํ•„์š”ํ•  ๊ฒƒ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค:

public interface ApplyRepository extends JpaRepository<Apply, Long> {
    // post id๋กœ ์ง€์›์„œ ์กฐํšŒ
+   List<Apply> findByPostId(Long postId);

}
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// post id๋กœ ์ง€์›์„œ ์กฐํšŒ
public interface ApplyRepository extends JpaRepository<Apply, Long> {
// post id๋กœ ์ง€์›์„œ ์กฐํšŒ
List<Apply> findByPostId(Long postId);
}

Comment on lines +11 to +23
public record PostRequestDTO(
String title,
String content,
Integer headCount,
String image,
String requirementPersonality,
LocalDate endedAt,

PostCategory category,
PostType type,

List<String> skills
) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

ํ•„๋“œ ์œ ํšจ์„ฑ ๊ฒ€์ฆ ์ถ”๊ฐ€ ํ•„์š”

ํ˜„์žฌ PostRequestDTO์˜ ํ•„๋“œ๋“ค์— ๋Œ€ํ•œ ์œ ํšจ์„ฑ ๊ฒ€์ฆ์ด ์—†์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด title์ด๋‚˜ content๊ฐ€ ๋น„์–ด์žˆ๊ฑฐ๋‚˜, headCount๊ฐ€ ์Œ์ˆ˜์ธ ๊ฒฝ์šฐ ๋“ฑ ์œ ํšจํ•˜์ง€ ์•Š์€ ์ž…๋ ฅ์ด ๋“ค์–ด์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Bean Validation ์• ๋…ธํ…Œ์ด์…˜(@NotBlank, @Size, @Min ๋“ฑ)์„ ์‚ฌ์šฉํ•˜์—ฌ ์œ ํšจ์„ฑ ๊ฒ€์ฆ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค:

 public record PostRequestDTO(
+        @NotBlank(message = "์ œ๋ชฉ์€ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
+        @Size(max = 100, message = "์ œ๋ชฉ์€ 100์ž ์ด๋‚ด๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”")
         String title,
+        @NotBlank(message = "๋‚ด์šฉ์€ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
         String content,
+        @Min(value = 1, message = "์ธ์› ์ˆ˜๋Š” ์ตœ์†Œ 1๋ช… ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค")
         Integer headCount,
         String image,
         String requirementPersonality,
+        @NotNull(message = "๋ชจ์ง‘ ์ข…๋ฃŒ์ผ์€ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
+        @Future(message = "๋ชจ์ง‘ ์ข…๋ฃŒ์ผ์€ ํ˜„์žฌ ์ดํ›„์˜ ๋‚ ์งœ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค")
         LocalDate endedAt,

+        @NotNull(message = "์นดํ…Œ๊ณ ๋ฆฌ๋Š” ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
         PostCategory category,
+        @NotNull(message = "ํƒ€์ž…์€ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
         PostType type,

+        @NotEmpty(message = "์ตœ์†Œ ํ•˜๋‚˜ ์ด์ƒ์˜ ์Šคํ‚ฌ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค")
         List<String> skills
 ) {

Bean Validation์„ ์œ„ํ•ด ์•„๋ž˜ ์˜์กด์„ฑ ์ถ”๊ฐ€๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค:

import jakarta.validation.constraints.*;

Comment on lines +40 to +42
@Column
private String requirementPersonality;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

requirementPersonality ํ•„๋“œ์— ์œ ํšจ์„ฑ ์ œ์•ฝ์กฐ๊ฑด ์ถ”๊ฐ€ ํ•„์š”

requirementPersonality ํ•„๋“œ์— ์œ ํšจ์„ฑ ์ œ์•ฝ์กฐ๊ฑด์ด ์—†์Šต๋‹ˆ๋‹ค. ์ด ํ•„๋“œ์— ๋„ˆ๋ฌด ๊ธด ํ…์ŠคํŠธ๊ฐ€ ์ €์žฅ๋  ๊ฒฝ์šฐ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. @Size ์• ๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธธ์ด ์ œํ•œ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

-  @Column
+  @Column(length = 500)
+  @Size(max = 500)
   private String requirementPersonality;
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Column
private String requirementPersonality;
@Column(length = 500)
@Size(max = 500)
private String requirementPersonality;

Comment on lines +57 to +60
// ์–‘๋ฐฉํ–ฅ ๋งคํ•‘
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
@Builder.Default
private List<PostSkill> postSkills = new ArrayList<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

์–‘๋ฐฉํ–ฅ ๋งคํ•‘์— ๋Œ€ํ•œ ํ—ฌํผ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€ ํ•„์š”

์–‘๋ฐฉํ–ฅ ๋งคํ•‘์„ ์‚ฌ์šฉํ•  ๋•Œ๋Š” ์–‘์ชฝ์—์„œ ๊ด€๊ณ„๋ฅผ ์„ค์ •ํ•˜๋Š” ํ—ฌํผ ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ํ˜„์žฌ๋Š” ๊ด€๊ณ„ ์„ค์ • ์ฑ…์ž„์ด ์„œ๋น„์Šค ๊ณ„์ธต์— ์žˆ์–ด์„œ ์ผ๊ด€์„ฑ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํฌ์ŠคํŠธ์™€ ์Šคํ‚ฌ ๊ฐ„์˜ ์–‘๋ฐฉํ–ฅ ๊ด€๊ณ„๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ํ—ฌํผ ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค:

   @OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
   @Builder.Default
   private List<PostSkill> postSkills = new ArrayList<>();
+  
+  // ์–‘๋ฐฉํ–ฅ ๊ด€๊ณ„ ์œ ์ง€๋ฅผ ์œ„ํ•œ ํ—ฌํผ ๋ฉ”์„œ๋“œ
+  public void addPostSkill(PostSkill postSkill) {
+    this.postSkills.add(postSkill);
+    if (postSkill.getPost() != this) {
+      postSkill.setPost(this);
+    }
+  }
+  
+  public void removePostSkill(PostSkill postSkill) {
+    this.postSkills.remove(postSkill);
+    if (postSkill.getPost() == this) {
+      postSkill.setPost(null);
+    }
+  }
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// ์–‘๋ฐฉํ–ฅ ๋งคํ•‘
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
@Builder.Default
private List<PostSkill> postSkills = new ArrayList<>();
// ์–‘๋ฐฉํ–ฅ ๋งคํ•‘
@OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
@Builder.Default
private List<PostSkill> postSkills = new ArrayList<>();
// ์–‘๋ฐฉํ–ฅ ๊ด€๊ณ„ ์œ ์ง€๋ฅผ ์œ„ํ•œ ํ—ฌํผ ๋ฉ”์„œ๋“œ
public void addPostSkill(PostSkill postSkill) {
this.postSkills.add(postSkill);
if (postSkill.getPost() != this) {
postSkill.setPost(this);
}
}
public void removePostSkill(PostSkill postSkill) {
this.postSkills.remove(postSkill);
if (postSkill.getPost() == this) {
postSkill.setPost(null);
}
}

Comment on lines +75 to +91
@Override
public PostDetailDTO getPostDetail(Long postId) {
// ๊ฒŒ์‹œ๊ธ€ ์ •๋ณด ์กฐํšŒ
Post post = postRepository.findByIdWithSkills(postId)
.orElseThrow();

// ์Šคํ‚ฌ ์ด๋ฆ„ ์กฐํšŒ
List<String> skills = post.getPostSkills().stream()
.map(s -> s.getSkill().getName())
.collect(Collectors.toList());

// ๋งค์นญ ์‚ฌ์šฉ์ž ์ •๋ณด ์กฐํšŒ
// TODO : ์‹ค์ œ ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ์กฐํšŒ
List<MatchedUserDTO> matchedUsers = new ArrayList<>();

return PostDetailDTO.from(post,skills, matchedUsers);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

getPostDetail ๋ฉ”์„œ๋“œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ๊ฐœ์„  ํ•„์š”

ํ˜„์žฌ getPostDetail ๋ฉ”์„œ๋“œ์—์„œ๋Š” ๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์ง€ ๋ชปํ–ˆ์„ ๋•Œ .orElseThrow()๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์ง€๋งŒ, ๊ตฌ์ฒด์ ์ธ ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€๋ฅผ ์ œ๊ณตํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ TODO ์ฃผ์„์ด ์žˆ๋Š”๋ฐ, ์‹ค์ œ ๋งค์นญ๋œ ์‚ฌ์šฉ์ž๋ฅผ ์กฐํšŒํ•˜๋Š” ๊ตฌํ˜„์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

+  /**
+   * ๊ฒŒ์‹œ๊ธ€ ID๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์ •๋ณด๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
+   * ๊ฒŒ์‹œ๊ธ€๊ณผ ๊ด€๋ จ ์Šคํ‚ฌ, ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ํ•จ๊ป˜ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
+   *
+   * @param postId ์กฐํšŒํ•  ๊ฒŒ์‹œ๊ธ€ ID
+   * @return ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์ •๋ณด๊ฐ€ ๋‹ด๊ธด DTO
+   * @throws NoSuchElementException ํ•ด๋‹น ID์˜ ๊ฒŒ์‹œ๊ธ€์ด ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ
+   */
+  @Transactional(readOnly = true)
   @Override
   public PostDetailDTO getPostDetail(Long postId) {
     // ๊ฒŒ์‹œ๊ธ€ ์ •๋ณด ์กฐํšŒ
     Post post = postRepository.findByIdWithSkills(postId)
-            .orElseThrow();
+            .orElseThrow(() -> new NoSuchElementException("ID๊ฐ€ " + postId + "์ธ ๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค"));

     // ์Šคํ‚ฌ ์ด๋ฆ„ ์กฐํšŒ
     List<String> skills = post.getPostSkills().stream()
             .map(s -> s.getSkill().getName())
-            .collect(Collectors.toList());
+            .toList();

     // ๋งค์นญ ์‚ฌ์šฉ์ž ์ •๋ณด ์กฐํšŒ
     // TODO : ์‹ค์ œ ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ์กฐํšŒ
+    // ์‚ฌ์šฉ์ž ๋งค์นญ ๋กœ์ง ๊ตฌํ˜„ ํ•„์š”
     List<MatchedUserDTO> matchedUsers = new ArrayList<>();

     return PostDetailDTO.from(post,skills, matchedUsers);
   }
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Override
public PostDetailDTO getPostDetail(Long postId) {
// ๊ฒŒ์‹œ๊ธ€ ์ •๋ณด ์กฐํšŒ
Post post = postRepository.findByIdWithSkills(postId)
.orElseThrow();
// ์Šคํ‚ฌ ์ด๋ฆ„ ์กฐํšŒ
List<String> skills = post.getPostSkills().stream()
.map(s -> s.getSkill().getName())
.collect(Collectors.toList());
// ๋งค์นญ ์‚ฌ์šฉ์ž ์ •๋ณด ์กฐํšŒ
// TODO : ์‹ค์ œ ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ์กฐํšŒ
List<MatchedUserDTO> matchedUsers = new ArrayList<>();
return PostDetailDTO.from(post,skills, matchedUsers);
}
/**
* ๊ฒŒ์‹œ๊ธ€ ID๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์ •๋ณด๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
* ๊ฒŒ์‹œ๊ธ€๊ณผ ๊ด€๋ จ ์Šคํ‚ฌ, ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ํ•จ๊ป˜ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
*
* @param postId ์กฐํšŒํ•  ๊ฒŒ์‹œ๊ธ€ ID
* @return ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์ •๋ณด๊ฐ€ ๋‹ด๊ธด DTO
* @throws NoSuchElementException ํ•ด๋‹น ID์˜ ๊ฒŒ์‹œ๊ธ€์ด ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ
*/
@Transactional(readOnly = true)
@Override
public PostDetailDTO getPostDetail(Long postId) {
// ๊ฒŒ์‹œ๊ธ€ ์ •๋ณด ์กฐํšŒ
Post post = postRepository.findByIdWithSkills(postId)
.orElseThrow(() -> new NoSuchElementException("ID๊ฐ€ " + postId + "์ธ ๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค"));
// ์Šคํ‚ฌ ์ด๋ฆ„ ์กฐํšŒ
List<String> skills = post.getPostSkills().stream()
.map(s -> s.getSkill().getName())
.toList();
// ๋งค์นญ ์‚ฌ์šฉ์ž ์ •๋ณด ์กฐํšŒ
// TODO : ์‹ค์ œ ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ์กฐํšŒ
// ์‚ฌ์šฉ์ž ๋งค์นญ ๋กœ์ง ๊ตฌํ˜„ ํ•„์š”
List<MatchedUserDTO> matchedUsers = new ArrayList<>();
return PostDetailDTO.from(post, skills, matchedUsers);
}

Comment on lines +58 to +61
@GetMapping
public ResponseEntity<List<PostResponseDTO>> getAllPosts(){
return ResponseEntity.ok(postService.getAllPosts());
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

ํŽ˜์ด์ง€๋„ค์ด์…˜ ๊ตฌํ˜„์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

getAllPosts() ๋ฉ”์„œ๋“œ๋Š” ๋ชจ๋“  ๊ฒŒ์‹œ๊ธ€์„ ํ•œ ๋ฒˆ์— ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ฒŒ์‹œ๊ธ€ ์ˆ˜๊ฐ€ ๋งŽ์•„์ง€๋ฉด ์„ฑ๋Šฅ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŽ˜์ด์ง€๋„ค์ด์…˜์„ ๊ตฌํ˜„ํ•˜์—ฌ ํ•œ ๋ฒˆ์— ๋กœ๋“œ๋˜๋Š” ๋ฐ์ดํ„ฐ์˜ ์–‘์„ ์ œํ•œํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ํŽ˜์ด์ง€๋„ค์ด์…˜์„ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

@Operation(summary="๋ชจ์ง‘๊ธ€ ์กฐํšŒ", description = "๋ชจ์ง‘๊ธ€ ๋ชฉ๋ก์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping
- public ResponseEntity<List<PostResponseDTO>> getAllPosts(){
-   return ResponseEntity.ok(postService.getAllPosts());
+ public ResponseEntity<Page<PostResponseDTO>> getAllPosts(
+     @RequestParam(defaultValue = "0") int page,
+     @RequestParam(defaultValue = "10") int size,
+     @RequestParam(defaultValue = "id") String sortBy) {
+   Pageable pageable = PageRequest.of(page, size, Sort.by(sortBy).descending());
+   return ResponseEntity.ok(postService.getAllPosts(pageable));
}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +63 to +67
@Operation(summary="๋ชจ์ง‘๊ธ€ ์ƒ์„ธ ์กฐํšŒ", description="๋ชจ์ง‘๊ธ€ ๊ฒŒ์‹œ๊ธ€์„ ์ƒ์„ธ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค")
@GetMapping("/{postId}")
public ResponseEntity<PostDetailDTO> getPostDetail(@PathVariable Long postId){
return ResponseEntity.ok(postService.getPostDetail(postId));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

์˜ˆ์™ธ ์ฒ˜๋ฆฌ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

getPostDetail() ๋ฉ”์„œ๋“œ๋Š” ์กด์žฌํ•˜์ง€ ์•Š๋Š” ID์— ๋Œ€ํ•œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๊ฐ€ ๋ช…์‹œ์ ์œผ๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์„œ๋น„์Šค ๊ณ„์ธต์—์„œ ์˜ˆ์™ธ๋ฅผ ๋˜์งˆ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์ด๋ฅผ ์ ์ ˆํžˆ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

@Operation(summary="๋ชจ์ง‘๊ธ€ ์ƒ์„ธ ์กฐํšŒ", description="๋ชจ์ง‘๊ธ€ ๊ฒŒ์‹œ๊ธ€์„ ์ƒ์„ธ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค")
@GetMapping("/{postId}")
public ResponseEntity<PostDetailDTO> getPostDetail(@PathVariable Long postId){
+   try {
      return ResponseEntity.ok(postService.getPostDetail(postId));
+   } catch (NoSuchElementException e) {
+       log.error("๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ID: {}", postId, e);
+       return ResponseEntity.notFound().build();
+   } catch (Exception e) {
+       log.error("๊ฒŒ์‹œ๊ธ€ ์กฐํšŒ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ. ID: {}", postId, e);
+       return ResponseEntity.internalServerError().build();
+   }
}

๋˜๋Š” ์ „์—ญ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๊ธฐ(Global Exception Handler)๋ฅผ ๊ตฌํ˜„ํ•˜์—ฌ ๋ชจ๋“  ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์˜ˆ์™ธ๋ฅผ ์ค‘์•™์—์„œ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒƒ์„ ๊ณ ๋ คํ•ด ๋ณด์„ธ์š”.

๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Operation(summary="๋ชจ์ง‘๊ธ€ ์ƒ์„ธ ์กฐํšŒ", description="๋ชจ์ง‘๊ธ€ ๊ฒŒ์‹œ๊ธ€์„ ์ƒ์„ธ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค")
@GetMapping("/{postId}")
public ResponseEntity<PostDetailDTO> getPostDetail(@PathVariable Long postId){
return ResponseEntity.ok(postService.getPostDetail(postId));
}
@Operation(summary="๋ชจ์ง‘๊ธ€ ์ƒ์„ธ ์กฐํšŒ", description="๋ชจ์ง‘๊ธ€ ๊ฒŒ์‹œ๊ธ€์„ ์ƒ์„ธ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค")
@GetMapping("/{postId}")
public ResponseEntity<PostDetailDTO> getPostDetail(@PathVariable Long postId){
try {
return ResponseEntity.ok(postService.getPostDetail(postId));
} catch (NoSuchElementException e) {
log.error("๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ID: {}", postId, e);
return ResponseEntity.notFound().build();
} catch (Exception e) {
log.error("๊ฒŒ์‹œ๊ธ€ ์กฐํšŒ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ. ID: {}", postId, e);
return ResponseEntity.internalServerError().build();
}
}

Comment on lines +45 to +55
@Operation(summary="๋ชจ์ง‘๊ธ€ ๋“ฑ๋ก ํ…Œ์ŠคํŠธ", description="[TEST] ๋ชจ์ง‘๊ธ€์„ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.")
@PostMapping("/mock")
public ResponseEntity<?> createPostForSwagger(@RequestBody PostRequestDTO dto){

// ํ…Œ์ŠคํŠธ์šฉ userId
User mockUser = userRepository.findById(1L).orElseThrow();
Post createPost = postService.createPost(dto, mockUser);
List<String> skills = postSkillRepository.findSkillByPostId(createPost.getId());
PostResponseDTO responseDTO = PostResponseDTO.from(createPost, skills, 0);
return ResponseEntity.ok(responseDTO);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

ํ…Œ์ŠคํŠธ์šฉ ์—”๋“œํฌ์ธํŠธ์— ๋Œ€ํ•œ ๋ณด์•ˆ ๋ฐ ์„ค๊ณ„ ๊ฐœ์„ ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

ํ…Œ์ŠคํŠธ์šฉ ์—”๋“œํฌ์ธํŠธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฌธ์ œ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  1. ํ•˜๋“œ์ฝ”๋”ฉ๋œ userId(1L)๋Š” ํ•ด๋‹น ์‚ฌ์šฉ์ž๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  2. ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ ํ…Œ์ŠคํŠธ ์—”๋“œํฌ์ธํŠธ๊ฐ€ ๋…ธ์ถœ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ์ •๊ทœ createPost ๋ฉ”์„œ๋“œ์™€ ์ฝ”๋“œ ์ค‘๋ณต์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ ๊ฐœ์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  1. ํ…Œ์ŠคํŠธ ์—”๋“œํฌ์ธํŠธ๋Š” ๊ฐœ๋ฐœ/ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ์—์„œ๋งŒ ํ™œ์„ฑํ™”๋˜๋„๋ก ์„ค์ •
  2. ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ์ถ”๊ฐ€
  3. ํ•˜๋“œ์ฝ”๋”ฉ๋œ ID ๋Œ€์‹  ๋” ์•ˆ์ „ํ•œ ๋ฐฉ๋ฒ• ์‚ฌ์šฉ
+ @Profile({"dev", "test"}) // ๊ฐœ๋ฐœ ๋ฐ ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ์—์„œ๋งŒ ํ™œ์„ฑํ™”
@Operation(summary="๋ชจ์ง‘๊ธ€ ๋“ฑ๋ก ํ…Œ์ŠคํŠธ", description="[TEST] ๋ชจ์ง‘๊ธ€์„ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.")
@PostMapping("/mock")
public ResponseEntity<?> createPostForSwagger(@RequestBody PostRequestDTO dto){
  // ํ…Œ์ŠคํŠธ์šฉ userId
- User mockUser = userRepository.findById(1L).orElseThrow();
+ User mockUser = userRepository.findById(1L)
+     .orElseThrow(() -> new IllegalStateException("ํ…Œ์ŠคํŠธ์šฉ ์‚ฌ์šฉ์ž(ID: 1)๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."));
  
  // createPost ๋ฉ”์„œ๋“œ๋ฅผ ์žฌ์‚ฌ์šฉํ•˜์—ฌ ์ค‘๋ณต ์ฝ”๋“œ ์ œ๊ฑฐ
- Post createPost = postService.createPost(dto, mockUser);
- List<String> skills = postSkillRepository.findSkillByPostId(createPost.getId());
- PostResponseDTO responseDTO = PostResponseDTO.from(createPost, skills, 0);
- return ResponseEntity.ok(responseDTO);
+ return createPost(dto, mockUser);
}

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +29 to +31
private final PostService postService;
private final UserRepository userRepository;
private final PostSkillRepository postSkillRepository;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์ง์ ‘ Repository ์ ‘๊ทผ์€ ์ง€์–‘ํ•˜์„ธ์š”.

์ปจํŠธ๋กค๋Ÿฌ ๋ ˆ์ด์–ด์—์„œ ์ง์ ‘ UserRepository์™€ PostSkillRepository๋ฅผ ์ฃผ์ž…๋ฐ›์•„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ ๊ณ„์ธต ๊ตฌ์กฐ์˜ ์›์น™์„ ์œ„๋ฐ˜ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฐ์ดํ„ฐ ์•ก์„ธ์Šค๋Š” ์„œ๋น„์Šค ๋ ˆ์ด์–ด๋ฅผ ํ†ตํ•ด ์ด๋ฃจ์–ด์ ธ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ปจํŠธ๋กค๋Ÿฌ๋Š” ์„œ๋น„์Šค ๋ ˆ์ด์–ด์™€๋งŒ ์ƒํ˜ธ์ž‘์šฉํ•˜๊ณ , ์„œ๋น„์Šค ๋ ˆ์ด์–ด๊ฐ€ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๊ตฌ์กฐ๊ฐ€ ๋ฐ”๋žŒ์งํ•ฉ๋‹ˆ๋‹ค.

๋ฆฌํฌ์ง€ํ† ๋ฆฌ ์ ‘๊ทผ ๋กœ์ง์„ ์„œ๋น„์Šค ๊ณ„์ธต์œผ๋กœ ์ด๋™ํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค:

  public class PostController {
    private final PostService postService;
-   private final UserRepository userRepository;
-   private final PostSkillRepository postSkillRepository;

  @PostMapping
  public ResponseEntity<?> createPost(@RequestBody PostRequestDTO dto, @AuthenticationPrincipal User user){
    Post createPost = postService.createPost(dto, user);
-   // ์Šคํ‚ฌ ์กฐํšŒ
-   List<String> skills = postSkillRepository.findSkillByPostId(createPost.getId());
    // dto ๋ฐ˜ํ™˜
    // TODO : currentCount ๋กœ์ง ๊ตฌํ˜„ ํ›„ ๋ณ€ํ™˜
-   PostResponseDTO responseDTO = PostResponseDTO.from(createPost, skills, 0);
+   PostResponseDTO responseDTO = postService.getPostResponse(createPost);
    return ResponseEntity.ok(responseDTO);
  }
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private final PostService postService;
private final UserRepository userRepository;
private final PostSkillRepository postSkillRepository;
public class PostController {
private final PostService postService;
@PostMapping
public ResponseEntity<?> createPost(@RequestBody PostRequestDTO dto, @AuthenticationPrincipal User user) {
Post createPost = postService.createPost(dto, user);
// dto ๋ฐ˜ํ™˜
// TODO : currentCount ๋กœ์ง ๊ตฌํ˜„ ํ›„ ๋ณ€ํ™˜
PostResponseDTO responseDTO = postService.getPostResponse(createPost);
return ResponseEntity.ok(responseDTO);
}
}

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2025

Walkthrough

์ด๋ฒˆ ๋ณ€๊ฒฝ์—์„œ๋Š” ๊ฒŒ์‹œ๊ธ€(Post) ๊ด€๋ จ ๊ธฐ๋Šฅ์˜ ํŒจํ‚ค์ง€ ๊ตฌ์กฐ๋ฅผ ์„ธ๋ถ„ํ™”ํ•˜๊ณ , ๊ฒŒ์‹œ๊ธ€ ๋“ฑ๋กยท์กฐํšŒยท์ƒ์„ธ์กฐํšŒ API๋ฅผ ๊ตฌํ˜„ํ•˜์˜€์œผ๋ฉฐ, ์ด๋ฅผ ์œ„ํ•œ DTO, ์„œ๋น„์Šค, ๋ ˆํฌ์ง€ํ† ๋ฆฌ ๊ณ„์ธต์„ ์‹ ์„คํ•˜์˜€์Šต๋‹ˆ๋‹ค. Skill(๊ธฐ์ˆ ) ๊ด€๋ จ ๋ ˆํฌ์ง€ํ† ๋ฆฌ ๋ฐ ์„œ๋น„์Šค, Apply(์ง€์›) ๊ด€๋ จ ํŒจํ‚ค์ง€ ๊ตฌ์กฐ๋„ ์ •๋น„๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ Spring Security ์˜์กด์„ฑ์ด ํ™œ์„ฑํ™”๋˜์—ˆ๊ณ , ์—”ํ‹ฐํ‹ฐ ๊ด€๊ณ„(๊ฒŒ์‹œ๊ธ€-๊ธฐ์ˆ ) ๋ฐ ํ•„๋“œ๊ฐ€ ํ™•์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ์กด post ํŒจํ‚ค์ง€์˜ ์ปจํŠธ๋กค๋Ÿฌ, ์„œ๋น„์Šค, ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋Š” ์‚ญ์ œ๋˜๊ณ , ์ƒˆ๋กœ์šด ๊ตฌ์กฐ๋กœ ์žฌ๊ตฌ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

Changes

ํŒŒ์ผ/๊ฒฝ๋กœ ๊ทธ๋ฃน ๋ณ€๊ฒฝ ์š”์•ฝ
build.gradle Spring Security ์˜์กด์„ฑ ์ฃผ์„ ํ•ด์ œ
src/main/java/aibe/hosik/analysis/Analysis.java Apply ํด๋ž˜์Šค import ๊ฒฝ๋กœ ์ˆ˜์ •
src/main/java/aibe/hosik/apply/... (controller, entity, repository, service) Apply ๊ด€๋ จ ํŒŒ์ผ ํŒจํ‚ค์ง€ ๊ตฌ์กฐ ์„ธ๋ถ„ํ™” ๋ฐ import ์ •๋น„, ์ฃผ์„ ์ถ”๊ฐ€
src/main/java/aibe/hosik/skill/cotnroller/SkillController.java
.../skill/service/SkillService.java
Skill ๊ด€๋ จ ํŒŒ์ผ ํŒจํ‚ค์ง€๋ช… ๋ฐ import ์ •๋น„
src/main/java/aibe/hosik/skill/repository/SkillRepository.java ํŒจํ‚ค์ง€๋ช… ๋ฐ import ์ •๋น„, findByName ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
src/main/java/aibe/hosik/skill/repository/PostSkillRepository.java PostSkillRepository ์‹ ์„ค, ๊ฒŒ์‹œ๊ธ€๋ณ„ ๊ธฐ์ˆ  ์กฐํšŒ ์ฟผ๋ฆฌ ์ถ”๊ฐ€
src/main/java/aibe/hosik/post/PostController.java
.../PostService.java
.../PostRepository.java
๊ธฐ์กด post ์ปจํŠธ๋กค๋Ÿฌ, ์„œ๋น„์Šค, ๋ ˆํฌ์ง€ํ† ๋ฆฌ ์‚ญ์ œ
src/main/java/aibe/hosik/post/controller/PostController.java ๊ฒŒ์‹œ๊ธ€ ์ปจํŠธ๋กค๋Ÿฌ ์‹ ์„ค ๋ฐ REST API ์—”๋“œํฌ์ธํŠธ ๊ตฌํ˜„
src/main/java/aibe/hosik/post/dto/MatchedUserDTO.java
.../PostDetailDTO.java
.../PostRequestDTO.java
.../PostResponseDTO.java
๊ฒŒ์‹œ๊ธ€ ๊ด€๋ จ DTO(๋ ˆ์ฝ”๋“œ) ์‹ ์„ค ๋ฐ ํŒฉํ† ๋ฆฌ/๋ณ€ํ™˜ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
src/main/java/aibe/hosik/post/entity/Post.java requirementPersonality ํ•„๋“œ ๋ฐ PostSkill ์—ฐ๊ด€๊ด€๊ณ„ ์ถ”๊ฐ€
src/main/java/aibe/hosik/post/repository/PostRepository.java PostRepository ์‹ ์„ค, ๊ธฐ์ˆ  ์กฐ์ธ fetch ์ฟผ๋ฆฌ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
src/main/java/aibe/hosik/post/service/PostService.java
.../PostServiceImpl.java
PostService ์ธํ„ฐํŽ˜์ด์Šค ๋ฐ ๊ตฌํ˜„์ฒด ์‹ ์„ค, ๊ฒŒ์‹œ๊ธ€ ๋“ฑ๋ก/์กฐํšŒ/์ƒ์„ธ์กฐํšŒ ๋กœ์ง ๊ตฌํ˜„

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PostController
    participant PostService
    participant PostRepository
    participant SkillRepository
    participant PostSkillRepository
    participant UserRepository

    Client->>PostController: POST /api/posts (PostRequestDTO)
    PostController->>UserRepository: ์ธ์ฆ ์‚ฌ์šฉ์ž ์กฐํšŒ
    PostController->>PostService: createPost(dto, user)
    PostService->>PostRepository: ๊ฒŒ์‹œ๊ธ€ ์ €์žฅ
    loop ๊ฐ skill
        PostService->>SkillRepository: findByName(skill)
        alt skill ์—†์Œ
            PostService->>SkillRepository: skill ์ƒ์„ฑ ๋ฐ ์ €์žฅ
        end
        PostService->>PostSkillRepository: PostSkill ์ €์žฅ
    end
    PostService-->>PostController: ์ €์žฅ๋œ Post ๋ฐ˜ํ™˜
    PostController->>PostSkillRepository: ๊ฒŒ์‹œ๊ธ€๋ณ„ ๊ธฐ์ˆ  ์กฐํšŒ
    PostController-->>Client: PostResponseDTO ๋ฐ˜ํ™˜
Loading
sequenceDiagram
    participant Client
    participant PostController
    participant PostService
    participant PostRepository
    participant PostSkillRepository

    Client->>PostController: GET /api/posts
    PostController->>PostService: getAllPosts()
    PostService->>PostRepository: findAllWithSkills()
    loop ๊ฐ Post
        PostService->>PostSkillRepository: ๊ธฐ์ˆ ๋ช… ๋ฆฌ์ŠคํŠธ ์กฐํšŒ
    end
    PostService-->>PostController: PostResponseDTO ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜
    PostController-->>Client: PostResponseDTO ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜
Loading

Poem

๐Ÿ‡
์ƒˆ์‹น์ฒ˜๋Ÿผ ํŒจํ‚ค์ง€ ๊ฐˆ๋ผ,
๊ฒŒ์‹œ๊ธ€ API๊ฐ€ ํ™œ์ง ํ”ผ์—ˆ๋„ค!
๊ธฐ์ˆ ๋„ ์ฒ™์ฒ™ ์—ฐ๊ฒฐํ•˜๊ณ ,
DTO ํ† ๋ผ๋“ค์ด ํด์งํด์ง.
Security๋„ ๊นจ์–ด๋‚˜๊ณ ,
์„œ๋น„์Šค์™€ ๋ ˆํฌ์ง€ํ† ๋ฆฌ,
๋ชจ๋‘๋ชจ๋‘ ์ƒˆ๋กœ์›Œ์ง„ ๋ด„๋‚ ์ด์•ผ!
๐ŸŒฑโœจ

โœจ Finishing Touches
  • ๐Ÿ“ Generate Docstrings

๐Ÿชง Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

๐Ÿ”ญ Outside diff range comments (1)
src/main/java/aibe/hosik/apply/controller/ApplyController.java (1)

9-15: ๐Ÿ› ๏ธ Refactor suggestion

์ปจํŠธ๋กค๋Ÿฌ ๋ฉ”์„œ๋“œ ๊ตฌํ˜„ ๋ˆ„๋ฝ
ํ˜„์žฌ ApplyController์— ์‹ค์ œ REST API ์—”๋“œํฌ์ธํŠธ ๋ฉ”์„œ๋“œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
์ง€์›์„œ ๋“ฑ๋ก, ๋ชฉ๋ก ์กฐํšŒ, ์ƒ์„ธ ์กฐํšŒ ๋“ฑ์˜ CRUD ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

โ™ป๏ธ Duplicate comments (13)
src/main/java/aibe/hosik/apply/repository/ApplyRepository.java (1)

7-8: post ID๋กœ ์ง€์›์„œ ์กฐํšŒ ๋ฉ”์„œ๋“œ ๊ตฌํ˜„ ํ•„์š”
์ฃผ์„์œผ๋กœ๋งŒ ๋‚จ์•„ ์žˆ๋Š” // post id๋กœ ์ง€์›์„œ ์กฐํšŒ ๋ถ€๋ถ„์— ์‹ค์ œ ์ฟผ๋ฆฌ ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
์˜ˆ: List<Apply> findByPostId(Long postId);

src/main/java/aibe/hosik/skill/cotnroller/SkillController.java (1)

1-1: ํŒจํ‚ค์ง€ ์ด๋ฆ„์— ์˜คํƒ€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค

ํŒจํ‚ค์ง€ ์ด๋ฆ„์ด aibe.hosik.skill.cotnroller๋กœ ๋˜์–ด ์žˆ๋Š”๋ฐ, ์ •ํ™•ํ•œ ์ŠคํŽ ๋ง์€ aibe.hosik.skill.controller์ž…๋‹ˆ๋‹ค. ํŒจํ‚ค์ง€ ์ด๋ฆ„์˜ ์˜คํƒ€๋Š” ์ถ”ํ›„์— ์ž„ํฌํŠธ ๋ฌธ์ œ๋ฅผ ์ผ์œผํ‚ฌ ์ˆ˜ ์žˆ์œผ๋‹ˆ ์ˆ˜์ •ํ•ด์ฃผ์„ธ์š”.

-package aibe.hosik.skill.cotnroller;
+package aibe.hosik.skill.controller;
src/main/java/aibe/hosik/post/entity/Post.java (2)

40-42: requirementPersonality ํ•„๋“œ์— ์œ ํšจ์„ฑ ์ œ์•ฝ์กฐ๊ฑด ์ถ”๊ฐ€ ํ•„์š”

requirementPersonality ํ•„๋“œ์— ์œ ํšจ์„ฑ ์ œ์•ฝ์กฐ๊ฑด์ด ์—†์Šต๋‹ˆ๋‹ค. ์ด ํ•„๋“œ์— ๋„ˆ๋ฌด ๊ธด ํ…์ŠคํŠธ๊ฐ€ ์ €์žฅ๋  ๊ฒฝ์šฐ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. @Size ์• ๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธธ์ด ์ œํ•œ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

-  @Column
+  @Column(length = 500)
+  @Size(max = 500)
   private String requirementPersonality;

57-60: ์–‘๋ฐฉํ–ฅ ๋งคํ•‘์— ๋Œ€ํ•œ ํ—ฌํผ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€ ํ•„์š”

์–‘๋ฐฉํ–ฅ ๋งคํ•‘์„ ์‚ฌ์šฉํ•  ๋•Œ๋Š” ์–‘์ชฝ์—์„œ ๊ด€๊ณ„๋ฅผ ์„ค์ •ํ•˜๋Š” ํ—ฌํผ ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ํ˜„์žฌ๋Š” ๊ด€๊ณ„ ์„ค์ • ์ฑ…์ž„์ด ์„œ๋น„์Šค ๊ณ„์ธต์— ์žˆ์–ด์„œ ์ผ๊ด€์„ฑ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํฌ์ŠคํŠธ์™€ ์Šคํ‚ฌ ๊ฐ„์˜ ์–‘๋ฐฉํ–ฅ ๊ด€๊ณ„๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ํ—ฌํผ ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค:

  @OneToMany(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
  @Builder.Default
  private List<PostSkill> postSkills = new ArrayList<>();
+  
+  // ์–‘๋ฐฉํ–ฅ ๊ด€๊ณ„ ์œ ์ง€๋ฅผ ์œ„ํ•œ ํ—ฌํผ ๋ฉ”์„œ๋“œ
+  public void addPostSkill(PostSkill postSkill) {
+    this.postSkills.add(postSkill);
+    if (postSkill.getPost() != this) {
+      postSkill.setPost(this);
+    }
+  }
+  
+  public void removePostSkill(PostSkill postSkill) {
+    this.postSkills.remove(postSkill);
+    if (postSkill.getPost() == this) {
+      postSkill.setPost(null);
+    }
+  }
src/main/java/aibe/hosik/post/dto/PostRequestDTO.java (1)

11-23: ๋นˆ ์œ ํšจ์„ฑ ๊ฒ€์ฆ ์• ๋…ธํ…Œ์ด์…˜์ด ๋ˆ„๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค

ํ˜„์žฌ PostRequestDTO์˜ ํ•„๋“œ๋“ค์— ๋Œ€ํ•œ ์œ ํšจ์„ฑ ๊ฒ€์ฆ์ด ์—†์Šต๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์ž˜๋ชป๋œ ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅํ•  ๊ฒฝ์šฐ ์„œ๋ฒ„์—์„œ ์ ์ ˆํ•œ ๊ฒ€์ฆ ์—†์ด ์ฒ˜๋ฆฌ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด Bean Validation ์• ๋…ธํ…Œ์ด์…˜์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค:

 public record PostRequestDTO(
+        @NotBlank(message = "์ œ๋ชฉ์€ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
+        @Size(max = 100, message = "์ œ๋ชฉ์€ 100์ž ์ด๋‚ด๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”")
         String title,
+        @NotBlank(message = "๋‚ด์šฉ์€ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
         String content,
+        @Min(value = 1, message = "์ธ์› ์ˆ˜๋Š” ์ตœ์†Œ 1๋ช… ์ด์ƒ์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค")
         Integer headCount,
         String image,
         String requirementPersonality,
+        @NotNull(message = "๋ชจ์ง‘ ์ข…๋ฃŒ์ผ์€ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
+        @Future(message = "๋ชจ์ง‘ ์ข…๋ฃŒ์ผ์€ ํ˜„์žฌ ์ดํ›„์˜ ๋‚ ์งœ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค")
         LocalDate endedAt,

+        @NotNull(message = "์นดํ…Œ๊ณ ๋ฆฌ๋Š” ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
         PostCategory category,
+        @NotNull(message = "ํƒ€์ž…์€ ํ•„์ˆ˜ ์ž…๋ ฅ๊ฐ’์ž…๋‹ˆ๋‹ค")
         PostType type,

+        @NotEmpty(message = "์ตœ์†Œ ํ•˜๋‚˜ ์ด์ƒ์˜ ์Šคํ‚ฌ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค")
         List<String> skills
 ) {

Bean Validation์„ ์œ„ํ•ด ์•„๋ž˜ ์˜์กด์„ฑ ์ถ”๊ฐ€๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค:

import jakarta.validation.constraints.*;
src/main/java/aibe/hosik/post/dto/PostDetailDTO.java (1)

27-41: ์—ด๊ฑฐํ˜• ํƒ€์ž… ์•ˆ์ „์„ฑ ๊ฐœ์„  ๋ฐ ์ฝ”๋“œ ํ˜•์‹ ์ˆ˜์ • ํ•„์š”

  1. category์™€ type ํ•„๋“œ๋Š” ์—ด๊ฑฐํ˜• ๊ฐ’์˜ toString() ๋Œ€์‹  name()์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
  2. ํŒŒ์ผ ๋์— ์ค‘๊ด„ํ˜ธ ํ˜•์‹์— ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค (}} โ†’ } }).

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค:

 public static PostDetailDTO from(Post post, List<String> skills, List<MatchedUserDTO> matchedUsers) {
     return new PostDetailDTO(
             post.getId(),
             post.getTitle(),
             post.getContent(),
             post.getHeadCount(),
             post.getImage(),
             post.getRequirementPersonality(),
             post.getEndedAt(),
-            post.getCategory().toString(),
-            post.getType().toString(),
+            post.getCategory().name(),
+            post.getType().name(),
             skills,
             matchedUsers
     );
-}}
+  }
+}
src/main/java/aibe/hosik/post/service/PostServiceImpl.java (2)

49-73: ํŠธ๋žœ์žญ์…˜ ๊ด€๋ฆฌ ๋ฐ ์ฝ”๋“œ ๊ฐœ์„  ํ•„์š”

ํ˜„์žฌ createPost ๋ฉ”์„œ๋“œ์—๋Š” ๋ช‡ ๊ฐ€์ง€ ๊ฐœ์„ ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค:

  1. ํŠธ๋žœ์žญ์…˜ ๊ด€๋ฆฌ๊ฐ€ ์—†์–ด ์—ฌ๋Ÿฌ ์Šคํ‚ฌ์„ ์ €์žฅํ•˜๋Š” ๊ณผ์ •์—์„œ ์˜ˆ์™ธ ๋ฐœ์ƒ ์‹œ ์ผ๋ถ€๋งŒ ์ €์žฅ๋  ์œ„ํ—˜์ด ์žˆ์Šต๋‹ˆ๋‹ค.
  2. ์ฃผ์„์—์„œ ์–ธ๊ธ‰ํ•œ๋Œ€๋กœ for ๋ฃจํ”„๋ฅผ ์ŠคํŠธ๋ฆผ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
  3. ๊ฒŒ์‹œ๊ธ€๊ณผ ์Šคํ‚ฌ ๊ฐ„์˜ ์—ฐ๊ด€๊ด€๊ณ„ ์„ค์ • ๋ถ€๋ถ„์„ ์—”ํ‹ฐํ‹ฐ ๋‚ด๋ถ€ ํ—ฌํผ ๋ฉ”์„œ๋“œ๋กœ ์ด๋™์‹œํ‚ค๋Š” ๊ฒƒ์ด ๋ฐ”๋žŒ์งํ•ฉ๋‹ˆ๋‹ค.

75-91: ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ๋ฐ ํŠธ๋žœ์žญ์…˜ ๊ด€๋ฆฌ ๊ฐœ์„  ํ•„์š”

getPostDetail ๋ฉ”์„œ๋“œ์—์„œ ๋‹ค์Œ ์‚ฌํ•ญ๋“ค์„ ๊ฐœ์„ ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

  1. ๊ฒŒ์‹œ๊ธ€์„ ์ฐพ์ง€ ๋ชปํ–ˆ์„ ๋•Œ ๊ตฌ์ฒด์ ์ธ ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
  2. ์ฝ๊ธฐ ์ „์šฉ ์ž‘์—…์— @Transactional(readOnly = true) ์–ด๋…ธํ…Œ์ด์…˜์„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  3. ์ตœ์‹  Java ๋ฌธ๋ฒ•์„ ํ™œ์šฉํ•˜์—ฌ collect(Collectors.toList()) ๋Œ€์‹  toList()๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.
src/main/java/aibe/hosik/post/controller/PostController.java (5)

29-31: ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์ง์ ‘ Repository ์ ‘๊ทผ์€ ์ง€์–‘ํ•˜์„ธ์š”

์ปจํŠธ๋กค๋Ÿฌ ๋ ˆ์ด์–ด์—์„œ ์ง์ ‘ UserRepository์™€ PostSkillRepository๋ฅผ ์ฃผ์ž…๋ฐ›์•„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์€ ๊ณ„์ธต ๊ตฌ์กฐ ์›์น™์„ ์œ„๋ฐ˜ํ•ฉ๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ ์•ก์„ธ์Šค๋Š” ์„œ๋น„์Šค ๋ ˆ์ด์–ด๋ฅผ ํ†ตํ•ด ์ด๋ฃจ์–ด์ ธ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ปจํŠธ๋กค๋Ÿฌ๋Š” ์„œ๋น„์Šค ๋ ˆ์ด์–ด์™€๋งŒ ์ƒํ˜ธ์ž‘์šฉํ•˜๊ณ , ์„œ๋น„์Šค ๋ ˆ์ด์–ด๊ฐ€ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๊ตฌ์กฐ๊ฐ€ ๋ฐ”๋žŒ์งํ•ฉ๋‹ˆ๋‹ค.


44-55: ํ…Œ์ŠคํŠธ์šฉ ์—”๋“œํฌ์ธํŠธ ๊ฐœ์„  ํ•„์š”

ํ…Œ์ŠคํŠธ์šฉ ์—”๋“œํฌ์ธํŠธ์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฌธ์ œ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค:

  1. ํ•˜๋“œ์ฝ”๋”ฉ๋œ userId(1L)๋Š” ํ•ด๋‹น ์‚ฌ์šฉ์ž๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  2. ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ ํ…Œ์ŠคํŠธ ์—”๋“œํฌ์ธํŠธ๊ฐ€ ๋…ธ์ถœ๋  ์ˆ˜ ์žˆ์–ด ๋ณด์•ˆ ์œ„ํ—˜์ด ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ์ •๊ทœ createPost ๋ฉ”์„œ๋“œ์™€ ์ฝ”๋“œ ์ค‘๋ณต์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

57-61: ํŽ˜์ด์ง€๋„ค์ด์…˜ ๊ตฌํ˜„ ํ•„์š”

getAllPosts() ๋ฉ”์„œ๋“œ๋Š” ๋ชจ๋“  ๊ฒŒ์‹œ๊ธ€์„ ํ•œ ๋ฒˆ์— ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๊ฒŒ์‹œ๊ธ€ ์ˆ˜๊ฐ€ ๋งŽ์•„์ง€๋ฉด ์„ฑ๋Šฅ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŽ˜์ด์ง€๋„ค์ด์…˜์„ ๊ตฌํ˜„ํ•˜์—ฌ ํ•œ ๋ฒˆ์— ๋กœ๋“œ๋˜๋Š” ๋ฐ์ดํ„ฐ์˜ ์–‘์„ ์ œํ•œํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.


63-67: ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ์ถ”๊ฐ€ ํ•„์š”

getPostDetail() ๋ฉ”์„œ๋“œ๋Š” ์กด์žฌํ•˜์ง€ ์•Š๋Š” ID์— ๋Œ€ํ•œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๊ฐ€ ๋ช…์‹œ์ ์œผ๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์„œ๋น„์Šค ๊ณ„์ธต์—์„œ ์˜ˆ์™ธ๋ฅผ ๋˜์งˆ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์ด๋ฅผ ์ ์ ˆํžˆ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.


33-43: ๐Ÿ› ๏ธ Refactor suggestion

์„œ๋น„์Šค ๊ณ„์ธต์œผ๋กœ ์ฑ…์ž„ ์ด๋™ ํ•„์š”

ํ˜„์žฌ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์ง์ ‘ ์Šคํ‚ฌ์„ ์กฐํšŒํ•˜๊ณ  DTO๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋กœ์ง์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋กœ์ง์€ ์„œ๋น„์Šค ๊ณ„์ธต์œผ๋กœ ์ด๋™์‹œ์ผœ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ปจํŠธ๋กค๋Ÿฌ๋Š” ์š”์ฒญ์„ ๋ฐ›๊ณ  ์‘๋‹ต์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ์—ญํ• ๋งŒ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์ด ๋ฐ”๋žŒ์งํ•ฉ๋‹ˆ๋‹ค.

@Operation(summary="๋ชจ์ง‘๊ธ€ ๋“ฑ๋ก", description="๋ชจ์ง‘๊ธ€์„ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.")
@PostMapping
public ResponseEntity<?> createPost(@RequestBody PostRequestDTO dto, @AuthenticationPrincipal User user){
-  Post createPost = postService.createPost(dto, user);
-  // ์Šคํ‚ฌ ์กฐํšŒ
-  List<String> skills = postSkillRepository.findSkillByPostId(createPost.getId());
-  // dto ๋ฐ˜ํ™˜
-  // TODO : currentCount ๋กœ์ง ๊ตฌํ˜„ ํ›„ ๋ณ€ํ™˜
-  PostResponseDTO responseDTO = PostResponseDTO.from(createPost, skills, 0);
-  return ResponseEntity.ok(responseDTO);
+  PostResponseDTO responseDTO = postService.createAndGetPostResponse(dto, user);
+  return ResponseEntity.ok(responseDTO);
}
๐Ÿงน Nitpick comments (12)
src/main/java/aibe/hosik/apply/entity/Apply.java (1)

28-32: ๋ช…์‹œ์  JoinColumn ์ง€์ • ๊ถŒ์žฅ
@ManyToOne ์—ฐ๊ด€๊ด€๊ณ„ ํ•„๋“œ์— @JoinColumn(name = "post_id") ๋ฐ @JoinColumn(name = "resume_id")๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด DB ์Šคํ‚ค๋งˆ์™€ ๋งคํ•‘์ด ๋ช…ํ™•ํ•ด์ ธ ๊ฐ€๋…์„ฑ๊ณผ ์œ ์ง€๋ณด์ˆ˜์„ฑ์ด ๊ฐœ์„ ๋ฉ๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/apply/service/ApplyService.java (1)

8-13: ๋กœ๊ฑฐ ๋ฏธ์‚ฌ์šฉ ์‹œ ์ œ๊ฑฐ ๊ณ ๋ ค
@Slf4j ์• ๋…ธํ…Œ์ด์…˜์ด ์ ์šฉ๋˜์—ˆ์œผ๋‚˜ ํ˜„์žฌ ๋กœ๊น… ํ˜ธ์ถœ์ด ์—†์Šต๋‹ˆ๋‹ค. ์ถ”ํ›„ ๋กœ๊น… ๊ณ„ํš์ด ์—†๋‹ค๋ฉด ์ œ๊ฑฐํ•ด๋„ ์ข‹์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/post/dto/MatchedUserDTO.java (1)

1-15: ์ž˜ ์ž‘์„ฑ๋œ DTO ํด๋ž˜์Šค์ด์ง€๋งŒ ๋ถˆํ•„์š”ํ•œ ์ž„ํฌํŠธ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

DTO ๋ ˆ์ฝ”๋“œ๊ฐ€ ์ž˜ ์„ค๊ณ„๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ํ•„์š”ํ•œ ์‚ฌ์šฉ์ž ์ •๋ณด ํ•„๋“œ๋“ค์„ ๋ชจ๋‘ ํฌํ•จํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ Post ์—”ํ‹ฐํ‹ฐ๋ฅผ ์ž„ํฌํŠธํ•˜๊ณ  ์žˆ์ง€๋งŒ ์‹ค์ œ๋กœ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ถˆํ•„์š”ํ•œ ์ž„ํฌํŠธ๋ฅผ ์ œ๊ฑฐํ•˜์„ธ์š”:

package aibe.hosik.post.dto;

-import aibe.hosik.post.entity.Post;

import java.util.List;

public record MatchedUserDTO(
        Long userId,
        String username,
        String nickname,
        String image,
        String introduction
) {

}
src/main/java/aibe/hosik/skill/repository/PostSkillRepository.java (1)

16-18: ์ฃผ์„ ์˜คํƒ€ ์ˆ˜์ • ํ•„์š”

์ฃผ์„์— ์˜คํƒ€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. "์ด๋ฅด"๋Š” "์ด๋ฆ„"์˜ ์˜คํƒ€๋กœ ๋ณด์ž…๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜์„ธ์š”:

-    // Post ID๋กœ ํ•ด๋‹น ๊ธ€๊ณผ ์—ฐ๊ด€๋œ ๋ชจ๋“  ์Šคํ‚ฌ ์ด๋ฅด ์ง์ ‘ ์กฐํšŒ
+    // Post ID๋กœ ํ•ด๋‹น ๊ธ€๊ณผ ์—ฐ๊ด€๋œ ๋ชจ๋“  ์Šคํ‚ฌ ์ด๋ฆ„ ์ง์ ‘ ์กฐํšŒ
    @Query("SELECT s.skill.name FROM PostSkill s WHERE s.post.id = :postId")
    List<String> findSkillByPostId(@Param("postId") Long postId);
src/main/java/aibe/hosik/post/service/PostService.java (1)

11-15: ์„œ๋น„์Šค ์ธํ„ฐํŽ˜์ด์Šค ๋ฉ”์„œ๋“œ์— JavaDoc ์„ค๋ช… ์ถ”๊ฐ€ ๋ฐ ๋ฐ˜ํ™˜ ํƒ€์ž… ์ผ๊ด€์„ฑ ๊ฒ€ํ† 

์„œ๋น„์Šค ์ธํ„ฐํŽ˜์ด์Šค ๋ฉ”์„œ๋“œ๋“ค์ด ์ž˜ ์ •์˜๋˜์–ด ์žˆ์ง€๋งŒ, ๊ฐ ๋ฉ”์„œ๋“œ์˜ ๋ชฉ์ ๊ณผ ๋™์ž‘์„ ์„ค๋ช…ํ•˜๋Š” JavaDoc ์ฃผ์„์ด ์—†์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ createPost ๋ฉ”์„œ๋“œ๋Š” ๋‹ค๋ฅธ ๋ฉ”์„œ๋“œ๋“ค๊ณผ ๋‹ฌ๋ฆฌ ์—”ํ‹ฐํ‹ฐ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์žˆ์–ด ์ผ๊ด€์„ฑ์ด ๋–จ์–ด์ง‘๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด JavaDoc์„ ์ถ”๊ฐ€ํ•˜๊ณ  ๋ฐ˜ํ™˜ ํƒ€์ž…์„ DTO๋กœ ํ†ต์ผํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค:

public interface PostService {
+  /**
+   * ๋ชจ๋“  ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
+   * @return ๊ฒŒ์‹œ๊ธ€ ์‘๋‹ต DTO ๋ชฉ๋ก
+   */
  List<PostResponseDTO> getAllPosts();
+  
+  /**
+   * ์ƒˆ๋กœ์šด ๊ฒŒ์‹œ๊ธ€์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
+   * @param dto ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ ์š”์ฒญ DTO
+   * @param user ๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ์ž
+   * @return ์ƒ์„ฑ๋œ ๊ฒŒ์‹œ๊ธ€ ์‘๋‹ต DTO
+   */
-  Post createPost(PostRequestDTO dto, User user);
+  PostResponseDTO createPost(PostRequestDTO dto, User user);
+  
+  /**
+   * ํŠน์ • ๊ฒŒ์‹œ๊ธ€์˜ ์ƒ์„ธ ์ •๋ณด๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
+   * @param postId ์กฐํšŒํ•  ๊ฒŒ์‹œ๊ธ€ ID
+   * @return ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์ •๋ณด DTO
+   */
  PostDetailDTO getPostDetail(Long postId);
}
src/main/java/aibe/hosik/post/dto/PostResponseDTO.java (1)

7-16: ์‘๋‹ต DTO ํ•„๋“œ์— ๋Œ€ํ•œ ๋ฌธ์„œํ™” ํ•„์š”

PostResponseDTO ํด๋ž˜์Šค์˜ ๊ฐ ํ•„๋“œ์— ๋Œ€ํ•œ ์„ค๋ช…์ด ์—†์–ด ๋‹ค๋ฅธ ๊ฐœ๋ฐœ์ž๊ฐ€ ์ด DTO๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๊ฐ ํ•„๋“œ์˜ ์˜๋ฏธ์™€ ์šฉ๋„๋ฅผ ์ดํ•ดํ•˜๊ธฐ ์–ด๋ ค์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Javadoc ์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๊ฐ ํ•„๋“œ์˜ ์˜๋ฏธ์™€ ์šฉ๋„๋ฅผ ๋ช…ํ™•ํ•˜๊ฒŒ ์„ค๋ช…ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค:

/**
+ * ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก ์กฐํšŒ ์‘๋‹ต์„ ์œ„ํ•œ DTO
+ */
 public record PostResponseDTO(
+        /** ๊ฒŒ์‹œ๊ธ€ ID */
         Long id,
+        /** ๊ฒŒ์‹œ๊ธ€ ์ด๋ฏธ์ง€ URL */
         String image,
+        /** ๊ฒŒ์‹œ๊ธ€ ์ œ๋ชฉ */
         String title,
+        /** ๊ฒŒ์‹œ๊ธ€ ๋‚ด์šฉ */
         String content,
+        /** ๊ฒŒ์‹œ๊ธ€ ์นดํ…Œ๊ณ ๋ฆฌ */
         String category,
+        /** ๊ฒŒ์‹œ๊ธ€ ๊ด€๋ จ ๊ธฐ์ˆ  ๋ชฉ๋ก */
         List<String> skills,
+        /** ์ด ๋ชจ์ง‘ ์ธ์› */
         Integer headCount,
+        /** ํ˜„์žฌ ๋ชจ์ง‘๋œ ์ธ์› */
         Integer currentCount
 ) {
src/main/java/aibe/hosik/post/repository/PostRepository.java (1)

13-17: EntityGraph์™€ JPQL ์ฟผ๋ฆฌ ์‚ฌ์šฉ ๋ฐฉ์‹ ์„ค๋ช… ํ•„์š”

ํ˜„์žฌ ์ฝ”๋“œ์—์„œ๋Š” @EntityGraph๊ฐ€ ์ฃผ์„ ์ฒ˜๋ฆฌ๋˜๊ณ  JPQL ์ฟผ๋ฆฌ๊ฐ€ ์‚ฌ์šฉ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋‘ ๋ฐฉ์‹ ๋ชจ๋‘ ๊ฐ€๋Šฅํ•˜์ง€๋งŒ ์–ด๋–ค ๋ฐฉ์‹์„ ์„ ํƒํ–ˆ๋Š”์ง€์™€ ๊ทธ ์ด์œ ์— ๋Œ€ํ•œ ์„ค๋ช…์ด ์—†์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ ๋Œ€๋Ÿ‰์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์กฐํšŒํ•  ๋•Œ DISTINCT๋Š” ์„ฑ๋Šฅ ์ด์Šˆ๋ฅผ ๋ฐœ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 public interface PostRepository extends JpaRepository<Post, Long> {
-    // Post ์กฐํšŒ ์‹œ postSkills, skill ์—”ํ‹ฐํ‹ฐ ์ฆ‰์‹œ ๋กœ๋”ฉ ์ง€์ •
+    /**
+     * ๋ชจ๋“  ๊ฒŒ์‹œ๊ธ€์„ ์—ฐ๊ด€๋œ ์Šคํ‚ฌ๊ณผ ํ•จ๊ป˜ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
+     * JPQL์˜ LEFT JOIN FETCH๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ N+1 ๋ฌธ์ œ๋ฅผ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค.
+     * ์ฐธ๊ณ : EntityGraph ๋ฐฉ์‹๋„ ๊ฐ€๋Šฅํ•˜๋‚˜ JPQL ์ฟผ๋ฆฌ๊ฐ€ ๋” ๋ช…์‹œ์ ์ด์–ด์„œ ์„ ํƒํ–ˆ์Šต๋‹ˆ๋‹ค.
+     * @return ์Šคํ‚ฌ ์ •๋ณด๊ฐ€ ํฌํ•จ๋œ ๋ชจ๋“  ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก
+     */
     //@EntityGraph(attributePaths = {"postSkills", "postSkills.skill"})
     @Query("SELECT DISTINCT p FROM Post p LEFT JOIN FETCH p.postSkills ps LEFT JOIN FETCH ps.skill")
     List<Post> findAllWithSkills();
src/main/java/aibe/hosik/post/dto/PostDetailDTO.java (1)

10-26: DTO ํ•„๋“œ์— ๋Œ€ํ•œ ๋ฌธ์„œํ™” ์ถ”๊ฐ€ ํ•„์š”

PostDetailDTO ํด๋ž˜์Šค์˜ ๊ฐ ํ•„๋“œ์— ๋Œ€ํ•œ ์„ค๋ช…์ด ์—†์–ด ๋‹ค๋ฅธ ๊ฐœ๋ฐœ์ž๊ฐ€ ์ด DTO๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๊ฐ ํ•„๋“œ์˜ ์˜๋ฏธ์™€ ์šฉ๋„๋ฅผ ์ดํ•ดํ•˜๊ธฐ ์–ด๋ ค์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ "ํ˜„์žฌ ์„ ํƒ๋œ ๋ชฉ๋ก ๋ณด์—ฌ์ฃผ๊ธฐ" ์ฃผ์„์€ ๊ตฌ์ฒด์ ์ธ ์„ค๋ช…์ด ๋ถ€์กฑํ•ฉ๋‹ˆ๋‹ค.

Javadoc ์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๊ฐ ํ•„๋“œ์˜ ์˜๋ฏธ์™€ ์šฉ๋„๋ฅผ ๋ช…ํ™•ํ•˜๊ฒŒ ์„ค๋ช…ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค:

+/**
+ * ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ ์ •๋ณด๋ฅผ ์œ„ํ•œ DTO ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.
+ */
 public record PostDetailDTO(
+        /** ๊ฒŒ์‹œ๊ธ€ ID */
         Long id,
+        /** ๊ฒŒ์‹œ๊ธ€ ์ œ๋ชฉ */
         String title,
+        /** ๊ฒŒ์‹œ๊ธ€ ๋‚ด์šฉ */
         String content,
+        /** ๋ชจ์ง‘ ์ธ์› ์ˆ˜ */
         Integer headCount,
+        /** ๊ฒŒ์‹œ๊ธ€ ์ด๋ฏธ์ง€ URL */
         String image,
+        /** ์š”๊ตฌ๋˜๋Š” ์„ฑ๊ฒฉ ํŠน์„ฑ */
         String requirementPersonality,
+        /** ๋ชจ์ง‘ ์ข…๋ฃŒ์ผ */
         LocalDate endedAt,

+        /** ๊ฒŒ์‹œ๊ธ€ ์นดํ…Œ๊ณ ๋ฆฌ */
         String category,
+        /** ๊ฒŒ์‹œ๊ธ€ ํƒ€์ž… */
         String type,

+        /** ๊ด€๋ จ ๊ธฐ์ˆ  ๋ชฉ๋ก */
         List<String> skills,

-        // ํ˜„์žฌ ์„ ํƒ๋œ ๋ชฉ๋ก ๋ณด์—ฌ์ฃผ๊ธฐ
+        /** ๋งค์นญ๋œ ์‚ฌ์šฉ์ž ๋ชฉ๋ก - ํ˜„์žฌ ์„ ํƒ๋œ ์ง€์›์ž๋“ค์˜ ์ •๋ณด๋ฅผ ํฌํ•จ */
         List<MatchedUserDTO> matchedUsers
 ) {
src/main/java/aibe/hosik/post/service/PostServiceImpl.java (1)

28-47: Stream ์‚ฌ์šฉ ์‹œ ์ตœ์‹  Java ๋ฉ”์„œ๋“œ ํ™œ์šฉ ๊ถŒ์žฅ

getAllPosts() ๋ฉ”์„œ๋“œ์—์„œ ๋ฐ˜ํ™˜ ์‹œ collect(Collectors.toList())๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ๊ณ„์‹ ๋ฐ, Java 16 ์ด์ƒ์—์„œ๋Š” ๋” ๊ฐ„๊ฒฐํ•œ .toList() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ํ˜„์žฌ ์ฐธ์—ฌ์ž ์ˆ˜์— ๋Œ€ํ•œ ๊ตฌํ˜„์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

  return posts.stream()
          .map(post -> {
            // fetch๋œ postSkills์—์„œ skill ์ถ”์ถœ
            List<String> skills = post.getPostSkills().stream()
                    .map(s -> s.getSkill().getName())
-                   .collect(Collectors.toList());
+                   .toList();

            // TODO : ํ˜„์žฌ ์ฐธ์—ฌ์ž ์ˆ˜ ๊ณ„์‚ฐ
            Integer currentCount = 0;

            // DTO ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ํ™œ์šฉ
            return PostResponseDTO.from(post, skills, currentCount);
-         }).collect(Collectors.toList());
+         }).toList();
src/main/java/aibe/hosik/post/controller/PostController.java (3)

15-16: ๋ถˆํ•„์š”ํ•œ import ์ œ๊ฑฐ

org.apache.coyote.Response import๋Š” ์‚ฌ์šฉ๋˜์ง€ ์•Š๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋ถˆํ•„์š”ํ•œ import๋Š” ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

import lombok.extern.slf4j.Slf4j;
-import org.apache.coyote.Response;
import org.springframework.http.ResponseEntity;

22-22: ๋ถˆํ•„์š”ํ•œ ์ฃผ์„ ์ œ๊ฑฐ

"ํ…Œ์ŠคํŠธ" ์ฃผ์„์€ ์˜๋ฏธ๊ฐ€ ๋ถˆ๋ถ„๋ช…ํ•˜๋ฉฐ ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์„ ์ €ํ•˜์‹œํ‚ต๋‹ˆ๋‹ค. ๋ช…ํ™•ํ•œ ์„ค๋ช…์ด ํ•„์š”ํ•˜๊ฑฐ๋‚˜ ๋ถˆํ•„์š”ํ•œ ์ฃผ์„์€ ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

-// ํ…Œ์ŠคํŠธ
@Slf4j
@RestController

1-21: ์ „์ฒด ์ปจํŠธ๋กค๋Ÿฌ ๊ตฌ์กฐ ๊ฐœ์„  ์ œ์•ˆ

์ปจํŠธ๋กค๋Ÿฌ ์ „์ฒด์— ๋Œ€ํ•œ ๋ช‡ ๊ฐ€์ง€ ๊ฐœ์„  ์‚ฌํ•ญ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค:

  1. ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๊ธ€๋กœ๋ฒŒ ์˜ˆ์™ธ ํ•ธ๋“ค๋Ÿฌ(Global Exception Handler) ๊ตฌํ˜„์„ ๊ณ ๋ คํ•˜์„ธ์š”.
  2. ๋ฆฌํŒฉํ† ๋ง๋œ ์„œ๋น„์Šค ๊ณ„์ธต๊ณผ ํ•จ๊ป˜ ์ž‘๋™ํ•˜๋„๋ก ์ปจํŠธ๋กค๋Ÿฌ ์ฝ”๋“œ๋ฅผ ์กฐ์ •ํ•˜์„ธ์š”.
  3. ๋ฐ˜ํ™˜ ํƒ€์ž…์„ ์ผ๊ด€์„ฑ ์žˆ๊ฒŒ ์œ ์ง€ํ•˜๊ณ , ๊ฐ€๋Šฅํ•œ ๊ตฌ์ฒด์ ์ธ ํƒ€์ž…์„ ์‚ฌ์šฉํ•˜์„ธ์š”(์˜ˆ: ResponseEntity<?>๋ณด๋‹ค๋Š” ResponseEntity<PostResponseDTO>).
  4. ํšจ๊ณผ์ ์ธ API ๋ฌธ์„œํ™”๋ฅผ ์œ„ํ•ด Swagger ์–ด๋…ธํ…Œ์ด์…˜์„ ๋” ์ž์„ธํ•˜๊ฒŒ ํ™œ์šฉํ•˜์„ธ์š”.

๋ชจ๋ฒ” ์‚ฌ๋ก€๋กœ ๊ณ ๋ คํ•ด ๋ณผ ์ˆ˜ ์žˆ๋Š” ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

  1. ๊ณ„์ธต ๋ถ„๋ฆฌ: ์ปจํŠธ๋กค๋Ÿฌ๋Š” HTTP ์š”์ฒญ/์‘๋‹ต ์ฒ˜๋ฆฌ๋งŒ ๋‹ด๋‹นํ•˜๊ณ , ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์€ ์„œ๋น„์Šค์—์„œ ์ฒ˜๋ฆฌ
  2. DTO ๋ณ€ํ™˜: ์—”ํ‹ฐํ‹ฐ์™€ DTO ๊ฐ„ ๋ณ€ํ™˜ ๋กœ์ง์„ ์„œ๋น„์Šค ๋˜๋Š” ๋งคํผ ํด๋ž˜์Šค๋กœ ๋ถ„๋ฆฌ
  3. ๊ธ€๋กœ๋ฒŒ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ: @ControllerAdvice ๋˜๋Š” @RestControllerAdvice๋ฅผ ์‚ฌ์šฉํ•œ ์ผ๊ด€๋œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ
  4. ํŽ˜์ด์ง€๋„ค์ด์…˜: ๋Œ€์šฉ๋Ÿ‰ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ํ‘œ์ค€ ํŽ˜์ด์ง€๋„ค์ด์…˜ ๊ตฌํ˜„
๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

๐Ÿ“ฅ Commits

Reviewing files that changed from the base of the PR and between 4d39b8c and 0c90910.

๐Ÿ“’ Files selected for processing (22)
  • build.gradle (1 hunks)
  • src/main/java/aibe/hosik/analysis/Analysis.java (1 hunks)
  • src/main/java/aibe/hosik/apply/controller/ApplyController.java (1 hunks)
  • src/main/java/aibe/hosik/apply/entity/Apply.java (1 hunks)
  • src/main/java/aibe/hosik/apply/repository/ApplyRepository.java (1 hunks)
  • src/main/java/aibe/hosik/apply/service/ApplyService.java (1 hunks)
  • src/main/java/aibe/hosik/post/PostController.java (0 hunks)
  • src/main/java/aibe/hosik/post/PostRepository.java (0 hunks)
  • src/main/java/aibe/hosik/post/PostService.java (0 hunks)
  • src/main/java/aibe/hosik/post/controller/PostController.java (1 hunks)
  • src/main/java/aibe/hosik/post/dto/MatchedUserDTO.java (1 hunks)
  • src/main/java/aibe/hosik/post/dto/PostDetailDTO.java (1 hunks)
  • src/main/java/aibe/hosik/post/dto/PostRequestDTO.java (1 hunks)
  • src/main/java/aibe/hosik/post/dto/PostResponseDTO.java (1 hunks)
  • src/main/java/aibe/hosik/post/entity/Post.java (3 hunks)
  • src/main/java/aibe/hosik/post/repository/PostRepository.java (1 hunks)
  • src/main/java/aibe/hosik/post/service/PostService.java (1 hunks)
  • src/main/java/aibe/hosik/post/service/PostServiceImpl.java (1 hunks)
  • src/main/java/aibe/hosik/skill/cotnroller/SkillController.java (1 hunks)
  • src/main/java/aibe/hosik/skill/repository/PostSkillRepository.java (1 hunks)
  • src/main/java/aibe/hosik/skill/repository/SkillRepository.java (1 hunks)
  • src/main/java/aibe/hosik/skill/service/SkillService.java (1 hunks)
๐Ÿ’ค Files with no reviewable changes (3)
  • src/main/java/aibe/hosik/post/PostRepository.java
  • src/main/java/aibe/hosik/post/PostService.java
  • src/main/java/aibe/hosik/post/PostController.java
๐Ÿ”‡ Additional comments (11)
src/main/java/aibe/hosik/apply/entity/Apply.java (1)

1-2: ํŒจํ‚ค์ง€ ๊ตฌ์กฐ ๋ณ€๊ฒฝ ํ™•์ธ
package aibe.hosik.apply.entity;๋กœ ์—”ํ‹ฐํ‹ฐ ํŒจํ‚ค์ง€๊ฐ€ ์„ธ๋ถ„ํ™”๋˜์–ด ๋ชจ๋“ˆํ™” ๊ตฌ์กฐ๊ฐ€ ์ผ๊ด€๋˜๊ฒŒ ์ •๋ฆฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/analysis/Analysis.java (1)

3-3: Import ๊ฒฝ๋กœ ์—…๋ฐ์ดํŠธ ํ™•์ธ
import aibe.hosik.apply.entity.Apply;๋กœ ๋ณ€๊ฒฝ๋˜์–ด Apply ์—”ํ‹ฐํ‹ฐ์˜ ์ƒˆ๋กœ์šด ํŒจํ‚ค์ง€ ์œ„์น˜๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ฐ˜์˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/apply/service/ApplyService.java (1)

1-3: ํŒจํ‚ค์ง€ ๋ฐ import ์—…๋ฐ์ดํŠธ
package aibe.hosik.apply.service;์™€ import aibe.hosik.apply.repository.ApplyRepository;๋กœ ๋ชจ๋“ˆํ™”๋œ ํŒจํ‚ค์ง€ ๊ตฌ์กฐ๊ฐ€ ์ผ๊ด€๋˜๊ฒŒ ์ •๋ฆฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/apply/controller/ApplyController.java (1)

1-3: ํŒจํ‚ค์ง€ ๋ฐ import ๊ฒฝ๋กœ ๋ณ€๊ฒฝ ํ™•์ธ
package aibe.hosik.apply.controller;์™€ import aibe.hosik.apply.service.ApplyService;๋กœ ๊ตฌ์กฐ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ฐ˜์˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/apply/repository/ApplyRepository.java (1)

1-3: ํŒจํ‚ค์ง€ ๋ฐ import ๋ณ€๊ฒฝ ํ™•์ธ
package aibe.hosik.apply.repository;์™€ import aibe.hosik.apply.entity.Apply;๋กœ ์ด๋™์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ฐ˜์˜๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/skill/cotnroller/SkillController.java (1)

3-3: ์„œ๋น„์Šค ๋ ˆ์ด์–ด ์ž„ํฌํŠธ ์ถ”๊ฐ€ ๊ตฌํ˜„ ์™„๋ฃŒ

SkillService๋ฅผ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ž„ํฌํŠธํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๊ณ„์ธต ๊ตฌ์กฐ๋ฅผ ์ ์ ˆํžˆ ๋ถ„๋ฆฌํ•˜์—ฌ ๊ตฌํ˜„ํ•˜์‹  ์ ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/skill/service/SkillService.java (2)

1-1: ์„œ๋น„์Šค ๊ณ„์ธต ํŒจํ‚ค์ง€ ๊ตฌ์กฐ ๊ฐœ์„ 

์„œ๋น„์Šค ํด๋ž˜์Šค๋ฅผ service ํŒจํ‚ค์ง€๋กœ ์ด๋™์‹œํ‚จ ๊ฒƒ์€ ์ข‹์€ ๊ตฌ์กฐ ๊ฐœ์„ ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ํ‘œ์ค€ Spring ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ ˆ์ด์–ด๋ง ๊ทœ์น™์„ ๋”ฐ๋ฅด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.


3-3: ๋ ˆํฌ์ง€ํ† ๋ฆฌ ์ž„ํฌํŠธ ๊ฒฝ๋กœ ์ˆ˜์ • ์™„๋ฃŒ

SkillRepository๋ฅผ ์˜ฌ๋ฐ”๋ฅธ ํŒจํ‚ค์ง€์—์„œ ์ž„ํฌํŠธํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ณ„์ธต ๊ตฌ์กฐ์— ๋งž๊ฒŒ ์ž˜ ์ •๋ฆฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

src/main/java/aibe/hosik/skill/repository/SkillRepository.java (3)

1-1: ๋ ˆํฌ์ง€ํ† ๋ฆฌ ๊ณ„์ธต ํŒจํ‚ค์ง€ ๊ตฌ์กฐ ๊ฐœ์„ 

๋ ˆํฌ์ง€ํ† ๋ฆฌ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ repository ํŒจํ‚ค์ง€๋กœ ์ด๋™์‹œํ‚จ ๊ฒƒ์€ ์ข‹์€ ๊ตฌ์กฐ ๊ฐœ์„ ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ํ‘œ์ค€ Spring ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ ˆ์ด์–ด๋ง ๊ทœ์น™์„ ๋”ฐ๋ฅด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.


6-7: Optional ์ž„ํฌํŠธ ์ถ”๊ฐ€

Optional์„ ์‚ฌ์šฉํ•˜์—ฌ ์กด์žฌํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋Š” ๊ฐ’์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์€ Java 8 ์ดํ›„์˜ ์ข‹์€ ๊ด€ํ–‰์ž…๋‹ˆ๋‹ค. ์ž˜ ํ•˜์…จ์Šต๋‹ˆ๋‹ค.


9-9: ์ด๋ฆ„์œผ๋กœ ์Šคํ‚ฌ์„ ์ฐพ๋Š” ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€

findByName ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•œ ๊ฒƒ์€ ์ข‹์€ ๊ตฌํ˜„์ž…๋‹ˆ๋‹ค. Spring Data JPA ๊ทœ์น™์— ๋”ฐ๋ผ ๋ฉ”์„œ๋“œ ์ด๋ฆ„์„ ํ†ตํ•ด ์ฟผ๋ฆฌ๊ฐ€ ์ž๋™ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. Optional์„ ๋ฐ˜ํ™˜ ํƒ€์ž…์œผ๋กœ ์‚ฌ์šฉํ•˜์—ฌ null ์ฒดํฌ ๋Œ€์‹  ํ•จ์ˆ˜ํ˜• ์ ‘๊ทผ ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•œ ์ ๋„ ์ข‹์Šต๋‹ˆ๋‹ค.

์ด ๋ฉ”์„œ๋“œ๋Š” ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ฑ ๊ณผ์ •์—์„œ ์Šคํ‚ฌ์„ ์ด๋ฆ„์œผ๋กœ ์กฐํšŒํ•˜๋Š” ๋ฐ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Comment thread build.gradle
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-security'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ’ก Verification agent

โ“ Verification inconclusive

Spring Security ์˜์กด์„ฑ์ด ํ™œ์„ฑํ™”๋˜์—ˆ์Šต๋‹ˆ๋‹ค

Spring Security ์˜์กด์„ฑ์„ ํ™œ์„ฑํ™”ํ•˜์…จ๋„ค์š”. ์ด๋Š” ์ธ์ฆ ๋ฐ ๊ถŒํ•œ ๋ถ€์—ฌ ๊ธฐ๋Šฅ์„ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋งŒ, Spring Security๋ฅผ ํ™œ์„ฑํ™”ํ•˜๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ ๋ชจ๋“  ์—”๋“œํฌ์ธํŠธ๊ฐ€ ์ธ์ฆ์„ ํ•„์š”๋กœ ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•œ ์ ์ ˆํ•œ ๋ณด์•ˆ ๊ตฌ์„ฑ์ด ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ด์ฃผ์„ธ์š”.

ํ”„๋กœ์ ํŠธ์— SecurityConfig ๋˜๋Š” WebSecurityConfigurerAdapter ๊ตฌํ˜„์ฒด๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•ด๋ณด์„ธ์š”:


๐Ÿ Script executed:

#!/bin/bash
# ๋ณด์•ˆ ์„ค์ • ํŒŒ์ผ ์กด์žฌ ํ™•์ธ
find src/main/java -type f -name "*Security*.java" -o -name "*WebSecurity*.java" | sort

Length of output: 89


๋ณด์•ˆ ์„ค์ • ํด๋ž˜์Šค ๋ฏธํ™•์ธ

Spring Security ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•˜์…จ์œผ๋‚˜, src/main/java ๊ฒฝ๋กœ์—์„œ *Security*.java ๋˜๋Š” *WebSecurity*.java ํŒŒ์ผ์ด ๊ฒ€์ƒ‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ด ์ƒํƒœ๋ผ๋ฉด ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ ๋ชจ๋“  ์—”๋“œํฌ์ธํŠธ๊ฐ€ ์ธ์ฆ์„ ํ•„์š”๋กœ ํ•˜๋ฉฐ, ๊ธฐ๋ณธ ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€์™€ ๊ธฐ๋ณธ ๊ณ„์ •์ด ์ƒ์„ฑ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์‚ฌํ•ญ์„ ๊ฒ€ํ†  ๋ฐ ์กฐ์น˜ํ•ด์ฃผ์„ธ์š”:

  • ์‚ฌ์šฉ์ž ์ •์˜ ๋ณด์•ˆ ์„ค์ • ํด๋ž˜์Šค(SecurityConfig)๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์ธ์ฆ/์ธ๊ฐ€ ์ •์ฑ…์„ ๋ช…์‹œ์ ์œผ๋กœ ๊ตฌ์„ฑ
  • @Configuration๊ณผ @EnableWebSecurity ์• ๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ•ด WebSecurityConfigurerAdapter ๋˜๋Š” SecurityFilterChain ๊ตฌํ˜„์ฒด ์ƒ์„ฑ
  • ์—”๋“œํฌ์ธํŠธ๋ณ„ ์ ‘๊ทผ ์ œ์–ด(antMatchers ๋“ฑ), CSRFยทCORS ์„ค์ • ์—ฌ๋ถ€ ํ™•์ธ

์˜ˆ์‹œ:

@Configuration
@EnableWebSecurity
public class SecurityConfig {
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http
            .authorizeRequests(auth -> auth
                .antMatchers("/public/**").permitAll()
                .anyRequest().authenticated()
            )
            .formLogin(withDefaults());
        return http.build();
    }
}

์œ„์™€ ๊ฐ™์ด ๋ณด์•ˆ ์„ค์ •์„ ์ถ”๊ฐ€ํ•˜์—ฌ ํ”„๋กœ์ ํŠธ์— ํ•„์š”ํ•œ ์ธ์ฆยท์ธ๊ฐ€ ๋กœ์ง์„ ๊ตฌํ˜„ํ•ด์ฃผ์„ธ์š”.

Comment on lines +24 to +36
public Post toEntity(User user) {
return Post.builder()
.title(title())
.content(content())
.headCount(headCount())
.image(image())
.requirementPersonality(requirementPersonality())
.endedAt(endedAt())
.category(category())
.type(type())
.user(user)
.build();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

toEntity ๋ฉ”์„œ๋“œ์— Null ์ฒดํฌ ์ถ”๊ฐ€ ํ•„์š”

toEntity ๋ฉ”์„œ๋“œ์—์„œ null ๊ฐ’์„ ๊ฐ€์ง„ ํ•„๋“œ๋“ค์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์œ ํšจ์„ฑ ๊ฒ€์ฆ์„ ์ถ”๊ฐ€ํ•˜๋”๋ผ๋„ ๋Ÿฐํƒ€์ž„์—์„œ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ NullPointerException์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋นŒ๋” ํŒจํ„ด์—์„œ null ์ฒดํฌ ๋กœ์ง์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค:

 public Post toEntity(User user) {
+    if (user == null) {
+        throw new IllegalArgumentException("์‚ฌ์šฉ์ž ์ •๋ณด๋Š” ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค");
+    }
     return Post.builder()
             .title(title())
             .content(content())
             .headCount(headCount())
             .image(image())
             .requirementPersonality(requirementPersonality())
             .endedAt(endedAt())
             .category(category())
             .type(type())
             .user(user)
             .build();
 }
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public Post toEntity(User user) {
return Post.builder()
.title(title())
.content(content())
.headCount(headCount())
.image(image())
.requirementPersonality(requirementPersonality())
.endedAt(endedAt())
.category(category())
.type(type())
.user(user)
.build();
}
public Post toEntity(User user) {
if (user == null) {
throw new IllegalArgumentException("์‚ฌ์šฉ์ž ์ •๋ณด๋Š” ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค");
}
return Post.builder()
.title(title())
.content(content())
.headCount(headCount())
.image(image())
.requirementPersonality(requirementPersonality())
.endedAt(endedAt())
.category(category())
.type(type())
.user(user)
.build();
}

Comment on lines +18 to +28
public static PostResponseDTO from(Post post,List<String> skills, Integer currentCount) {
return new PostResponseDTO(post.getId(),
post.getImage(),
post.getTitle(),
post.getContent(),
post.getCategory().toString(),
skills,
post.getHeadCount(),
currentCount
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

๋ฌธ๋ฒ• ๋ฐ Enum ์ฒ˜๋ฆฌ ๊ฐœ์„  ํ•„์š”

  1. ๋ฉ”์„œ๋“œ ์ธ์ž ์‚ฌ์ด์— ๊ณต๋ฐฑ์ด ๋ˆ„๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค (Post post,List<String> โ†’ Post post, List<String>).
  2. Enum ๊ฐ’์„ ์ฒ˜๋ฆฌํ•  ๋•Œ toString() ๋Œ€์‹  name()์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค:

-    public static PostResponseDTO from(Post post,List<String> skills, Integer currentCount) {
+    public static PostResponseDTO from(Post post, List<String> skills, Integer currentCount) {
         return new PostResponseDTO(post.getId(),
                 post.getImage(),
                 post.getTitle(),
                 post.getContent(),
-                post.getCategory().toString(),
+                post.getCategory().name(),
                 skills,
                 post.getHeadCount(),
                 currentCount
         );
     }
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static PostResponseDTO from(Post post,List<String> skills, Integer currentCount) {
return new PostResponseDTO(post.getId(),
post.getImage(),
post.getTitle(),
post.getContent(),
post.getCategory().toString(),
skills,
post.getHeadCount(),
currentCount
);
}
public static PostResponseDTO from(Post post, List<String> skills, Integer currentCount) {
return new PostResponseDTO(post.getId(),
post.getImage(),
post.getTitle(),
post.getContent(),
post.getCategory().name(),
skills,
post.getHeadCount(),
currentCount
);
}

Comment on lines +19 to +22
// PostDetail ์กฐํšŒ ์‹œ ์ฆ‰์‹œ ๋กœ๋”ฉ ์ง€์ •
//@EntityGraph(attributePaths = {"postSkills", "postSkills.skill"})
@Query("SELECT DISTINCT p FROM Post p LEFT JOIN FETCH p.postSkills ps LEFT JOIN FETCH ps.skill WHERE p.id = :id")
Optional<Post> findByIdWithSkills(@Param("id") Long id);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ ๋ฐ ์ฃผ์„ ๊ฐœ์„  ํ•„์š”

๊ฒŒ์‹œ๊ธ€ ์กฐํšŒ ์‹œ ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ๊ฐ€ ๊ตฌํ˜„๋˜์–ด ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๊ฐ€ ๋งŽ์•„์งˆ ๊ฒฝ์šฐ ์„ฑ๋Šฅ ์ด์Šˆ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ ๋ฉ”์„œ๋“œ ์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ฉ”์„œ๋“œ์˜ ๋ชฉ์ ๊ณผ ์‚ฌ์šฉ๋ฒ•์„ ๋ช…ํ™•ํžˆ ์„ค๋ช…ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

-    // PostDetail ์กฐํšŒ ์‹œ ์ฆ‰์‹œ ๋กœ๋”ฉ ์ง€์ •
+    /**
+     * ํŠน์ • ID์˜ ๊ฒŒ์‹œ๊ธ€์„ ์—ฐ๊ด€๋œ ์Šคํ‚ฌ๊ณผ ํ•จ๊ป˜ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
+     * JPQL์˜ LEFT JOIN FETCH๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ N+1 ๋ฌธ์ œ๋ฅผ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค.
+     * @param id ์กฐํšŒํ•  ๊ฒŒ์‹œ๊ธ€ ID
+     * @return ์Šคํ‚ฌ ์ •๋ณด๊ฐ€ ํฌํ•จ๋œ ๊ฒŒ์‹œ๊ธ€ (Optional)
+     */
     //@EntityGraph(attributePaths = {"postSkills", "postSkills.skill"})
     @Query("SELECT DISTINCT p FROM Post p LEFT JOIN FETCH p.postSkills ps LEFT JOIN FETCH ps.skill WHERE p.id = :id")
     Optional<Post> findByIdWithSkills(@Param("id") Long id);
+
+    /**
+     * ๋ชจ๋“  ๊ฒŒ์‹œ๊ธ€์„ ํŽ˜์ด์ง•ํ•˜์—ฌ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
+     * @param pageable ํŽ˜์ด์ง• ์ •๋ณด
+     * @return ํŽ˜์ด์ง•๋œ ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก
+     */
+    @Query(value = "SELECT DISTINCT p FROM Post p",
+           countQuery = "SELECT COUNT(p) FROM Post p")
+    Page<Post> findAllWithPaging(Pageable pageable);
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// PostDetail ์กฐํšŒ ์‹œ ์ฆ‰์‹œ ๋กœ๋”ฉ ์ง€์ •
//@EntityGraph(attributePaths = {"postSkills", "postSkills.skill"})
@Query("SELECT DISTINCT p FROM Post p LEFT JOIN FETCH p.postSkills ps LEFT JOIN FETCH ps.skill WHERE p.id = :id")
Optional<Post> findByIdWithSkills(@Param("id") Long id);
/**
* ํŠน์ • ID์˜ ๊ฒŒ์‹œ๊ธ€์„ ์—ฐ๊ด€๋œ ์Šคํ‚ฌ๊ณผ ํ•จ๊ป˜ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
* JPQL์˜ LEFT JOIN FETCH๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ N+1 ๋ฌธ์ œ๋ฅผ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค.
* @param id ์กฐํšŒํ•  ๊ฒŒ์‹œ๊ธ€ ID
* @return ์Šคํ‚ฌ ์ •๋ณด๊ฐ€ ํฌํ•จ๋œ ๊ฒŒ์‹œ๊ธ€ (Optional)
*/
//@EntityGraph(attributePaths = {"postSkills", "postSkills.skill"})
@Query("SELECT DISTINCT p FROM Post p LEFT JOIN FETCH p.postSkills ps LEFT JOIN FETCH ps.skill WHERE p.id = :id")
Optional<Post> findByIdWithSkills(@Param("id") Long id);
/**
* ๋ชจ๋“  ๊ฒŒ์‹œ๊ธ€์„ ํŽ˜์ด์ง•ํ•˜์—ฌ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
* @param pageable ํŽ˜์ด์ง• ์ •๋ณด
* @return ํŽ˜์ด์ง•๋œ ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก
*/
@Query(value = "SELECT DISTINCT p FROM Post p",
countQuery = "SELECT COUNT(p) FROM Post p")
Page<Post> findAllWithPaging(Pageable pageable);

Comment on lines +1 to +27
package aibe.hosik.post.service;

import aibe.hosik.post.dto.MatchedUserDTO;
import aibe.hosik.post.dto.PostDetailDTO;
import aibe.hosik.post.dto.PostRequestDTO;
import aibe.hosik.post.dto.PostResponseDTO;
import aibe.hosik.post.entity.Post;
import aibe.hosik.post.repository.PostRepository;
import aibe.hosik.skill.repository.PostSkillRepository;
import aibe.hosik.skill.repository.SkillRepository;
import aibe.hosik.skill.entity.PostSkill;
import aibe.hosik.skill.entity.Skill;
import aibe.hosik.user.User;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class PostServiceImpl implements PostService {
private final PostRepository postRepository;
private final SkillRepository skillRepository;
private final PostSkillRepository postSkillRepository;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

์ „์ฒด ํด๋ž˜์Šค ๊ตฌ์กฐ์— ๋Œ€ํ•œ ์ œ์•ˆ

์„œ๋น„์Šค ํด๋ž˜์Šค ์ „์ฒด์— ๋Œ€ํ•œ ๋ช‡ ๊ฐ€์ง€ ๊ฐœ์„  ์‚ฌํ•ญ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค:

  1. ๊ฐ ๋ฉ”์„œ๋“œ์— ๋ช…ํ™•ํ•œ JavaDoc ์ฃผ์„์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ฉ”์„œ๋“œ์˜ ๋ชฉ์ , ๋งค๊ฐœ๋ณ€์ˆ˜, ๋ฐ˜ํ™˜๊ฐ’, ์˜ˆ์™ธ ๋“ฑ์„ ๋ฌธ์„œํ™”ํ•˜์„ธ์š”.
  2. ํด๋ž˜์Šค ์ˆ˜์ค€์—์„œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ์ „๋žต์„ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค (์˜ˆ: ์‚ฌ์šฉ์ž ์ •์˜ ์˜ˆ์™ธ ํด๋ž˜์Šค ์‚ฌ์šฉ).
  3. ๋””๋ฒ„๊ทธ ๋ฐ ์„ฑ๋Šฅ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ์œ„ํ•œ ๋กœ๊น…์„ ์ถ”๊ฐ€ํ•˜์„ธ์š”.
 package aibe.hosik.post.service;

 import aibe.hosik.post.dto.MatchedUserDTO;
 import aibe.hosik.post.dto.PostDetailDTO;
 import aibe.hosik.post.dto.PostRequestDTO;
 import aibe.hosik.post.dto.PostResponseDTO;
 import aibe.hosik.post.entity.Post;
 import aibe.hosik.post.repository.PostRepository;
 import aibe.hosik.skill.repository.PostSkillRepository;
 import aibe.hosik.skill.repository.SkillRepository;
 import aibe.hosik.skill.entity.PostSkill;
 import aibe.hosik.skill.entity.Skill;
 import aibe.hosik.user.User;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import java.util.NoSuchElementException;

 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;

+/**
+ * ๊ฒŒ์‹œ๊ธ€(Post) ๊ด€๋ จ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์„œ๋น„์Šค ๊ตฌํ˜„ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.
+ * ๊ฒŒ์‹œ๊ธ€ ์กฐํšŒ, ์ƒ์„ฑ, ์ƒ์„ธ ์กฐํšŒ ๋“ฑ์˜ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
+ */
 @Service
 @RequiredArgsConstructor
+@Slf4j
 public class PostServiceImpl implements PostService {
   private final PostRepository postRepository;
   private final SkillRepository skillRepository;
   private final PostSkillRepository postSkillRepository;
๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
package aibe.hosik.post.service;
import aibe.hosik.post.dto.MatchedUserDTO;
import aibe.hosik.post.dto.PostDetailDTO;
import aibe.hosik.post.dto.PostRequestDTO;
import aibe.hosik.post.dto.PostResponseDTO;
import aibe.hosik.post.entity.Post;
import aibe.hosik.post.repository.PostRepository;
import aibe.hosik.skill.repository.PostSkillRepository;
import aibe.hosik.skill.repository.SkillRepository;
import aibe.hosik.skill.entity.PostSkill;
import aibe.hosik.skill.entity.Skill;
import aibe.hosik.user.User;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class PostServiceImpl implements PostService {
private final PostRepository postRepository;
private final SkillRepository skillRepository;
private final PostSkillRepository postSkillRepository;
package aibe.hosik.post.service;
import aibe.hosik.post.dto.MatchedUserDTO;
import aibe.hosik.post.dto.PostDetailDTO;
import aibe.hosik.post.dto.PostRequestDTO;
import aibe.hosik.post.dto.PostResponseDTO;
import aibe.hosik.post.entity.Post;
import aibe.hosik.post.repository.PostRepository;
import aibe.hosik.skill.repository.PostSkillRepository;
import aibe.hosik.skill.repository.SkillRepository;
import aibe.hosik.skill.entity.PostSkill;
import aibe.hosik.skill.entity.Skill;
import aibe.hosik.user.User;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import lombok.extern.slf4j.Slf4j;
+import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
+/**
+ * ๊ฒŒ์‹œ๊ธ€(Post) ๊ด€๋ จ ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์„œ๋น„์Šค ๊ตฌํ˜„ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค.
+ * ๊ฒŒ์‹œ๊ธ€ ์กฐํšŒ, ์ƒ์„ฑ, ์ƒ์„ธ ์กฐํšŒ ๋“ฑ์˜ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
+ */
@Service
@RequiredArgsConstructor
+@Slf4j
public class PostServiceImpl implements PostService {
private final PostRepository postRepository;
private final SkillRepository skillRepository;
private final PostSkillRepository postSkillRepository;
// ... rest of the implementation
}

s0ooo0k added a commit that referenced this pull request Dec 9, 2025
Entity ์ž‘์„ฑ ๋ฐ ํด๋” ๊ตฌ์กฐ ์ƒ์„ฑ
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.

1 participant