Skip to content

Conversation

@eastlight82
Copy link
Collaborator

@eastlight82 eastlight82 commented Nov 12, 2025

๐Ÿš€Pull requests

๐Ÿชพ ๋ธŒ๋žœ์น˜

๐Ÿ“„ ์ž‘์—…ํ•œ ๋‚ด์šฉ
/votes (admin): crud ๊ฐ€๋Šฅ(์ด๋ฆ„, ์ผ์ •, ์ฐธ๊ฐ€์ž)
config: openapi(swagger), security

โš ๏ธ ์ฐธ๊ณ  ์‚ฌํ•ญ

๐Ÿ’ฌ ๋ฆฌ๋ทฐ ํฌ์ธํŠธ (์„ ํƒ)

๐Ÿ”— ๊ด€๋ จ ์ด์Šˆ

  • Closes: #์ด์Šˆ๋ฒˆํ˜ธ

Copy link
Collaborator

@leesanghuu leesanghuu left a comment

Choose a reason for hiding this comment

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

๊ณ„์ธต ๋ถ„๋ฆฌ๋„ ์ž˜ํ•ด๋†จ๊ณ  Swagger๋‚˜ ๊ฐ์ข… Config๋„ ์ž˜ ์ •๋ฆฌํ•ด๋‘ฌ์„œ ์ข‹์•˜๋‹ค ์Šคํƒ€ํŠธ๋ฅผ ์ž˜ ๋Š์–ด์ค€๋“ฏ๐Ÿ‘

Comment on lines +30 to +51
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);
}
}
}
}
Copy link
Collaborator

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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

loginCode๋ฅผ ์ƒ์„ฑํ•ด๋†“๊ณ  ์•ˆ์“ฐ์ด๋Š” ๊ฒƒ ๊ฐ™์•„์„œ ์–ด๋””์„œ ํ•„์š”ํ•œ๊ฑฐ์ง€?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants