code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -6,6 +6,8 @@ public class OutputView {
private static final String RESULT_STATISTICS_MESSAGE = "๋น์ฒจ ํต๊ณ";
private static final String BOUNDARY_LINE = "---------";
private static final String TOTAL_EARNING_RATIO_MESSAGE = "์ด ์์ต๋ฅ ์ %s ์
๋๋ค.";
+ private static final int SECOND_RANK_COUNT = 5;
+ private... | Java | ์ ์ฝ์ฌํญ ์๊ตฌ์ฌํญ์ ๋ฐ์ํ ๋ `rank.getMatch() == 5 && rank.getBonusMatchCount() == 1` ์ ๊ฐ์ ์ฝ๋๋ฅผ ๋ฉ์๋๋ก ๋ฐ๋ก ๋ถ๋ฆฌํด์ `validateMatchCount(rank)`์ ๊ฐ์ด ์์ฑํ๋ค๋ฉด ์ฝ๋๋ฅผ ์ฝ๋ ๋ค๋ฅธ ๊ฐ๋ฐ์๊ฐ ์ ์ฝ์ฌํญ์ ํ์
ํ๋๋ฐ ๋ ์ฌ์ธ ๊ฒ ๊ฐ์ต๋๋ค. ๋ฉ์๋๋ช
๋ง ๋ณด๊ณ "์ด ์ง์ ์์ validate ์ฒดํฌ๋ฅผ ํ๋ ๊ตฌ๋"๋ผ๊ณ ํ๋์ ํ์
์ด ๋๊ณ , ๊ตฌ์ฒด์ ์ธ ์ ์ฝ์ฌํญ์ด ๊ถ๊ธํ ๋ ํด๋น ๋ฉ์๋ ๋ด๋ถ ๊ตฌํ๋ง ์ฐพ์๋ณด๋ฉด ๋๊ฒ ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ถ๊ฐ๋ก ์ซ์๋ค๋ ์์ ์ฒ๋ฆฌํด์ฃผ๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -1,10 +1,33 @@
+import exception.*;
+import java.util.List;
+
public class Application {
public static void main(String[] args) {
LottoGame game = new LottoGame();
- OutputView.printLottoCount(game.inputMoney(new Money(InputView.inputMoney()).getMoney()));
- OutputView.printLottoTicket(g... | Java | ํฐ ์์๋ ์๋๊ฒ ์ง๋ง ๊ด๋ จ์ฑ์ ๋ฐ๋ผ์ ๊ฐํ์ ์ถ๊ฐํด ๊ตฌ๋ถ ์ง์ด์ฃผ๋ ๊ฒ๋ ๊ฐ๋
์ฑ์ ๋์ด๋ ์์๋ผ๊ณ ์๊ฐํฉ๋๋ค! |
@@ -1,9 +1,14 @@
+import java.util.List;
import java.util.Scanner;
public class InputView {
private static final String INPUT_MONEY_MESSAGE = "๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.";
private static final String INPUT_WINNING_LOTTO_MESSAGE = "์ง๋ ์ฃผ ๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.";
+ private static final String MANUAL_LOTTO_COUNT_MESSAGE = ... | Java | InputView์์ ์๋ ๋ก๋์ ๋ํด ๋ฒํธ๋ฅผ ์
๋ ฅ ๋ฐ๋ ์ญํ ์ ๋ํด ์ง์ ๋ก๋๋ฅผ ์์ฑํ๋ ์ญํ ๊น์ง ํ๊ณ ์๋ค์. ์ญํ ์ ๋ถ๋ฆฌํด๋ณผ ์ ์์๊น์? ๋ถ๋ฆฌํ์ ๋ ์ด๋ค ์ด์ ์ด ์๊ธธ๊น์? |
@@ -4,44 +4,36 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
public class LottoGameTest {
@Test
- @... | Java | `inputMoney()`๋ผ๋ ์ด๋ฆ์ ๋ฉ์๋์ ๊ฒฐ๊ณผ๊ฐ์ผ๋ก ๋ก๋ ๊ฐฏ์๊ฐ ๋์ค๋๊ฒ ์กฐ๊ธ ์ด์ํ ๊ฒ ๊ฐ์ต๋๋ค. ์
๋ ฅ๋ฐ๋ ๋ฉ์๋์ ๊ฐฏ์๋ฅผ ๋ฐํํ๋ ๋ฉ์๋๋ก ๋ถ๋ฆฌํด๋ณด๋ฉด ์ด๋จ๊น์? |
@@ -4,44 +4,36 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
public class LottoGameTest {
@Test
- @... | Java | ๊ฒฐ๊ณผ๊ฐ๊ณผ ๋น๊ตํ๋ ๊ฐ์ lottoCount๊ฐ ์๋ ์ง์ ์ ์ธ ์ซ์๋ก ๋น๊ตํ๋ฉด ์ด๋จ๊น์? ๋ง์ฝ ์ค์๋ก lottoGame.inputMoney()์์ ์
๋ ฅ๋ฐ์ ๋์ ๋ฐ์ฌ๋ฆผํด์ ์ฅ์๋ฅผ ์ถ๋ ฅํ๋๋ก ํด๋ฒ๋ ธ๋ค๋ฉด ํฐ์ผ์ ์ฌ์ด์ฆ๊ฐ 4๋๋ผ๋ ํ
์คํธ๊ฐ ํต๊ณผํ๊ฒ ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ฌ์ค ์ง๊ธ ํ
์คํธ ์ฝ๋๋ `lottoGame.inputMoney()`๊ฐ ๋จผ์ ๋ณด์ฅ๋์ด์ผํ๋๋ง ์ ํํ ํ
์คํธ๊ฐ ๊ฐ๋ฅํ ์ฝ๋๋ผ๊ณ ๋ณผ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค. ํ
์คํธ๋ฅผ ํ๋ค๋ณด๋ฉด ์ด์ฉ ์ ์๋ ๋ถ๋ถ์ผ ์๋ ์๊ณ , ์ ๋ง์ด ์ ๋ต์ ์๋์ง๋ง ๊ฒฐ๊ณผ๊ฐ์ ๊ฐ๊ธ์ ๋ ์ ํํ ๊ฒ์ ์์กดํด์ผํ์ง ์์๊น ์๊ฐ์ด ๋ค์ด ๋ฆฌ๋ทฐ ๋จ๊ฒจ๋ดค์ต๋๋ค. |
@@ -1,9 +1,14 @@
+import java.util.List;
import java.util.Scanner;
public class InputView {
private static final String INPUT_MONEY_MESSAGE = "๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.";
private static final String INPUT_WINNING_LOTTO_MESSAGE = "์ง๋ ์ฃผ ๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.";
+ private static final String MANUAL_LOTTO_COUNT_MESSAGE = ... | Java | ์๋์ด ์๋ ์๋์ผ๋ก ์
๋ ฅํ ๊ฐฏ์๋งํผ ์
๋ ฅ์ ๋ฐ๋๋ก ์๊ตฌ์ฌํญ์ด ๊ธฐ์ฌ๋์ด ์๊ธฐ ๋๋ฌธ์, ๋ง์ฝ `์๋์ผ๋ก ๊ตฌ๋งคํ ๋ก๋ ์๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.` ์์ 2๊ฐ๋ฅผ ์
๋ ฅํ๋ค๋ฉด, 2์ค์ ์
๋ ฅ ๊ฐ์ ๋ฃ์ด์ฃผ์ด์ผ ํฉ๋๋ค! |
@@ -1,9 +1,14 @@
+import java.util.List;
import java.util.Scanner;
public class InputView {
private static final String INPUT_MONEY_MESSAGE = "๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.";
private static final String INPUT_WINNING_LOTTO_MESSAGE = "์ง๋ ์ฃผ ๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.";
+ private static final String MANUAL_LOTTO_COUNT_MESSAGE = ... | Java | <img width="370" alt="แแ
ณแแ
ณแ
แ
ตแซแแ
ฃแบ 2022-07-04 แแ
ฉแแ
ฎ 7 14 35" src="https://user-images.githubusercontent.com/62830487/177134400-0365bef0-a31c-4a57-9020-e294daa65100.png">
๋ก์ง์ ๋ฌธ์ ๊ฐ ์์ด๋ณด์ด๋ค์. ์๋ ๋ก๋ 2์ฅ์ ๊ตฌ๋งคํด์ ๋ก๋ 2์ฅ์ ๋ฒํธ๋ฅผ ์
๋ ฅํ๋๋ฐ ์
๋ ฅ์ ํ ๋ฒ ๋ ๊ธฐ๋ค๋ฆฌ๊ณ ์๋ค์. ํ์ธ ๋ถํ๋๋ ค์. |
@@ -9,19 +9,24 @@ public LottoGame() {
statistics = new TreeMap<>();
}
- public int inputMoney(int money) {
+ public int calculateLottoCount(int money) {
return lottoCount = money / Lotto.LOTTO_PRICE;
}
- public LottoTicket generateAutoLottoTicket() {
+ public LottoTicket gen... | Java | ๊ฒฐ๊ตญ์ ์๋ ๋ก๋์ ์๋ ๋ก๋ ๋ชจ๋ ํ๋์ ๋ก๋ ํฐ์ผ์ผ๋ก ํฉ์ณ์ง๋ ๋ถ๋ถ์ด ํ์ํ๊ธฐ ๋๋ฌธ์, ํ์ฌ `generateLottoTicket()` ๋ด์ ์๋๊ณผ ์๋ ๋ก๋ ์์ฑ ๊ฐ๊ฐ์ ๋ฐ๋ณต๋ฌธ์ `generateManualLottoTicket()`๊ณผ `generateAutoLottoTicket()` ์ผ๋ก ๋ฉ์๋๋ฅผ ๋ถ๋ฆฌํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค |
@@ -0,0 +1,12 @@
+public class BonusNumber {
+ private LottoNumber bonusNumber;
+
+ public BonusNumber(LottoNumber bonusNumber) {
+ this.bonusNumber = bonusNumber;
+ }
+
+ public LottoNumber getBonusNumber() {
+ return bonusNumber;
+ }
+}
+ | Java | @sunghyuki ๊ธฐ์กด์ Lotto ๊ฐ์ฒด๋ก๋ง ๊ตฌ์ฑ๋ WinningLotto์ BonusNumber๋ฅผ ์ถ๊ฐํ์ฌ, ๋ก๋ ๋น์ฒจ ๋ฒํธ ์ค 5๊ฐ๊ฐ ์ผ์นํ๋ ๊ฒฝ์ฐ BonusNumber ์ผ์น ์ฌ๋ถ ํ์ธ์ ๋ถ๋ช
ํ๊ฒ ํ๊ธฐ ์ํด LottoNumber ํ์
์ผ๋ก ๊ตฌ์ฑ๋ BonusNumber๋ฅผ ์์ฑํ์ต๋๋ค~ |
@@ -4,44 +4,36 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
public class LottoGameTest {
@Test
- @... | Java | @Bellroute ์ ํฌ๋ ์
๋ ฅ ๊ธ์ก๋งํผ ๋ก๋ ๋ฆฌ์คํธ๊ฐ ์ ์ถ๊ฐ๋๋์ง ํ
์คํธํ๋ ค๊ณ ์์ฑํ๋๋ฐ, ์ ์ด์ฃผ์ ๋ฆฌ๋ทฐ๋ฅผ ์ ์ดํดํ์ง ๋ชปํ ๊ฒ ๊ฐ์ต๋๋ค. ๋ถ์ฐ ์ค๋ช
๋ถํ๋๋ ค๋ ๋ ๊น์?? |
@@ -1,9 +1,14 @@
+import java.util.List;
import java.util.Scanner;
public class InputView {
private static final String INPUT_MONEY_MESSAGE = "๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.";
private static final String INPUT_WINNING_LOTTO_MESSAGE = "์ง๋ ์ฃผ ๋น์ฒจ ๋ฒํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.";
+ private static final String MANUAL_LOTTO_COUNT_MESSAGE = ... | Java | @Bellroute ๊ธฐ์กด์ ์ ํฌ๊ฐ ์์ฑํ ์ฝ๋๋ ์ง์ ํด์ฃผ์ ๊ฒ์ฒ๋ผ Lottoame ์ฑ
์์ InputView์์ ๋ถ์ฌํ๊ณ ์์ต๋๋ค. ์ด ๊ฒฝ์ฐ ๋ณ๊ฒฝ์ฌํญ์ด ์๊ธธ ๋, InputView์ Lotto๋ฅผ ์์ฑํ๋ LottoGame์ ๋ชจ๋ ์์ ํด์ผํฉ๋๋ค.
ํ์ธํด๋ณด๋ LottoGame์ ๊ธฐ์กด์ ์์ฑํด๋ Lotto ์์ฑ ๋ฉ์๋๋ฅผ ํ์ฉํด์ ๋ฆฌํํ ๋งํ์์ต๋๋ค. |
@@ -25,10 +25,13 @@ repositories {
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'
implementation 'org.springframew... | Unknown | ํ์์ ๋ง์ถฐ์ฃผ์ธ์. |
@@ -0,0 +1,72 @@
+package com.ll.nbe342team8.domain.admin.service;
+
+import com.ll.nbe342team8.domain.admin.dto.AdminQuestionDto;
+import com.ll.nbe342team8.domain.qna.question.entity.Question;
+import com.ll.nbe342team8.domain.qna.question.repository.QuestionRepository;
+import com.ll.nbe342team8.global.exceptions.Se... | Java | ์ ๋ฒ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค๋ช
๋๋ ธ์์ฃ ?
๊ทธ๋ฆฌ๊ณ ๊ทธ๊ฒ ์๋๋๋ผ๋, ๋ค๋ฅธ๊ณณ์์ ์ฌ์ฉํ ๊ฐ๋ฅ์ฑ์ด ์๋ค๋ฉด ์ด ๋ฉ์๋๋ ์ฌ๊ธฐ ์์ผ๋ฉด ์๋ฉ๋๋ค. |
@@ -0,0 +1,72 @@
+package com.ll.nbe342team8.domain.admin.service;
+
+import com.ll.nbe342team8.domain.admin.dto.AdminQuestionDto;
+import com.ll.nbe342team8.domain.qna.question.entity.Question;
+import com.ll.nbe342team8.domain.qna.question.repository.QuestionRepository;
+import com.ll.nbe342team8.global.exceptions.Se... | Java | ๋ฉ์๋ ์ด๋ฆ์ ๊ฐ๋
์ฑ์ด ์ ๋ง, ์ ๋ง ์ ์ข๋ค์...
์๋ฌด๋ฆฌ Data JPA์ ๋ค์ด๋ฐ ์ปจ๋ฒค์
์ด๋ผ๊ณ ํด๋, ์ ๋นํ ์๋ฅผ ํ์๊ฐ ์์ต๋๋ค. |
@@ -0,0 +1,101 @@
+package com.ll.nbe342team8.domain.book.book.controller;
+
+import java.net.URI;
+import java.util.List;
+
+import org.hibernate.validator.constraints.Range;
+import org.springframework.data.domain.Page;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.D... | Java | ๊ฐ๋ฅํ๋ฉด, ๊ธฐ์
์ OpenAPI ๋ช
์ธ๋ฅผ ์ฝ์ด๋ณด๋ฉด์, ์ด์ชฝ์์ ์ ๊ณตํ๋ ๋ฆฌํด๊ฐ์ ๊ผญ ํ์ธํด๋ดค์ผ๋ฉด ์ข๊ฒ ์ด์.
- https://developers.kakaopay.com/docs/moneytransfer/sendmoney.code/api-qrlink-delete
- https://developers.worksmobile.com/kr/docs/group-delete
๊ณตํต์ ์ด ์์ง ์๋์? |
@@ -1,56 +1,107 @@
package com.ll.nbe342team8.domain.book.book.dto;
+import java.time.LocalDate;
+
import com.ll.nbe342team8.domain.book.book.entity.Book;
import com.ll.nbe342team8.domain.book.category.entity.Category;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.N... | Java | ๊ผญ ๊ธฐ๋ณธ placeholder๊ฐ ์์ด์ผ ํ ๊น์? |
@@ -1,108 +1,104 @@
package com.ll.nbe342team8.domain.book.book.entity;
+import java.time.LocalDate;
+import java.util.List;
+
+import org.hibernate.annotations.Formula;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.ll.nbe342team8.domain.book.book.dto.BookPatchRequestDto;
import com.ll.nbe342te... | Java | ์ ๋ฐ์ ์ธ indent๊ฐ ๊ผฌ์ธ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,123 @@
+package com.ll.nbe342team8.domain.book.book.service;
+
+import java.util.List;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.ll.nbe342team8.domain.book.book.dto.BookResponseDto;
+import com.ll.nbe342team8.domain.book.... | Java | ์ด๊ฑฐ ๋ฌธ์์ด ํฉ์น๋ ๋ฒ ๋ค์์ ์๋ ค๋๋ฆด๊ฒ์ ใ
ใ
|
@@ -1,113 +1,93 @@
package com.ll.nbe342team8.domain.book.book.service;
-import com.ll.nbe342team8.domain.book.book.dto.BookPatchRequestDto;
-import com.ll.nbe342team8.domain.book.book.dto.BookResponseDto;
-import com.ll.nbe342team8.domain.book.book.dto.ExternalBookDto;
-import com.ll.nbe342team8.domain.book.book.en... | Java | Transactional ์ด ์๋ค์? |
@@ -1,113 +1,93 @@
package com.ll.nbe342team8.domain.book.book.service;
-import com.ll.nbe342team8.domain.book.book.dto.BookPatchRequestDto;
-import com.ll.nbe342team8.domain.book.book.dto.BookResponseDto;
-import com.ll.nbe342team8.domain.book.book.dto.ExternalBookDto;
-import com.ll.nbe342team8.domain.book.book.en... | Java | JDK 17๋ก ๋์ด๊ฐ๋ฉด์ switch ๊ตฌ๋ฌธ์ด ์ด๋ป๊ฒ ๋ณํ๋์ง ์์๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -1,7 +1,10 @@
package baseball;
+import baseball.controller.GameController;
+
public class Application {
public static void main(String[] args) {
- // TODO: ํ๋ก๊ทธ๋จ ๊ตฌํ
+ GameController gameController = new GameController();
+ gameController.gameFlow();
}
} | Java | ์ฌ๊ธฐ ์ ๊ฒฝ๊ณ ํ์๊ฐ ๋จ๋๊ฑธ๊น?
https://hyeon9mak.github.io/github-no-newline-at-a-end-of-file/ |
@@ -0,0 +1,78 @@
+package baseball.controller;
+
+import java.util.List;
+
+import baseball.model.ComputerInputData;
+import baseball.view.PlayerInputView;
+import baseball.model.CompareBallsModel;
+import baseball.service.BaseballGameService;
+import baseball.service.InvalidInputHandler;
+import baseball.serv... | Java | `result[0]`์ด ์คํธ๋ผ์ดํฌ ์นด์ดํฐ์ด๊ณ `result[1]`์ด ๋ณผ ์นด์ดํธ์ธ ๊ฒ์ `BaseballCompareModel` ํด๋์ค๋ฅผ ํ์ธํด์ผ๋ง ์ ์ ์๋๊ฑด๊ฐ? |
@@ -0,0 +1,78 @@
+package baseball.controller;
+
+import java.util.List;
+
+import baseball.model.ComputerInputData;
+import baseball.view.PlayerInputView;
+import baseball.model.CompareBallsModel;
+import baseball.service.BaseballGameService;
+import baseball.service.InvalidInputHandler;
+import baseball.serv... | Java | ์ `BaseballCompareModel` ํด๋์ค๋ง ์ธ์คํด์ค๋ช
์ด ๋ฌ๋ผ? |
@@ -0,0 +1,78 @@
+package baseball.controller;
+
+import java.util.List;
+
+import baseball.model.ComputerInputData;
+import baseball.view.PlayerInputView;
+import baseball.model.CompareBallsModel;
+import baseball.service.BaseballGameService;
+import baseball.service.InvalidInputHandler;
+import baseball.serv... | Java | [else ๋ฌธ์ ์ง์ํ๋ ์ด์ ](https://opendeveloper.tistory.com/entry/%EC%BD%94%EB%93%9C%EC%9D%B4%EC%8A%88-if%EB%AC%B8%EC%97%90%EC%84%9C-else%EC%99%80-else-if%EB%A5%BC-%EC%A7%80%EC%96%91%ED%95%98%EB%8A%94-%EC%9D%98%EA%B2%AC%EC%97%90-%EB%8C%80%ED%95%9C-%EC%83%9D%EA%B0%81%EC%A0%95%EB%A6%AC) |
@@ -0,0 +1,78 @@
+package baseball.controller;
+
+import java.util.List;
+
+import baseball.model.ComputerInputData;
+import baseball.view.PlayerInputView;
+import baseball.model.CompareBallsModel;
+import baseball.service.BaseballGameService;
+import baseball.service.InvalidInputHandler;
+import baseball.serv... | Java | ๋ฉ์๋๋ช
์ `print`๊ฐ ๋ค์ด๊ฐ๋ฉด `Controller`์ ๊ด์ฌ์ฌ๊ฐ ๋ง๋๊ฑธ๊น? |
@@ -0,0 +1,35 @@
+package baseball.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import camp.nextstep.edu.missionutils.Randoms;
+
+public class ComputerInputData {
+
+ private List<Integer> computerList;
... | Java | ์ฌ๊ธฐ์ `static`์ ์ฌ์ฉํ ์ด์ ๊ฐ ๋ญ์ผ? |
@@ -0,0 +1,35 @@
+package baseball.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import camp.nextstep.edu.missionutils.Randoms;
+
+public class ComputerInputData {
+
+ private List<Integer> computerList;
... | Java | `set` -> `List`๋ก ํ๋ณํ ํ ๋ ์๋์ผ๋ก ์ ๋ ฌ๋๊ธฐ ๋๋ฌธ์ `shuffle`์ ํ ๊ฑด ์ข์ ๊ฒ ๊ฐ์ ๐
๊ทธ๋ฐ๋ฐ ๋จ์ ํ
์คํธ๋ฅผ ํ ๋ ๋๋ค ๊ฐ์ ์ํ๋ ๊ฐ์ ๋ฃ๋ ๊ฒฝ์ฐ๋ ์์ํ
๋ฐ `shuffle`์ ์ด์ฉํ๋ฉด ์ํ๋ ํ
์คํธ๋ฅผ ํ๊ธฐ ์ด๋ ต์ง ์์๊น?
์๋ฅผ ๋ค์ด์ ์ฐ๋ฆฌ๋ `6`, `1`, `9`๋ฅผ ๋ฃ์ด์ ํ
์คํธ ํ๊ณ ์ถ์๋ฐ ์ ์์๋ฅผ ๋ณด์ฅํ ์ ์์๊น? |
@@ -0,0 +1,35 @@
+package baseball.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import camp.nextstep.edu.missionutils.Randoms;
+
+public class ComputerInputData {
+
+ private List<Integer> computerList;
... | Java | ๋ถ๋ช
`computerList`๋ `private`๋ก ์ ์ธํ์ง๋ง ์ด๋ฐ์์ผ๋ก ๋ฆฌํดํ๋ฉด ๋ถ๋ณ ๋ฆฌ์คํธ๋ฅผ ๋ณด์ฅํ ์ ์์ด?
[์ฐธ๊ณ ์๋ฃ](https://colabear754.tistory.com/185) |
@@ -0,0 +1,33 @@
+package baseball.service;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class BaseballGameService {
+
+ public boolean isValidInput(String input) {
+ // 3์๋ฆฌ ์ฒดํฌ
+ if(input.length() != 3) {
+ return false;
+ }
+
+ boolean onlyNum... | Java | ```java
Set<Character> charSet = new HashSet<>();
for (char c : input.toCharArray()) {
if (!charSet.add(c)) { // ์ค๋ณต๋ ๋ฌธ์๊ฐ ๋ค์ด์ค๋ฉด false ๋ฆฌํด
return false;
}
}
``` |
@@ -0,0 +1,33 @@
+package baseball.service;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class BaseballGameService {
+
+ public boolean isValidInput(String input) {
+ // 3์๋ฆฌ ์ฒดํฌ
+ if(input.length() != 3) {
+ return false;
+ }
+
+ boolean onlyNum... | Java | `isValidInput`์ด ๋ฌด์จ ์๋ฏธ์ผ? `BaseballGameService` ๋ณด๋ค๋ `InvalidInputHandler`์ ์๋๊ฒ ๋ ์ด์ธ๋ฆด ๊ฒ ๊ฐ์๋ฐ ๋ฉ์๋๋ช
์ธ๋ฐ |
@@ -0,0 +1,26 @@
+package baseball.service;
+
+import camp.nextstep.edu.missionutils.Console;
+
+public class MoreGameService {
+ InvalidInputHandler invalidInputHandler;
+
+ public MoreGameService() {
+ this.invalidInputHandler = new InvalidInputHandler();
+ }
+
+
+ public boolean more()... | Java | `Service` ๊ณ์ธต์์ ๋ค๋ฅธ `Service`๋ฅผ ์ฌ์ฉํ๋ฉด ๊ฒฐํฉ๋๊ฐ ๋๋ฌด ๋์๊ฑฐ ์๋๊ฐ? |
@@ -0,0 +1,7 @@
+package baseball.service;
+
+public class InvalidInputHandler {
+ public void invalidInputPrint() {
+ throw new IllegalArgumentException();
+ }
+}
| Java | ์ค์ง `IllegalArgumentException()`์ ์ํด ์กด์ฌํ๋ ํด๋์ค์ผ? |
@@ -0,0 +1,26 @@
+package baseball.service;
+
+import camp.nextstep.edu.missionutils.Console;
+
+public class MoreGameService {
+ InvalidInputHandler invalidInputHandler;
+
+ public MoreGameService() {
+ this.invalidInputHandler = new InvalidInputHandler();
+ }
+
+
+ public boolean more()... | Java | ๋ง์ฐฌ๊ฐ์ง๋ก `else`๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒ ํจ์ฌ ์ข์ ์ฝ๋์ธ ๊ฒ ๊ฐ์ |
@@ -0,0 +1,26 @@
+package baseball.service;
+
+import camp.nextstep.edu.missionutils.Console;
+
+public class MoreGameService {
+ InvalidInputHandler invalidInputHandler;
+
+ public MoreGameService() {
+ this.invalidInputHandler = new InvalidInputHandler();
+ }
+
+
+ public boolean more()... | Java | ์ฌ๊ธฐ๋ ๋ง์ฐฌ๊ฐ์ง๋ก `Service` ๊ณ์ธต์์ `System.out.println`์ ํ๋ ๊ฒ์ด ์ ์ ํ๊ฐ? |
@@ -0,0 +1,12 @@
+package baseball.view;
+
+import camp.nextstep.edu.missionutils.Console;
+
+public class PlayerInputView {
+
+ public String getPlayerInput() {
+ System.out.print("์ซ์๋ฅผ ์
๋ ฅํด์ฃผ์ธ์ : ");
+ return Console.readLine();
+ }
+
+}
| Java | `System.out.print`๋ `InputView`๋ณด๋ค๋ `OutputView`์ด์ง ์์๊น? |
@@ -0,0 +1,78 @@
+package baseball.controller;
+
+import java.util.List;
+
+import baseball.model.ComputerInputData;
+import baseball.view.PlayerInputView;
+import baseball.model.CompareBallsModel;
+import baseball.service.BaseballGameService;
+import baseball.service.InvalidInputHandler;
+import baseball.serv... | Java | ์ด ๋ถ๋ถ์ view์์ ์ฒ๋ฆฌํ๋ ๊ฑธ๋ก ํด์ผ ํ๋๋ฐ ๋๋ฌด ๊ฐ๋จํ ๋ก์ง ์ฒ๋ฆฌ๋ฅผ Model -> Controller -> View -> Controller ์ด๋ ๊ฒ ์ฒ๋ฆฌํ๋๊ฒ ์คํ๋ ค ๋ ๋นํจ์จ์ ์ด์ง ์์๊น ์๊ฐํด์ ์ด๋ ๊ฒ ์์ฑํด๋ดค๋๋ฐ ์์ง ์ ๋ต์ ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. |
@@ -0,0 +1,26 @@
+package baseball.service;
+
+import camp.nextstep.edu.missionutils.Console;
+
+public class MoreGameService {
+ InvalidInputHandler invalidInputHandler;
+
+ public MoreGameService() {
+ this.invalidInputHandler = new InvalidInputHandler();
+ }
+
+
+ public boolean more()... | Java | ์๋ ์ฝ๋ฉํธํ๊ณ ๋ ๊ด๋ จ๋์ด ์๋ ์ฌํญ์ธ๋ฐ Service์ ์ญํ ์ด ๋ค๋ฅด๊ณ , ๋จ์ํ ํธ์ถ ํ์์ธ๋ฐ ์ด ๋ถ๋ถ๋ ๊ฒฐํฉ์ด ๋์๊ฑด์ง ๊ถ๊ธํฉ๋๋ค. |
@@ -0,0 +1,26 @@
+package baseball.service;
+
+import camp.nextstep.edu.missionutils.Console;
+
+public class MoreGameService {
+ InvalidInputHandler invalidInputHandler;
+
+ public MoreGameService() {
+ this.invalidInputHandler = new InvalidInputHandler();
+ }
+
+
+ public boolean more()... | Java | ๋ด๊ฐ ์๊ฐํ๋ ๊ฒฐํฉ๋๋ ๋ง์ฝ `InvalidInputHandler`์ ์๊ตฌ ์ฌํญ์ด ๋ณ๊ฒฝ๋ผ์ ์์ ํ๊ฒ ๋๋ฉด ๋น์ฐํ `MoreGameService`์๋ ๋ฌธ์ ๊ฐ ์๊ธธ ๊ฐ๋ฅ์ฑ์ด ๋๊ฒ ์ง
์ง๊ธ์ ๋งค์ฐ ๊ฐ๋จํ ๋ก์ง์ ์ฒ๋ฆฌํด์ 1๊ฐ์ ์์กด๋ฐ์ ์์ง๋ง ๋ฐ๋๋ก ์๊ธฐํ๋ฉด ๊ฐ๋จํ ๋ก์ง๋ ์์กด์ฑ์ด ๋ฐ์ํ๋๋ฐ ๋ณต์กํ ๋ก์ง์ ์ผ๋ง๋ ๊ฐํ ๊ฒฐํฉ์ด ๋ฐ์ํ๊ณ ๋ฆฌํฉํ ๋ง์ด ์ด๋ ค์์ง๊น? ํ๋ ์๊ฐ์ด ๋๋ ๊ฒ ๊ฐ์ |
@@ -0,0 +1,78 @@
+package baseball.controller;
+
+import java.util.List;
+
+import baseball.model.ComputerInputData;
+import baseball.view.PlayerInputView;
+import baseball.model.CompareBallsModel;
+import baseball.service.BaseballGameService;
+import baseball.service.InvalidInputHandler;
+import baseball.serv... | Java | ๊ฐ๋จํ ๊ฑฐ๋ผ๋ `view`์ ๊ด์ฌ์ฌ๋ฉด `view`์์ ์ฒ๋ฆฌํ๋ ๊ฒ ๋ง๋ ๊ฒ ๊ฐ์. `Controller -> View`๊ฐ ๋๋ ๊ฑฐ์ง
์ผ๋จ ๊ฐ๋จํ๊ณ ๋ณต์กํ๊ฑฐ์ ๊ธฐ์ค์ด ์์์ ์ผ๋ง๋ ๊ฐ๋จํ๊ฑฐ๋ `Controller`์์ ์ฒ๋ฆฌํ๊ณ ๋ณต์กํ ๊ฑด `View`์์ ์ฒ๋ฆฌํ๋ค ๋ฒ์จ ๋ง์ด ์๋๋๊ฒ ๋๊ปด์ง์ง
๊ทธ๋ฆฌ๊ณ ๋ง์ฝ ์ถ๋ ฅ๋ถ๋ถ์์ ๋ฌธ์ ๊ฐ ์๊ธฐ๋ฉด ๋น์ฐํ `View` ๊ณ์ธต์ ํ์ธ ํ ํ
๋ฐ ๊ฐ๋จํ๋ค๊ณ ํด์ ๋ค๋ฅธ๊ณณ์์ ์ฒ๋ฆฌํ๋ฉด ์ ์ง๋ณด์ ๋น์ฉ์ด ํจ์ฌ ์ฌ๋ผ๊ฐ๊ฒ ์ง |
@@ -1,15 +1,10 @@
package com.api.resume.adapter.controller;
-import com.api.resume.adapter.payload.resumeintroduction.ResumeIntroductionCreateRequest;
-import com.api.resume.adapter.payload.resumeintroduction.ResumeIntroductionDetailResponse;
-import com.api.resume.adapter.payload.resumeintroduction.ResumeIntroduct... | Java | @dbeod2
์ํฐํฐ์ ์์ฑ ๋ก์ง์ ์ปจํธ๋กค๋ฌ์์ ๊ตณ์ด ๋
ธ์ถํ ํ์๊ฐ ์์ต๋๋ค~!
์ฝ๋๊ฐ ๊ฐ๋จํด์ง๊ณ ์์ฑ๋ก์ง์ด ์ํฐํฐ์ ๊ฐ์ด ์๊ฒ ๋์ด์ ์์ง์ฑ์ด ๊ฐํด์ง๋๋ค~!
```java
ResumeIntroductionCreateCommand command = ResumeIntroductionCreateCommand.from(request);
``` |
@@ -1,6 +1,6 @@
package com.api.resume.application.resumeintroduction;
-import com.api.resume.adapter.persistence.resumeIntroduction.ResumeIntroductionAdapter;
+import com.api.resume.adapter.persistence.resumeIntroduction.ResumeIntroductionRepository;
import com.api.resume.application.resumeintroduction.command.Res... | Java | @dbeod2
modify๊ฐ ์์ง void์ธ๊ฐ์? ์ ๋ถ๋ถ๋ ํ๋ฒ ์ดํด๋ด์ฃผ์ธ์~! |
@@ -1,6 +1,6 @@
package com.api.resume.application.resumeintroduction;
-import com.api.resume.adapter.persistence.resumeIntroduction.ResumeIntroductionAdapter;
+import com.api.resume.adapter.persistence.resumeIntroduction.ResumeIntroductionRepository;
import com.api.resume.application.resumeintroduction.command.Res... | Java | @dbeod2
Create, Update์ ๊ฒฝ์ฐ ์์ฑ/๋ณ๊ฒฝ๋ Entity ๊ฐ์ฒด์ ๊ฐ์ ๋ด๋ ค์ฃผ๋ ๊ฒฝ์ฐ๊ฐ ๋ง์ต๋๋ค.
์ ๋๋ก ๋ง๋ค์ด์ก๋์ง ํธ์ถ์๊ฐ ํ์ธํ๊ธฐ ์ฉ์ดํ๊ธฐ๋ ํ๊ณ , Restfulํ API์ ๊ธฐ์ค์์ ๋ณด๋ฉด ์์ฑํ๊ณ GET์ ํ๋ฒ ๋ ํธ์ถํด์ผ ์ ์ฒด ์ ๋ณด๋ฅผ ์ ์ ์๋๊ฒ ๋นํจ์จ์ ์ธ ๊ฒฝ์ฐ๊ฐ ๋ง์์์.
์ฐธ๊ณ ๋ถํ๋๋ฆฝ๋๋ค~! |
@@ -0,0 +1,75 @@
+package nextstep.security.authorization;
+
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
+
+public class RoleHierarchyImpl implements RoleHierarchy {
+
+ private final Map<String, Set<String>> rolesReachableInOneOrMoreStepsMap;
+
+ public RoleHierarchyImpl(Map<String, ... | Java | ๋ง์ฝ ๋ค์๊ณผ ๊ฐ์ด ๊ถํ์ ๊ณ์ธต ๊ตฌ์กฐ๋ฅผ ์ค์ ํ ๊ฒฝ์ฐ์๋ ์ด๋ป๊ฒ ์ฒ๋ฆฌ๋์ด์ผ ํ ๊น์?
``` java
RoleHierarchyImpl.with()
.role("ADMIN").implies("USER")
.role("USER").implies("GUEST")
.build();
```
ํ์ฌ ๊ตฌ์กฐ์์๋ ์ง์ ์ ์ธ ํ์ ์ญํ ๋ง ์ถ๊ฐํ๊ณ ์์ด์, ADMIN์ด USER๋ง ํฌํจํ๊ณ GUEST๊น์ง ํ์ฅ๋์ง ์๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.
Spring Security์ RoleHierarchyImpl์ buildRolesReachableInOneOrMore... |
@@ -0,0 +1,51 @@
+package nextstep.app;
+
+import nextstep.security.authorization.NullRoleHierarchy;
+import nextstep.security.authorization.RoleHierarchyImpl;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collection;
+import ... | Java | ํ
์คํธ ์ฝ๋ ๐
์ฝ๋ ๊ฐ์ ํด ๋ณด์๋ฉด์ ์๋ ์ผ์ด์ค์ ๋ํ ํ
์คํธ ์ฝ๋๋ ์์ฑํด ๋ณด๋ฉด ์ข์ ๊ฒ ๊ฐ๋ค์ ๐
``` java
RoleHierarchyImpl.with()
.role("ADMIN").implies("USER")
.role("USER").implies("GUEST")
.build();
``` |
@@ -0,0 +1,83 @@
+package nextstep.security.config;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.h... | Java | > ๊ถ๊ธํ์ ์ ์ VirtualFilterChain ์ FilterChainDecorator๋ฅผ ์
ํ spring security์์๋ ์ฌ์ฉํ๊ณ ์๋์ง ์
๋๋ค.
VirtualFilterChain์ ์ญํ ๊ณผ FilterChainDecorator์ ์ญํ ์ ์ญํ ์ด ๋ฌ๋ผ์ ๊ทธ๋ฐ๋ฐ์.
VirtualFilterChain๋ ํน์ ์กฐ๊ฑด์ ๊ธฐ๋ฐ์ผ๋ก ํํฐ๋ค์ ์คํํ๋ ์ญํ ์ ํ๊ณ , FilterChainDecorator๋ ๊ธฐ์กด FilterChain์ ์ถ๊ฐ์ ์ธ ๋ก์ง์ ์ฝ์
ํ๊ฑฐ๋ ์์ ํ ์ ์๋๋ก ๋์์ฃผ๋ ์ญํ ์ ํฉ๋๋ค.
์์๋ฅผ ๋ค์ด๋ณด์๋ฉด /a ์์ฒญ๊ณผ /b ์์ฒญ์ ๋ค๋ฅธ ๋ณด์ ํํฐ๋ฅผ... |
@@ -0,0 +1,83 @@
+package nextstep.security.config;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.h... | Java | > FilterChainDecorator ๋์์ธ ํจํด์ ๋ฐ์ฝ๋ ์ดํฐ ํจํด๊ณผ๋ ๋ค๋ฅธ ๊ทธ๋ฅ ๋ํผ์ญํ ์ ํ๋ ์ธํฐํ์ด์ค์ธ๊ฒ ๊ฐ์๋ฐ ์ด๋ฆ์ ์ฐ๊ด์ฑ์ด ์๋์ง ๊ถ๊ธํฉ๋๋ค.
์ ์์ ์ธ ๋ฐ์ฝ๋ ์ดํฐ ํจํด์ ์๋์ง๋ง FilterChain์ ๊ฐ์ธ์ ๊ธฐ์กด ํํฐ๋ฅผ ์์ ํ์ง ์๊ณ ์ถ๊ฐ์ ์ธ ํํฐ๋ฅผ ์คํํ๋ค๋ ๊ด์ ์์ ๋ฐ์ฝ๋ ์ดํฐ์ ์ญํ ์ ํ๊ณ ์๋ค๊ณ ๋ณด์ฌ์ง๋๋ค.
๋ฐ๋ผ์ `๋ฐ์ฝ๋ ์ดํฐ ๋์์ธ ํจํด์ ์๋ฒฝํ ๊ตฌํ์ฒด์ด๋ค!`๋ ์๋์ง๋ง, ๋ฐ์ฝ๋ ์ดํฐ ํจํด์์ ์๊ธฐํ๋ ํต์ฌ ๊ฐ๋
์ธ `์๋ณธ์ ์ ์งํ ์ํ๋ก ํ์ฅ์ด ๊ฐ๋ฅํ๋ค.` ๋ผ๋ ์ ์์๋ ๋ฐ์ฝ๋ ์ดํฐ๋ผ๋ ์ด๋ฆ์ด ์ด์ํ์ง ์์ ๊ฒ ๊ฐ๋ค๋ ์๊ฒฌ ๋๋ฆฝ๋๋ค :) |
@@ -0,0 +1,83 @@
+package nextstep.security.config;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.h... | Java | > security ํจํค์ง์์ securityconfig๋ผ๋ ํด๋์ค์ delegatingfilterproxy, filterchianproxy ๋น๋ค์ ์ค์ ํ๊ณ userService ๋น๋ง app ํจํค์ง ์์์ ์ค์ ํ์ต๋๋ค. ๊ทธ๋ฐ๋ฐ ํํฐ ๋ฑ๋ก์ด ์๋๋๋ผ๊ณ ์.(filterchainproxy)
์ด๊ฒ์ ๋ํด ๋ช
ํํ๊ฒ ์ ๊ทธ๋ฐ๊ฑด์ง ์ด์ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
์ ํํ ๊ฒ์ ํด๋น ์ฝ๋๋ฅผ ๋ด์ผ๊ฒ ์ง๋ง.. ๊ฐ๋ณ๊ฒ ์ถ์ธกํด ๋ณด์๋ฉด
1. SecurityAuthenticationApplication์์ componentScan์ ๋ณ๊ฒฝํ์ง ์์๋ค.
2. ์ค์ ํ Config์ `@Conf... |
@@ -0,0 +1,32 @@
+package nextstep.security.config;
+
+import nextstep.security.UserDetails;
+
+import java.security.Principal;
+
+// Implementations which use this class should be immutable.
+public abstract class AbstractAuthenticationToken implements Authentication{
+
+ private Object details;
+
+ @Override
+... | Java | principal์ด ์ถ๊ฐ๋ ๋ ๋ง๋ค ํด๋น ํด๋์ค๋ฅผ ์์ ํด์ผ ํ๋ ๊ฒ์ ๋ฌธ์ ๊ฐ ์์ด ๋ณด์ด๋๋ฐ์.
์์ฑ ์์ ์ principal์์ ํ์ํ ๊ฐ๋ง ์ถ์ถํ์ฌ ๋๊ฒจ ๋ฐ๋๋ค๋ฉด ํด๋น ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,81 @@
+package nextstep.security.config;
+
+
+import java.io.Serializable;
+import java.security.Principal;
+
+/**
+ * ์ผ๋จ ์์ฒญ์ด AuthenticationManager์ authenticate(Authentication) ๋ฉ์๋์ ์ํด์ ์งํ๋๋ค๋ฉด
+ * ์ธ์ฆ ์์ฒญ์ด๋ authenticated principaldใ
๋ํ ํ ํฐ์ ๋ํ๋ธ๋ค.
+
+ * ์ผ๋จ request๊ฐ authenticated ๋๋ฉด, ์ด Authentication ๊ฐ์ฒด๋ Securit... | Java | ํ์ตํ ๋ด์ฉ์ด ๋จ์์์ด์ ์ข๋ค์ ๐ฏ |
@@ -0,0 +1,42 @@
+package nextstep.security.config;
+
+import nextstep.security.AuthenticationException;
+import nextstep.security.UserDetailService;
+import nextstep.security.UserDetails;
+
+public class DaoAuthenticationProvider implements AuthenticationProvider{
+
+ private final UserDetailService userDetailServi... | Java | ํด๋น ํด๋์ค๋ฅผ ์ฌ์ฉํ๊ณ ์์ง ์๊ตฐ์! |
@@ -0,0 +1,45 @@
+package nextstep.security.config;
+
+import nextstep.security.ProviderNotFoundException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ProviderManager implements AuthenticationManager {
+
+ private List<AuthenticationProvider> providers = Collections.emptyList();
+
+ p... | Java | ์ง์ํ๋ provider๋ฅผ ์ฐพ์๋ authenticate ์ null์ด ์๋ต๋๋ค๋ฉด ํด๋น ์์ธ ๋ฉ์์ง๊ฐ ์ถ๋ ฅ๋๊ฒ ๋ค์.
์๋ํ ๋ด์ฉ์ด ๋ง์๊น์? |
@@ -0,0 +1,45 @@
+package nextstep.security.config;
+
+import nextstep.security.ProviderNotFoundException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ProviderManager implements AuthenticationManager {
+
+ private List<AuthenticationProvider> providers = Collections.emptyList();
+
+ p... | Java | ProviderManager๋ ์ฌ๋ฌ ๊ฐ์ AuthenticationProvider๋ฅผ ๊ด๋ฆฌํ๊ณ , ์ฌ๋ฐ๋ฅธ Provider๋ฅผ ์ ํํ์ฌ ์ธ์ฆ์ ์ํํ๋ ์ญํ ์ ๋ด๋นํ๊ฒ ๋๋๋ฐ์.
์ด ์ญํ ์ ProviderManager์ด ์๋ AuthenticationProvider์ ์ญํ ์ ๋ ์ ์ ํด ๋ณด์ด๋๋ฐ ์ด๋ป๊ฒ ์๊ฐํ์๋์? |
@@ -0,0 +1,85 @@
+package nextstep.security.filter;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.h... | Java | ์ฝ๋์ depth๊ฐ ๊ธธ์ด์ง๋ฉด ์ฝ๋์ ๊ฐ๋
์ฑ์ด ๋จ์ด์ง๊ฒ ๋๋๋ฐ์.
๊ทธ๋ฐ ๊ด์ ์์ early returnํ๋ ์ฝ๋๋ฅผ ์์ฑํ๋ค๋ฉด ๊ฐ๋
์ฑ์ด ์ฌ๋ผ๊ฐ ๊ฒ ๊ฐ์ต๋๋ค!
```suggestion
if (!isHttpServlet) {
throw new ServletException("BasicAuthFilter only supports HTTP requests");
}
HttpServletRequest request = (HttpServletRequest) servletRequest;
... |
@@ -0,0 +1,49 @@
+package nextstep.security.interceptor;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import nextstep.security.AuthenticationException;
+import nextstep.security.UserDetailService;
+import nextstep.security.UserDetails;
+import nextstep.security.u... | Java | BasicAuthInterceptor์ FormLoginInterceptor๋ ์ฌ์ฉ๋์ง ์๋ ๊ฒ ๊ฐ์๋ฐ, ์ด๋ค ์ด์ ๋ก ์ถ๊ฐํ์
จ์๊น์? |
@@ -0,0 +1,83 @@
+package nextstep.security.config;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.h... | Java | > > security ํจํค์ง์์ securityconfig๋ผ๋ ํด๋์ค์ delegatingfilterproxy, filterchianproxy ๋น๋ค์ ์ค์ ํ๊ณ userService ๋น๋ง app ํจํค์ง ์์์ ์ค์ ํ์ต๋๋ค. ๊ทธ๋ฐ๋ฐ ํํฐ ๋ฑ๋ก์ด ์๋๋๋ผ๊ณ ์.(filterchainproxy)
> > ์ด๊ฒ์ ๋ํด ๋ช
ํํ๊ฒ ์ ๊ทธ๋ฐ๊ฑด์ง ์ด์ ๋ฅผ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
>
> ์ ํํ ๊ฒ์ ํด๋น ์ฝ๋๋ฅผ ๋ด์ผ๊ฒ ์ง๋ง.. ๊ฐ๋ณ๊ฒ ์ถ์ธกํด ๋ณด์๋ฉด
>
> 1. SecurityAuthenticationApplication์์ componentScan์ ๋ณ๊ฒฝํ์ง ์์๋ค.
> 2. ์ค์ ํ ... |
@@ -0,0 +1,42 @@
+package nextstep.security.config;
+
+import nextstep.security.AuthenticationException;
+import nextstep.security.UserDetailService;
+import nextstep.security.UserDetails;
+
+public class DaoAuthenticationProvider implements AuthenticationProvider{
+
+ private final UserDetailService userDetailServi... | Java | ๋ค passwordencoder๋ ์ถํ ๋ฏธ์
์งํํ๋ฉด์ ์กฐ๊ธ ๋ ๋ฏ์ด๋ณผ ์์ ์
๋๋ค! |
@@ -0,0 +1,45 @@
+package nextstep.security.config;
+
+import nextstep.security.ProviderNotFoundException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ProviderManager implements AuthenticationManager {
+
+ private List<AuthenticationProvider> providers = Collections.emptyList();
+
+ p... | Java | > ์ง์ํ๋ provider๋ฅผ ์ฐพ์๋ authenticate ์ null์ด ์๋ต๋๋ค๋ฉด ํด๋น ์์ธ ๋ฉ์์ง๊ฐ ์ถ๋ ฅ๋๊ฒ ๋ค์. ์๋ํ ๋ด์ฉ์ด ๋ง์๊น์?
๋ค ๋ง์ต๋๋ค!
`AuthenticationManager`์์ ์ธ์ฆ์ supportํ๋ `AuthenticationProvider`๊ฐ ์๋ค๋ฉด ํด๋น ์์ธ๋ฅผ ๋์ง๊ฒ ๋ง๋ค์ด ๋์์ต๋๋ค!
`ProviderManager` ์ฝ๋๋ฅผ ์ฐธ๊ณ ํ๋๋ฐ์, `ProviderManager`์์๋ `parent` `AuthenticationManager`๊ฐ ์กด์ฌํ๋ค๋ฉด ๋ถ๋ชจ `AuthenticationManager`๊ฐ `authenticate()... |
@@ -0,0 +1,45 @@
+package nextstep.security.config;
+
+import nextstep.security.ProviderNotFoundException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ProviderManager implements AuthenticationManager {
+
+ private List<AuthenticationProvider> providers = Collections.emptyList();
+
+ p... | Java | ๊ทธ๋ฐ๋ฐ ๊ถ๊ธํ์ ์ `ProviderManager` ๋ ๋ด๋ถ์ `parent` ํ๋กํผํฐ๋ก `AuthenticationManager` ๊ฐ์ ธ์ `AuthenticationManager` ๋ฅผ ๊ณ์ํด์ ์ด์์ ์๋ค๋๊ฒ์ ํ์ธํ๋๋ฐ์,
์ ์ด๋ ๊ฒ ๋ง๋ค์์์ง ์ฌ์ฐ๋์ ์ด๋ป๊ฒ ์๊ฐํ์๋์?
์ parent๋ฅผ ํ๋กํผํฐ๋ก ๋์์๊น์?
์ฌ๋ฌ AuthenticationManager ๊ฐ์ ์ธ์ฆ ์ ์ฐจ๋ฅผ ์ ์ฐํ๊ฒ ์ค์ ํ๊ธฐ ์ํด ๊ด๊ณ ์ค์ ์ ํ๋๊ฒ์ผ๊ฒ ๊ฐ๊ธดํ๋ฐ ๊ถ๊ธํฉ๋๋ค :) |
@@ -0,0 +1,45 @@
+package nextstep.security.config;
+
+import nextstep.security.ProviderNotFoundException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ProviderManager implements AuthenticationManager {
+
+ private List<AuthenticationProvider> providers = Collections.emptyList();
+
+ p... | Java | ์ฌ๊ธฐ์ `ProviderManager` ๋ ์ง์ํ๋ `AuthenticationProvider`๋ฅผ ์ํํ๋ ์ญํ ์ ํ๋ค๊ณ ์๊ฐํ์ต๋๋ค.
์ธ์ฆ ๋ก์ง ์์ฒด๋ ๊ฐ `AuthenticationProvider`์์ ์งํ์ ํ๋ค๊ณ ์๊ฐํ์ด์. (๋ง์น FilerChainProxy์ SecurityFilterChain ๊ณผ ๋น์ทํ ๊ด๊ณ๊ฐ๋ค๊ณ ๋ ์๊ฐํ์ต๋๋ค.)
`AuthenticationProvider` ๋ ์ธ์ฆ๋๋ค๋ฉด `Authentication` ์ด๋ผ๋ ํ ํฐ๊ฐ์ฒด์ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ๋ด์ ๋๊ฒจ์ฃผ๋ ์ญํ ์ ํ๊ณ ์.
๊ทธ๋ฐ๋ฐ ์ฌ๊ธฐ์๋ result๋ผ๋ `Authentication` ๋ณ์... |
@@ -0,0 +1,85 @@
+package nextstep.security.filter;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.h... | Java | ํผ๋๋ฐฑ ๋ฐ์ํ๊ฒ ์ต๋๋ค! ๊ฐ์ฌํฉ๋๋ค :)
์ด๋ฒ ๋ฏธ์
์์๋ ๊ธฐ๋ณธ์ ์ผ๋ก security์ ๋์ ์๋ฆฌ ์ค์ฌ์ผ๋ก ๋ณด๊ณ ์์ด ์ ๊ฒฝ์ ์ฐ์ง ๋ชปํ์ง๋ง ๊ฐ๋
์ฑ๋ ๊ณ ๋ คํด์ ์์ฑํด๋ณด๊ฒ ์ต๋๋ค! ๐ |
@@ -0,0 +1,49 @@
+package nextstep.security.interceptor;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import nextstep.security.AuthenticationException;
+import nextstep.security.UserDetailService;
+import nextstep.security.UserDetails;
+import nextstep.security.u... | Java | ์ด๊ฑด ๋ฏธ์
์งํํ๋ค ๋จ๊ธด ์ ๋ฌผ๋ค์ธ๋ฐ ์ง์ฐ์ง์๊ณ ํ์ต์ฉ์ผ๋ก ๋จ๊ฒจ๋์์ต๋๋ค!
์ฒ์์ interceptor์ ๋ก์ง > filter๋ก ๋ณํ ๊ณผ์ ์์ ์๊ฒผ๋ ๊ฒ๋ค์
๋๋ค:) |
@@ -0,0 +1,45 @@
+package nextstep.security.config;
+
+import nextstep.security.ProviderNotFoundException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ProviderManager implements AuthenticationManager {
+
+ private List<AuthenticationProvider> providers = Collections.emptyList();
+
+ p... | Java | provider๋ฅผ ์ฐพ์ง ๋ชปํ ์ผ์ด์ค์ provider๋ฅผ ์ฐพ์์ง๋ง, ์ธ์ฆ์ ํ์ง ๋ชปํ ๊ฒฝ์ฐ์ ์ผ์ด์ค๋ ์์ธ ๋ฉ์์ง๋ฅผ ๋ค๋ฅด๊ฒ ๊ฐ๋๊ฒ ์ข์ ๊ฒ ๊ฐ์๋ฐ ์ด๋ป๊ฒ ์๊ฐํ์๋์? |
@@ -0,0 +1,45 @@
+package nextstep.security.config;
+
+import nextstep.security.ProviderNotFoundException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ProviderManager implements AuthenticationManager {
+
+ private List<AuthenticationProvider> providers = Collections.emptyList();
+
+ p... | Java | parent๋ฅผ ๊ฐ์ง๊ณ ์๋ ์ด์ ๋ ํ์ฌ ProviderManager์์ ์ฒ๋ฆฌํ ์ ์์ ๊ฒฝ์ฐ, parent์ ์์ํ๋ ๊ณ์ธตํ ๊ตฌ์กฐ๋ฅผ ์ง์ํ๊ธฐ ์ํด ์ ๋ฌํ ์ค๊ณ๊ฐ ๋ ๊ฒ ๊ฐ์์ ใ
ใ
|
@@ -0,0 +1,45 @@
+package nextstep.security.config;
+
+import nextstep.security.ProviderNotFoundException;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ProviderManager implements AuthenticationManager {
+
+ private List<AuthenticationProvider> providers = Collections.emptyList();
+
+ p... | Java | copyDetails ๋ด๋ถ์์ AbstractAuthenticationToken ํ์
์ ์ฒดํฌํ๋ ๊ฒ์ ๊ฐ์ฒด์งํฅ ์์น(SOLID) ์ค ๊ฐ๋ฐฉํ์ ์์น์ ๋ฆฌ์ค์ฝํ ์นํ ์์น์ ์๋ฐฐ๋ ๊ฐ๋ฅ์ฑ์ด ์์ด ๋จ๊ธด ์ฝ๋ฉํธ์๋๋ฐ์.
ProviderManager๋ ์ธ์ฆ ํ๋ก์ธ์ค๋ฅผ ๊ด๋ฆฌํ๋ ์ญํ ์ด๋ผ๋ฉด, ํน์ ๊ตฌํ์ฒด์ ์์กดํ์ง ์๋ ๊ฒ์ด ๋ ์ข์ ์ค๊ณ์ผ ๊ฒ ๊ฐ์๋ฐ ์ด๋ป๊ฒ ์๊ฐํ์๋์?
๋ด๋ถ์์ ํ์
์ ์ฒดํฌํ์ง ์๊ณ ์ธ์ฆ ํ๋ก์ธ์ค๋ฅผ ๊ด๋ฆฌํ๋ ์ญํ ๊น์ง ๊ฐ์ ธ๊ฐ ์ ์๋๋ก ํด๊ฒฐํ ๋ฐฉ๋ฒ์ด ์์์ง ๊ณ ๋ฏผํด๋ณด๋ฉด ์ข๊ฒ ์ต๋๋ค! |
@@ -0,0 +1,85 @@
+package nextstep.security.filter;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.h... | Java | > ํ๊ฐ์ง ์ดํด๊ฐ ์๋๋๊ฒ ์๋๋ฐ, ๋ง์ง๋ง์ BasicAuthentication๊ณผ UsernamePasswordAuthentication์ด ์์๋, ์ธ์
์ด ์๋ค๋ฉด BasicAuthentication์์ ์ธ์ฆํ ํ์๊ฐ ์๋๋ก ๊ตฌ์กฐ๋ฅผ ๋ฐ๊ฟ์ผํ๋๊ฒ ๋ง์๊น์?
์คํ๋ง ์ํ๋ฆฌํฐ๋ฅผ ๊ตฌํํ๋ฉฐ ํ์ตํ๊ณ ์๊ธฐ ๋๋ฌธ์ ์คํ๋ง ์ํ๋ฆฌํฐ ๊ตฌ์กฐ๊ฐ ๊ธฐ์ค์ ์ด ๋๊ธด ํ๋๋ฐ์.
์คํ๋ง ์ํ๋ฆฌํฐ๊ฐ ์ ๋ต์ด๋ผ๋ ํ์์ ๋ฒ์ด๋ ์ง์ ์ค๊ณ๋ฅผ ๊ณ ๋ฏผํด๋ณด๋ฉด ๋ ์๋ฏธ ์๋ ํ์ต์ด ๋ ๊ฒ ๊ฐ์์!
์ธ์
์ด ์์ ๋ ์ธ์ฆ์ ํ๋ค๋ฉด ์ด๋ ํ ์ฅ์ ์ด ์๊ณ , ํญ์ ์ํํ๋ฉด ์ด๋ค ์ฅ์ ์ด ์์์ง ๊ณ ๋ฏผ ํ ์คํธ๋์ ์ค... |
@@ -0,0 +1,29 @@
+package nextstep.security.config;
+
+import nextstep.security.AuthenticationException;
+
+public interface AuthenticationProvider {
+
+ /**
+ * AuthenticationManager์ authenticate ๋ฉ์๋์ ๊ฐ์ contract์ผ๋ก ์ธ์ฆ ์ํ
+
+ * @param authentication : ์ธ์ฆ ์์ฒญ ๊ฐ์ฒด
+ * @return credential์ ํฌํจํ ์์ ํ authenticat... | Java | > provider manager์์ ์ support ํ ๋ ๋ฆฌํ๋ ์
์ ํตํ ํด๋์ค ์ ๋ณด๋ฅผ ๋๊ธธ๊น์?
instanceof๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ ์์ ๊ด๊ณ์์ ํ์ธ์ด ์ด๋ ต๊ณ , ํ์
์ ์ฒดํฌํ๊ธฐ ์ํด์ ๋ฌด์กฐ๊ฑด ๊ฐ์ฒด๊ฐ ์์ฑ๋์ด์ผ ํ๊ธฐ ๋๋ฌธ์ ํด๋์ค ์ ๋ณด๋ก ํ์ธํ๋ ๊ฒ์ด ๋ ์ ์ฐํ ์ค๊ณ๋ก ๋ณด์ฌ์ง๋ค์! |
@@ -0,0 +1,94 @@
+package nextstep.app.config;
+
+import jakarta.servlet.Filter;
+import nextstep.app.domain.Member;
+import nextstep.app.domain.MemberRepository;
+import nextstep.security.UserDetailService;
+import nextstep.security.UserDetails;
+import nextstep.security.config.AuthenticationManager;
+import nextstep.... | Java | > Spring์์ ๊ด๋ฆฌํ๋ ํํฐ (Security filter)์ ๊ฒฝ์ฐ GenericFilterBean์ด๋ OncePerRequestFilter๊ฐ์๊ฑธ ์ฌ์ฉํ๋๋ฐ ์ด๊ฑด ์คํ๋ง ์์กด์ฑ์ ๊ฐ์ง๊ณ ์์ด Filter๋ฅผ implementํ๋๊ฒ๋ณด๋ค bean์ ๋ํ ์ถ๊ฐ์ ์ธ ์ ๋ณด ๋ฑ์ ๊ฐ์ ธ์ฌ ์ ์๋๋ผ๊ณ ์.
๊ถ๊ธํ๊ฒ, delegatingFilterproxy๋ tomcat์ ๋ฑ๋ก๋๋ filter๋ผ GenericFilterBean๋ฅผ ์ฌ์ฉํ๋๊ฒ ์๋ฏธ๊ฐ ์์ด ๋ณด์ด๋๋ฐ,
filterchainproxy์ virtualfilterchain์ ํ๊ณ ์ด๋ป๊ฒ ์คํ๋ง๊ณผ ์ด์ด์ง๋ ๊ทธ ๊ฒฝ๊ณ๊ฐ ๊ถ๊ธํฉ... |
@@ -0,0 +1,32 @@
+package nextstep.security.config;
+
+import nextstep.security.UserDetails;
+
+import java.security.Principal;
+
+// Implementations which use this class should be immutable.
+public abstract class AbstractAuthenticationToken implements Authentication{
+
+ private Object details;
+
+ @Override
+... | Java | ์ง๊ธ์ config ํจํค์ง์ ๋๋ฌด ๋ง์ ์ ๋ณด๊ฐ ๋ชจ์ฌ์๋๋ฐ, ์๋ฏธ์๋ ์ปจํ
์คํธ๋ฅผ ๋ฌถ์ด๋ณด๋ฉด ์ด๋จ๊น์? |
@@ -0,0 +1,46 @@
+package nextstep.security.config;
+
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import... | Java | OncePerRequestFilter๊ฐ ์๋ GenericFilterBean๋ก ๊ตฌํํด์ฃผ์ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,46 @@
+package nextstep.security.config;
+
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import... | Java | ์ง๊ธ์ SecurityContextRepository๊ฐ ์ธํฐํ์ด์ค๋ก ๋ถ๋ฆฌ๋์ด ์์ง๋ง, ๋ด๋ถ์์ ์ด๊ธฐํํ๊ณ ์๊ธฐ ๋๋ฌธ์ ํ์ฅ์ฑ์ด ๋จ์ด์ง๋ ๊ตฌ์กฐ๋ค์.
์ด๋ป๊ฒ ํ์ฅ์ด ๊ฐ๋ฅํ ๊ตฌ์กฐ๋ก ๋ง๋ค ์ ์์๊น์? |
@@ -0,0 +1,82 @@
+package nextstep.security.filter;
+
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.h... | Java | ํด๋น ํํฐ์์ SecurityContextRepository์ ๋ํ ์์กด์ฑ์ ๊ฐ์ง๊ณ ์๋๋ฐ์.
SecurityContextRepository์ ๊ด๋ จ๋ ์ญํ ์ ํ Filter๋ก ๋ชจ์์ ์ฒ๋ฆฌํ ์ ์์ผ๋ฉด ์ฝ๋์ ์์ง๋๊ฐ ๋์์ง ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,49 @@
+package christmas.domain;
+
+import christmas.error.ErrorCode;
+import java.util.Arrays;
+
+public enum MenuItem {
+
+ ์์ก์ด์คํ(6_000, "์์ก์ด์คํ", MenuCategory.Appetizers),
+ ํํ์ค(5_500, "ํํ์ค", MenuCategory.Appetizers),
+ ์์ ์๋ฌ๋(8_000, "์์ ์๋ฌ๋", MenuCategory.Appetizers),
+ ํฐ๋ณธ์คํ
์ดํฌ(55_000, "ํฐ๋ณธ์คํ
์ดํฌ", ... | Java | MenuItem์ enum์ผ๋ก ๋ง๋๋ ๋ฐฉ์์ด ์ข์๋ณด์ฌ์! |
@@ -0,0 +1,69 @@
+package christmas.domain.benefit;
+
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import java.time.LocalDate;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+
+public enum BenefitCategory {
+
+ ํ์ผํ ์ธ("ํ์ผํ ์ธ", 2_023, input -> {
+
+ L... | Java | enum ํด๋์ค ๋ด๋ถ์ ๋ก์ง์ด ๋ง์ผ๋ฉด ๋๋ฌด ๋ณต์กํ์ง๋ ์์๊น์? |
@@ -0,0 +1,69 @@
+package christmas.domain.benefit;
+
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import java.time.LocalDate;
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Function;
+
+public enum BenefitCategory {
+
+ ํ์ผํ ์ธ("ํ์ผํ ์ธ", 2_023, input -> {
+
+ L... | Java | ์ฆ์ ์ด๋ฒคํธ๋ ๋ ์ง์๋ ๊ด๋ จ์ด ์๋ ์ด๋ฒคํธ๋ผ function์ด ๋ฐ๋ก ์ฌ์ฉ๋์ง ์๋ค์.
์ฆ์ ์ด๋ฒคํธ๋ ์ด ํด๋์ค์์ ์ฒ๋ฆฌํ๋๊ฒ ์ข์๊ฐ์? |
@@ -0,0 +1,40 @@
+package christmas.domain.benefit;
+
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import christmas.domain.benefit.benefitItems.BenefitItem;
+import christmas.domain.benefit.benefitItems.ChristmasBenefit;
+import christmas.domain.benefit.benefitItems.GiftBenefit;
+import christmas... | Java | ํฉํ ๋ฆฌ ํจํด์ ์ฌ์ฉํ์ ๊ฒ ๊ฐ์๋ฐ ์ฌ๊ธฐ์ ํฉํ ๋ฆฌ ํจํด์ ์ฌ์ฉํ๋ฉด ์ด๋ค ์ด์ ์ ์ป์ ์ ์๋์ง ๊ถ๊ธํฉ๋๋ค! |
@@ -0,0 +1,40 @@
+package christmas.domain.benefit;
+
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import christmas.domain.benefit.benefitItems.BenefitItem;
+import christmas.domain.benefit.benefitItems.ChristmasBenefit;
+import christmas.domain.benefit.benefitItems.GiftBenefit;
+import christmas... | Java | ๊ตฌํ ์กฐ๊ฑด์ switch ๋ฌธ์ ์ฌ์ฉ ๊ธ์ง๋ผ๊ณ ๋์ด ์์ด์...
if๋ฌธ์ผ๋ก ์ถฉ๋ถํ ๋ฐ๊ฟ ์ ์์ด ๋ณด์ฌ์ ํฌ๊ฒ ์ค์ํ์ง ์์ ๊ฒ ๊ฐ์์ |
@@ -0,0 +1,54 @@
+package christmas.domain.benefit;
+
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import christmas.domain.benefit.benefitItems.BenefitItem;
+import java.util.List;
+
+public class Benefits {
+
+ public static final int GIFT_PRICE = 25_000;
+ private List<BenefitItem> benefi... | Java | ์ฆ์ ์ด๋ฒคํธ์ ํ ์ธ ๊ธ์ก์ ์ฌ์ฉ์์๊ฒ ๋ณด์ฌ์ฃผ๊ธฐ๋ง ํ๊ณ ์์ ๊ฒฐ์ ๊ธ์ก์๋ ์ ์ฉ๋์ง ์๊ธฐ ๋๋ฌธ์ ์ฌ๊ธฐ์ ์ฒ๋ฆฌํด ์ฃผ๋๊ฒ ์ข์ ๋ฐฉ๋ฒ ๊ฐ์์! |
@@ -0,0 +1,21 @@
+package christmas.domain.benefit.benefitItems;
+
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import christmas.domain.benefit.BenefitCategory;
+
+public class ChristmasBenefit extends BenefitItem {
+
+ public ChristmasBenefit(BenefitCategory benefitCategory, int discountPrice... | Java | 1000์ ๋งค์ง ๋๋ฒ๋ก ์ฌ์ฉํด์ค๋ ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,65 @@
+package christmas.io;
+
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import christmas.error.ErrorCode;
+import java.util.function.Supplier;
+
+public class InputView implements AutoCloseable {
+
+ private final Reader DEFAULT_READER = new ConsoleReader();
+ private final R... | Java | ๋ค์ ์
๋ ฅ ๋ฐ๋ ๋ฉ์๋๋ฅผ ์ ๋ค๋ฆญ๊ณผ ์ํ๋ผ์ด์ด๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌํํ๋ ๋ฐฉ์์ด ์ข์๋ณด์ฌ์! |
@@ -0,0 +1,80 @@
+package christmas.io;
+
+import christmas.domain.benefit.Benefits;
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import christmas.domain.OrderItem;
+import java.text.DecimalFormat;
+import java.time.LocalDate;
+import java.util.List;
+
+public class OutputView {
+
+ public sta... | Java | DecimalFormat ์ด๋ผ๋ ๊ฒ๋ ์๊ตฐ์...
๋ ์ฐพ์๋ด์ผ๊ฒ ์ด์ |
@@ -0,0 +1,80 @@
+package christmas.io;
+
+import christmas.domain.benefit.Benefits;
+import christmas.domain.Calender;
+import christmas.domain.Order;
+import christmas.domain.OrderItem;
+import java.text.DecimalFormat;
+import java.time.LocalDate;
+import java.util.List;
+
+public class OutputView {
+
+ public sta... | Java | ์ดํํ ๊ธ์ก์ด 0์ผ ๊ฒฝ์ฐ -0์ผ๋ก ์ถ๋ ฅ๋ ์๋ ์์ง ์์๊น์? |
@@ -0,0 +1,44 @@
+package christmas.domain;
+
+import christmas.error.ErrorCode;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class Order {
+
+ private final String DELIMITER = ",";
+ private final List<OrderItem> orderItems;
+
+ public... | Java | ๋ฉ๋ด๋ ํ ๋ฒ ์ต๋ 20๊ฐ๊น์ง๋ง ์ฃผ๋ฌธํ ์ ์๋๋ฐ ์ด ๋ถ๋ถ์ ๊ฒ์ฆํ๋ ๊ณณ์ด ์์๊น์?
์ด์ฃผ๋ฌธ ๊ธ์ก 10000์ ์ด์๋ถํฐ ์ด๋ฒคํธ๊ฐ ์ ์ฉ๋๋ ๋ถ๋ถ, ์๋ฃ๋ง ์ฃผ๋ฌธ ์ ์ฃผ๋ฌธ์ด ๋ถ๊ฐ๋ฅํ ๊ฒ์ ์ฒดํฌํด์ฃผ๋ ๋ถ๋ถ์ด ์๋์? |
@@ -0,0 +1,32 @@
+import * as S from './Header.styled';
+
+interface HeaderProps extends React.InputHTMLAttributes<HTMLInputElement> {
+ searchKeyword: string;
+ onSearch: (keyword: string) => void;
+}
+
+function LargeHeader({ searchKeyword, onSearch, ...rest }: HeaderProps) {
+ return (
+ <S.Layout>
+ <a h... | Unknown | ๋ผ์ฐํ
์ด ๋ฐ๋ก ํ์ํ์ง ์์์ a ํ๊ทธ๋ก ๋์ฒดํฉ๋๋ค! |
@@ -0,0 +1,20 @@
+import { DISPLAY_SIZE } from '../../../constants/displaySize';
+import LargeHeader from './LargeHeader';
+import MobileHeader from './MobileHeader';
+
+interface HeaderProps {
+ searchKeyword: string;
+ onSearch: (keyword: string) => void;
+}
+
+function Header({ searchKeyword, onSearch }: HeaderPro... | Unknown | HTMLInputElement๋ฅผ ์์๋ฐ์ผ๋ฉด์ rest props๋ฅผ ๋๊ฒจ์ฃผ๊ณ ์์ง๋ง ํ์ฌ๋ก์๋ ์ด ๊ธฐ๋ฅ๋ค์ ํ์ฉํ๊ณ ์๋ ๊ฒ ๊ฐ์ง ์์์. ๊ทธ๋ฆฌ๊ณ ๋ณดํต ์ด๋ฐ ํจํด์ ๊ณตํต ์ปดํฌ๋ํธ์์ ๋ง์ด ์ฌ์ฉํ๋๋ฐ, ์ ํค๋๋ common์ ๋ค์ด์๊ธฐ๋ ํ์ง๋ง ํน์ ๋์์ธ๊ณผ ๊ตฌํ์ ํนํ๋ ๊ฒ ๊ฐ์์ ์ด๋ ๊ฒ ํ์ฅ์ฑ์ ์ด์ด๋ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค!
+ common ํด๋์๋ง _๊ฐ ๋ถ์ด์๋๋ฐ ์ฒ์ ๋ณด๋ ์ปจ๋ฒค์
์ด๋ผ ์ด๋ค ์๋ฏธ์ธ์ง๋ ๊ถ๊ธํด์ ใ
ใ
|
@@ -0,0 +1,58 @@
+import React, { useReducer } from 'react';
+import * as S from './Header.styled';
+
+interface HeaderProps extends React.InputHTMLAttributes<HTMLInputElement> {
+ searchKeyword: string;
+ onSearch: (keyword: string) => void;
+}
+
+type State = boolean;
+type Action = { type: 'TOGGLE' } | { type: 'OP... | Unknown | ์ค input์ด ์ด์ฐจํผ ๋๋ณด๊ธฐ ํด๋ฆญ ์ ์๋ ์ด๋ฆฌ์ง ์์์ ๋์น๊ธฐ ์ฌ์ ์ํ
๋ฐ ๊ผผ๊ผผํ๊ฒ disabled๊น์ง ์ฑ๊ฒจ์ฃผ์
จ๋ค์! ๐
์ด๋ ๊ฒ UI์์ input์ด ์ฌ์ฉ ๋ถ๊ฐ๋ฅํ ๋ disabled๋ฅผ ๋ช
์ํด์ค ์ด์ ๊ฐ ๊ถ๊ธํด์. ์ ๋ UI์ ์ฝ๋์ ์ผ์น + ๋ถํ์ํ DOM ์กฐ์ ๋ฐฉ์ง ์ ๋๋ก ์๊ฐํ๋๋ฐ ๋ง๋์ฉ? |
@@ -0,0 +1,58 @@
+import React, { useReducer } from 'react';
+import * as S from './Header.styled';
+
+interface HeaderProps extends React.InputHTMLAttributes<HTMLInputElement> {
+ searchKeyword: string;
+ onSearch: (keyword: string) => void;
+}
+
+type State = boolean;
+type Action = { type: 'TOGGLE' } | { type: 'OP... | Unknown | Action์ ๊ฐ์ฒด๋ก ๋ง๋ ์ด์ ๋ ํ์ฅ์ฑ ๋๋ฌธ์ผ๊น์? ์ ๋ผ๋ฉด ๊ฐ๋จํ ํ๋ก๊ทธ๋จ์์๋ ๋จ์ ๋ฌธ์์ด union ํ์
์ผ๋ก ๋ง๋ค์์ ๊ฒ ๊ฐ๋ค์ ใ
ใ
ใ
|
@@ -0,0 +1,58 @@
+import React, { useReducer } from 'react';
+import * as S from './Header.styled';
+
+interface HeaderProps extends React.InputHTMLAttributes<HTMLInputElement> {
+ searchKeyword: string;
+ onSearch: (keyword: string) => void;
+}
+
+type State = boolean;
+type Action = { type: 'TOGGLE' } | { type: 'OP... | Unknown | useReducer๋ฅผ ์ค์ ๋ก ์ฐ๋ ์ฝ๋๋ ์ฒ์ ๋ณด๋ค์! ๋งค์ผ useState๋ง ์๊ฐํ๋๋ฐ ๋ฆฌํ๋ ์๊ฐ ๋๋๊ตฐ์ใ
ใ
ใ
๋ค๋ง ์ง๊ธ action ์ค์์ ์ค์ง์ ์ผ๋ก ์ฌ์ฉํ๋ ๋์์ TOGGLE๋ฟ์ธ ๊ฒ ๊ฐ์๋ฐ OPEN๊ณผ CLOSE๊ฐ ๋ช
์๋ ์ด์ , ๋ฆฌ๋์๋ฅผ ์ฌ์ฉํ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค~~ |
@@ -0,0 +1,81 @@
+import styled from 'styled-components';
+import media from '../../../styles/mediaQueries';
+
+export const Layout = styled.header`
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 1rem;
+
+ position: relative;
+
+ width: 100%;
+ height: 6rem;
+ padding: 0.8rem 3... | TypeScript | ํ๊ทธ๊ฐ header๋ฉด ๋ ์ข์ ๊ฒ ๊ฐ์์~! |
@@ -0,0 +1,52 @@
+import React, { Suspense, useEffect, useState } from 'react';
+import { createPortal } from 'react-dom';
+import * as S from './Modal.styled';
+import useEscapeKey from '../../../hooks/useEscapeKey';
+import ModalBackdrop from './ModalBackdrop';
+import SkeletonModal from '../Skeleton/SkeletonModal';
... | Unknown | ์ด๋ค ํจ๊ณผ์์๊น์?! |
@@ -0,0 +1,23 @@
+import Title from '../../_common/Title/Title';
+import MovieList from '../MovieList/MovieList';
+import * as S from '../Movie.styled';
+
+interface ContentProps {
+ searchKeyword: string;
+}
+
+function Content({ searchKeyword }: ContentProps) {
+ const titleContent =
+ searchKeyword.length > 0
+... | Unknown | ์ค ์์์ searchKeyword ๊ฐ์ ๋ฐ์์ค๋ ๋๋ฐ์ด์ค๋ฅผ ๊ฑธ์ด์ ์ ๊ฐ์ ๋ฐ์์ค๋๊ตฐ์ฉ
๊ทธ๋ฐ๋ฐ ๋๋ฐ์ด์ค ์ฒ๋ฆฌ๋ฅผ searchKeyword๋ฅผ ์์ ํ ๋ถ๋ชจ ์ปดํฌ๋ํธ๊ฐ ์๋๋ผ Content์์ ํด ์ฃผ๋ ์ด์ ๊ฐ ์๋์?
๋๋ฐ์ด์ค ๋ก์ง์ด Content๋ฅผ ๊ฑฐ์ณ์ผ ๋์ค๋ ์ํฉ์ด ์๋๋ผ์ ๋ถ๋ชจ ์ปดํฌ๋ํธ๊ฐ ๋ด๋นํ๋ ๊ฒ ์กฐ๊ธ ๋ ๋ซ๋ค๋ ์๊ฐ์
๋๋ค. (Single Source of Truth ๋ฉด์์)
๋ ์ญํ ์ ์ง๊ด์ ์ผ๋ก ๋๋ ๋ณผ ๋๋ debounce ์ฑ
์์ ๊ฒ์์ฐฝ ์ชฝ์์ ๋ด๋นํ๊ณ Content๋ ๊ทธ ๊ฐ์ ๋ฐ์์ ์ฐ๊ธฐ๋ง ํ๋ ๊ฒ ์์ฐ์ค๋ฌ์ ๋ณด์ธ๋ค๊ณ ์๊ฐํด์~! |
@@ -0,0 +1,59 @@
+import { useState } from 'react';
+import { useModalContext } from '../../../contexts/ModalContext';
+import Modal from '../../_common/Modal/Modal';
+import * as S from '../Movie.styled';
+import MovieDetail from '../MovieDetail/MovieDetail';
+import MovieItem from '../MovieItem/MovieItem';
+import Fe... | Unknown | id ๊ฐ์ ๊ด๋ฆฌํ๋๊น ๋ณ์๋ช
์์๋ ๋ช
ํํ๊ฒ Id์์ด ๋๋ฌ๋๋ฉด ์ข๊ฒ ์ด์! |
@@ -0,0 +1,131 @@
+import axios from 'axios';
+import { API_URL, TMDB_URL } from './constant';
+import { Movie, MovieDetail } from '../types/movie.type';
+
+interface GetPopularMoviesResponse {
+ page: number;
+ results: Movie[];
+ total_pages: number;
+ total_results: number;
+}
+
+export const getPopularMovies = ... | TypeScript | axios๋ ๊ฑฐ์ ๋ฐ๋
๋ง์ ๋ณด๋ค์...ใ
ใ
ใ
ใ
ใ
ใ
ํ์คํ fetch ์ฝ๋๊ฐ ๋ ๊ฐ๊ฒฐํด์ง๋๊ตฐ์
page๋ฅผ ๋ณด๋ผ ๋ String()์ด ์๋๋ผ ํ
ํ๋ฆฟ ๋ฆฌํฐ๋ด์ ์ฌ์ฉํ ๊ฒ ๋์ ๋๋ค์! |
@@ -0,0 +1,136 @@
+import styled from 'styled-components';
+import media from '../../../styles/mediaQueries';
+
+export const Layout = styled.div`
+ width: 100%;
+ height: 100%;
+`;
+
+// Text
+
+export const TitleText = styled.p`
+ ${({ theme }) => theme.font.body};
+ text-align: center;
+`;
+
+export const Captio... | TypeScript | ์ ๋ ํญ์ ์คํ์ผ๋ง ๋์์ด ๋๋ ์์์ ๊ธฐ๋ฅ๋ง ์๊ฐํด์ styled component์ ์ด๋ฆ์ ์ง์๋๋ฐ ์ ์ฉํ ์คํ์ผ๋ก ์ด๋ฆ์ ๋ถ์ด๋๊น ๋ ์ง๊ด์ ์ด๊ณ ํธํ๋ค์ ๐ ์ ์ด ์๊ฐ์ ๋ชป ํ์ง?! |
@@ -0,0 +1,136 @@
+import styled from 'styled-components';
+import media from '../../../styles/mediaQueries';
+
+export const Layout = styled.div`
+ width: 100%;
+ height: 100%;
+`;
+
+// Text
+
+export const TitleText = styled.p`
+ ${({ theme }) => theme.font.body};
+ text-align: center;
+`;
+
+export const Captio... | TypeScript | ์๊ธฐ overflow-y ์์ฑ์ด ์์ด์ผ ํ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,59 @@
+import { useState } from 'react';
+import { useModalContext } from '../../../contexts/ModalContext';
+import Modal from '../../_common/Modal/Modal';
+import * as S from '../Movie.styled';
+import MovieDetail from '../MovieDetail/MovieDetail';
+import MovieItem from '../MovieItem/MovieItem';
+import Fe... | Unknown | queries๋ฅผ ๊ฐ์ฒด๋ก ๋ง๋ค๊ณ key๋ฅผ name์ผ๋ก ํ๋ฉด ์ด๋ค ๋ฆฌ์์ค๋ฅผ ์ํ ์ฟผ๋ฆฌ์ธ์ง ๋ ์ ๋๋ฌ๋ ๊ฒ ๊ฐ์์~ ๊ทผ๋ฐ ๊ฐ์ฒด๋ผ์ ์ฝ๋๊ฐ ์ข ๋ ๋ณต์กํด์ง๊ฒ ๋ค์ ๐ |
@@ -0,0 +1,59 @@
+import { useState } from 'react';
+import { useModalContext } from '../../../contexts/ModalContext';
+import Modal from '../../_common/Modal/Modal';
+import * as S from '../Movie.styled';
+import MovieDetail from '../MovieDetail/MovieDetail';
+import MovieItem from '../MovieItem/MovieItem';
+import Fe... | Unknown | ์ต์ ๋ฒ ๊ด๋ จ ๋์์ ๋ณ๋์ ํ
์ผ๋ก ๋ถ๋ฆฌํ๋ฉด ์ฝ๋๊ฐ ๋ ๊ฐ๊ฒฐํด์ง ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,59 @@
+import { useState } from 'react';
+import { useModalContext } from '../../../contexts/ModalContext';
+import Modal from '../../_common/Modal/Modal';
+import * as S from '../Movie.styled';
+import MovieDetail from '../MovieDetail/MovieDetail';
+import MovieItem from '../MovieItem/MovieItem';
+import Fe... | Unknown | ์ค์น ์ด ๋ฐฉ์ ๊น๋ํ๊ณ ์ข๋ค์ ๐๐ ๋ฆฌํฉํ ๋งํ๋ฌ ๊ฐ์ผ๊ฒ ... ๐ |
@@ -0,0 +1,6 @@
+import styled from 'styled-components';
+
+export const Layout = styled.div`
+ width: 100%;
+ height: 10vh;
+`; | TypeScript | ํฌ๊ธฐ ์ ์ ๊ธฐ์ค์ด ๊ถ๊ธํด์! |
@@ -0,0 +1,29 @@
+import { Movie } from '../../../types/movie.type';
+import * as S from '../Movie.styled';
+
+interface MovieItemProps {
+ movie: Movie;
+ onClick: (movieId: number) => void;
+}
+
+function MovieItem({ movie, onClick }: MovieItemProps) {
+ return (
+ <li key={movie.id} onClick={() => onClick(movi... | Unknown | ์ฌ๊ธฐ์๋ ์์์ ๋ณด์ ์ ํด์ผ ํ ๊ฒ ๊ฐ์์ |
@@ -0,0 +1,112 @@
+import { TMDB } from '../../../constants/url';
+import useMovie from '../../../queries/useMovie';
+import useRating from '../../../queries/useRating';
+import useUpdateStars from '../../../queries/useUpdateStars';
+import * as S from './MovieDetail.styled';
+
+interface MovieDetailProps {
+ movieId:... | Unknown | ์ ๊ทผ์ฑ์ ์ํด button ํ๊ทธ๋ก ๊ฐ์ธ๋ ๊ฒ ์ข์ ๊ฒ ๊ฐ์๋ฐ ์๊ฐ์์ ์ด์ ๋ก img์ ๋ฐ๋ก onClick์ด ๋ถ์ ๊ฑธ๊น์?
๊ทธ๋ฆฌ๊ณ StarImageVoteBox ์ดํ ์ปดํฌ๋ํธ๋ค์ ๋ณ๋๋ก ๋ถ๋ฆฌํ์ง ์์ ์ด์ ๊ฐ ๊ถ๊ธํฉ๋๋ค(Content์์ ๋ ๊ฐ๋จํ ์ปดํฌ๋ํธ์ธ Title์ ๋ถ๋ฆฌ๋์ด ์๊ธธ๋์~!) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.