Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restep04 #19

Open
wants to merge 2 commits into
base: nokchax
Choose a base branch
from
Open

Restep04 #19

wants to merge 2 commits into from

Conversation

nokchax
Copy link

@nokchax nokchax commented Mar 24, 2020

WEB UI 적용완료

Copy link
Member

@junwoochoi junwoochoi left a 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");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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);
Copy link
Member

Choose a reason for hiding this comment

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

키값을 상수로 관리하면 어떨까요? 👀

Copy link

@wonoh wonoh left a 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);
Copy link

Choose a reason for hiding this comment

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

세션으로 값을 유지시킬수 있었군요! 배우고 갑니다

Copy link

@pasudo123 pasudo123 left a comment

Choose a reason for hiding this comment

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

코드 잘 보았습니다. 핸들바 커스텀헬퍼 등록이 어려워서 많이 헤맸는데 ㅠㅠ 방법을 찾아봐야겠네요..

Comment on lines +18 to +49
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);
}
}

Choose a reason for hiding this comment

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

핸들바 커스텀헬퍼 등록하다가 시간을 엄청 많이 들이다 포기했는데... ㅠ 자바코드로 등록이 가능하군요. 템플릿 엔진이 익숙치 않아서 어렵게 느껴지네요 ㅠ

Comment on lines +90 to +91
<th>{{plus @index}}</th>
<td>{{numbers}}</td>

Choose a reason for hiding this comment

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

👍 👍

Copy link
Member

@cglee079 cglee079 left a 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>
Copy link
Member

Choose a reason for hiding this comment

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

오, 이렇게 처리할수도있군요..! 인상깊습니당!! 배우고갑니당!

Comment on lines +64 to +65
model.put("revenue", ConsoleOutput.getRevenue(matchResult));
model.put("resultString", ConsoleOutput.getLottoPrizesResultString(matchResult));
Copy link
Member

Choose a reason for hiding this comment

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

ConsoleOutput을 웹/콘솔로 따로 클래스를 구분해도 좋을것 같아요!

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.

5 participants