-
Notifications
You must be signed in to change notification settings - Fork 5
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
Restep04 #19
base: nokchax
Are you sure you want to change the base?
Restep04 #19
Conversation
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.
코드 잘봤습니다!
특별히 코멘트달만한 사항은 없네요 ㅎㅎ....
기존 코드에서 큰 변경없이 구현하신 것이 좋네요!
get("/", (req, res) -> { | ||
Map<String, Object> model = new HashMap<>(); | ||
|
||
return render(model, "/index.html"); |
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.
return render(model, "/index.html"); | |
return render(Collections.emptyMap(), "/index.html"); |
빈Map을 이렇게 보내보면 어떨까요?
|
||
Lotto lotto = Lotto.buy(new TicketPayment(inputMoney, new LottoTickets(lottoTickets))); | ||
|
||
req.session().attribute("lotto", lotto); |
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.
키값을 상수로 관리하면 어떨까요? 👀
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.
깔끔한 코드 잘봤습니다!
딱히 코멘트할게 없네요 수고하셨습니다!
|
||
Lotto lotto = Lotto.buy(new TicketPayment(inputMoney, new LottoTickets(lottoTickets))); | ||
|
||
req.session().attribute("lotto", lotto); |
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.
세션으로 값을 유지시킬수 있었군요! 배우고 갑니다
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.
코드 잘 보았습니다. 핸들바 커스텀헬퍼 등록이 어려워서 많이 헤맸는데 ㅠㅠ 방법을 찾아봐야겠네요..
public class CustomHandlebarsTemplateEngine extends TemplateEngine { | ||
protected Handlebars handlebars; | ||
|
||
public CustomHandlebarsTemplateEngine() { | ||
this("/templates"); | ||
} | ||
|
||
public CustomHandlebarsTemplateEngine(String resourceRoot) { | ||
TemplateLoader templateLoader = new ClassPathTemplateLoader(); | ||
templateLoader.setPrefix(resourceRoot); | ||
templateLoader.setSuffix(null); | ||
|
||
handlebars = new Handlebars(templateLoader); | ||
handlebars.registerHelper("plus", new PlusHelper()); | ||
|
||
// Set Guava cache. | ||
Cache<TemplateSource, Template> cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES) | ||
.maximumSize(1000).build(); | ||
|
||
handlebars = handlebars.with(new GuavaTemplateCache(cache)); | ||
} | ||
|
||
@Override | ||
public String render(ModelAndView modelAndView) { | ||
String viewName = modelAndView.getViewName(); | ||
try { | ||
Template template = handlebars.compile(viewName); | ||
return template.apply(modelAndView.getModel()); | ||
} catch (IOException e) { | ||
throw new RuntimeIOException(e); | ||
} | ||
} |
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.
핸들바 커스텀헬퍼 등록하다가 시간을 엄청 많이 들이다 포기했는데... ㅠ 자바코드로 등록이 가능하군요. 템플릿 엔진이 익숙치 않아서 어렵게 느껴지네요 ㅠ
<th>{{plus @index}}</th> | ||
<td>{{numbers}}</td> |
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.
👍 👍
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.
수고하셨습니다
코멘트 할것이 별로없는것같아요 ㅎㅎ..!
깔끔한코드 잘보고 갑니당!
</tr> | ||
{{#each tickets}} | ||
<tr> | ||
<th>{{plus @index}}</th> |
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.
오, 이렇게 처리할수도있군요..! 인상깊습니당!! 배우고갑니당!
model.put("revenue", ConsoleOutput.getRevenue(matchResult)); | ||
model.put("resultString", ConsoleOutput.getLottoPrizesResultString(matchResult)); |
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.
ConsoleOutput
을 웹/콘솔로 따로 클래스를 구분해도 좋을것 같아요!
WEB UI 적용완료