-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/votes #3
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
base: dev
Are you sure you want to change the base?
Conversation
leesanghuu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๊ณ์ธต ๋ถ๋ฆฌ๋ ์ํด๋จ๊ณ Swagger๋ ๊ฐ์ข Config๋ ์ ์ ๋ฆฌํด๋ฌ์ ์ข์๋ค ์คํํธ๋ฅผ ์ ๋์ด์ค๋ฏ๐
| public VoteDtos.VoteSummary create(VoteDtos.CreateVoteReq req) { | ||
| //1. Vote c | ||
| String code = genCode(8); | ||
| Vote v = new Vote(req.name(), code); | ||
|
|
||
| // 2. ๋ ์ง ๋ฒ์ ์ค์ (์์ผ๋ฉด) | ||
| if (req.startDate() != null && req.endDate() != null) { | ||
| if (req.endDate().isBefore(req.startDate())) { | ||
| throw new IllegalArgumentException("endDate must be >= startDate"); | ||
| } | ||
| v.setDateRange(req.startDate(), req.endDate()); | ||
|
|
||
| // 3. ์ฐธ์ฌ์ ์ถ๊ฐ (์์ผ๋ฉด) | ||
| if (req.participantNames() != null && !req.participantNames().isEmpty()) { | ||
| for (String name : req.participantNames()) { | ||
| if (name != null && !name.isBlank()) { | ||
| Participant p = new Participant(v, name.trim()); | ||
| v.getParticipants().add(p); | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name๋ง DTO์์ @NotBlank๋ก validation ํ๋ ๊ฒ ๊ฐ์๋ฐ, ๊ทธ๋ฌ๋ฉด ํฌํ ์ด๋ฆ๋ง ์
๋ ฅ๋ฐ์ผ๋ฉด ๋๋จธ์ง๋ Null๊ฐ์ผ๋ก ๋ค์ด๊ฐ๊ฒ ๋์ด๋ Vote ๊ฐ์ฒด๋ ๋ง๋ค์ด์ง๊ฒ ๋จ.
(ํ๋ก ํธ์์ ์
๋ ฅ ๋ฐ์ ๋ ๊ฑธ๋ฌ์ฃผ๊ฒ ์ง๋ง) ์๋ฒ์์๋ ์ฐธ์ฌ์, ํฌํ ์ด๋ฆ, ๋ ์ง ๋ฒ์๊น์ง ๋ช
์์ ์ผ๋ก ํ์๋ก ๋ง๋๋๊ฒ ๋์๋ฏ? 1) DTO์์ validation์ผ๋ก ๋ฐฉ์ดํ๊ธฐ(name์ฒ๋ผ + if ๋นผ๋ฒ๋ฆฌ๊ธฐ) 2) Service ๊ณ์ธต์์ ์ด๋ฆ, ๋ ์ง, ์ฐธ์ฌ์(์ค๋ณต if ๋ง๊ณ ๊ฐ๊ฐ!) if ๋ฌธ์ผ๋ก ํ์ธํ๊ธฐ
์ด์ ๋ ์๊ฐํด๋ดค๋๋ฐ ๋ค๋ฅธ ์๋์์ผ๋ฉด ์๋ ค์ฃผ์์ค~
|
|
||
| public ParticipantDtos.ParticipantRes add(Long voteId, String displayName) { | ||
| Vote v = voteRepo.findById(voteId).orElseThrow(() -> new NoSuchElementException("vote not found")); | ||
| String loginCode = genCode(10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loginCode๋ฅผ ์์ฑํด๋๊ณ ์์ฐ์ด๋ ๊ฒ ๊ฐ์์ ์ด๋์ ํ์ํ๊ฑฐ์ง?
๐Pull requests
๐ชพ ๋ธ๋์น
๐ ์์ ํ ๋ด์ฉ
/votes (admin): crud ๊ฐ๋ฅ(์ด๋ฆ, ์ผ์ , ์ฐธ๊ฐ์)
config: openapi(swagger), security
๐ฌ ๋ฆฌ๋ทฐ ํฌ์ธํธ (์ ํ)
๐ ๊ด๋ จ ์ด์