code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,40 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import nextstep.security.core.Authentication;
+imp... | Java | BasicAuthenticationFilter 필터를 생성할 때 UserDetailsService 대신 AuthenticationManager를 주입 받으면 어떨까요? |
@@ -0,0 +1,35 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Map;
+import nextstep.security.core.Authentication;
+import nextstep.s... | Java | 여기도 마찬가지로 UserDetailsService 대신 AuthenticationManager를 주입 받으면 어떨까요? |
@@ -0,0 +1,40 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import nextstep.security.core.Authentication;
+imp... | Java | Authentication 생성의 책임을 별도의 클래스로 분리해보면 어떨까요? |
@@ -0,0 +1,40 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import nextstep.security.core.Authentication;
+imp... | Java | convert 메서드는 Token으로 변환해주는 역할만 하면 어떨까요? |
@@ -0,0 +1,35 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Map;
+import nextstep.security.core.Authentication;
+import nextstep.s... | Java | 시큐리티의 실제 코드를 살펴보면 인증 필터에서 중복되는 부분을 AbstractAuthenticationProcessingFilter로 분리되어있습니다! UsernamePasswordAuthenticationFilter에서 해당 부분을 분리해보는 시도를 해보시면 어떨까요?
필수 요구사항은 아니지만 빠르게 미션을 잘 해주셨고 선택 요구사항으로 3주차 미션 수행에 도움이 될 것 같아서 제안드려요~ |
@@ -0,0 +1,40 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import nextstep.security.core.Authentication;
+imp... | Java | 기존 구조에서 계속 발전시켜 나가다 보니 미처 신경쓰지 못한것 같습니다 😂
구체가 아닌 추상에 의존해야 한다는걸 상기시켜주셔서 감사합니다 👍 |
@@ -0,0 +1,35 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Map;
+import nextstep.security.core.Authentication;
+import nextstep.s... | Java | 마찬가지로 [fa5f619](https://github.com/next-step/spring-security-authentication/pull/33/commits/fa5f61942bfba0e2f794bb43c5b86af416c679b8) 커밋으로 반영했습니다! |
@@ -0,0 +1,40 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import nextstep.security.core.Authentication;
+imp... | Java | [81fa490](https://github.com/next-step/spring-security-authentication/pull/33/commits/81fa490d0c5ef702821a1b226a17c3363bb5131a)로 반영했습니다! |
@@ -0,0 +1,40 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import nextstep.security.core.Authentication;
+imp... | Java | DRY 위반도 겸하고 있었네요!
클래스 분리하고 보니 기존 메서드에 책임이 과도했고, 필요치 않은 더블체크가 들어갔다는게 바로 확인되어서 좋았습니다! |
@@ -0,0 +1,35 @@
+package nextstep.security.authentication;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Map;
+import nextstep.security.core.Authentication;
+import nextstep.s... | Java | [dbde31c](https://github.com/next-step/spring-security-authentication/pull/33/commits/dbde31cb10aee34fe4e1c767064389589b2fa2ba)로 시도해 보았습니다!
실제 코드를 분석하면서 흥미로웠던점은
SecurityContextRepository.saveContext() 호출을
SecurityContextHolderFilter가 아닌 AbstractAuthenticationProcessingFilter에서 해주고 있다는 점이었는데요.
 {
+ checkSizeValid(lottoNums);... | Java | final 로 선언하신 이유가 궁금합니다~ |
@@ -0,0 +1,57 @@
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class Lotto {
+ private final static int LOTTO_NUM_SIZE = 6;
+ private final List<LottoNo> lottoNums;
+
+ public Lotto(List<LottoNo> lottoNums) {
+ checkSizeValid(lottoNums);... | Java | check 메서드들이 public 인 이유가 있나요~? |
@@ -0,0 +1,57 @@
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class Lotto {
+ private final static int LOTTO_NUM_SIZE = 6;
+ private final List<LottoNo> lottoNums;
+
+ public Lotto(List<LottoNo> lottoNums) {
+ checkSizeValid(lottoNums);... | Java | java 8 의 stream map 을 써보면 어떨까요? |
@@ -0,0 +1,57 @@
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class Lotto {
+ private final static int LOTTO_NUM_SIZE = 6;
+ private final List<LottoNo> lottoNums;
+
+ public Lotto(List<LottoNo> lottoNums) {
+ checkSizeValid(lottoNums);... | Java | 접근제어자를 package-private 으로 하신 이유가 있을까요? |
@@ -0,0 +1,57 @@
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class Lotto {
+ private final static int LOTTO_NUM_SIZE = 6;
+ private final List<LottoNo> lottoNums;
+
+ public Lotto(List<LottoNo> lottoNums) {
+ checkSizeValid(lottoNums);... | Java | Set<LottoNo> 로 선언하는 것은 어떻게 생각하시나요~ |
@@ -0,0 +1,46 @@
+import java.util.Objects;
+
+public class LottoNo implements Comparable<LottoNo> {
+ private final static int INVALID_NUM = 0;
+ public final static LottoNo INVALID_LOTTO_NO = new LottoNo(INVALID_NUM);
+
+ private int lottoNumber;
+
+ public LottoNo(int lottoNumber) {
+ try {
+ ... | Java | LottoNo 는 변경되지 않는 lottoNumber 하나를 가지고 있어야하므로
final 키워드를 넣어도 될 것 같네요 ㅎㅎ |
@@ -0,0 +1,46 @@
+import java.util.Objects;
+
+public class LottoNo implements Comparable<LottoNo> {
+ private final static int INVALID_NUM = 0;
+ public final static LottoNo INVALID_LOTTO_NO = new LottoNo(INVALID_NUM);
+
+ private int lottoNumber;
+
+ public LottoNo(int lottoNumber) {
+ try {
+ ... | Java | 음.. RuntimeException 을 발생시키고 catch 를 굳이 하는 이유가 있을까요?
checkedException 과 uncheckedException 에 대해서 공부해보시면 좋을 것 같습니다~ |
@@ -0,0 +1,46 @@
+import java.util.Objects;
+
+public class LottoNo implements Comparable<LottoNo> {
+ private final static int INVALID_NUM = 0;
+ public final static LottoNo INVALID_LOTTO_NO = new LottoNo(INVALID_NUM);
+
+ private int lottoNumber;
+
+ public LottoNo(int lottoNumber) {
+ try {
+ ... | Java | 굳이 메서드로 빼지 않아도 될 것 같아요 |
@@ -0,0 +1,40 @@
+import java.util.ArrayList;
+import java.util.List;
+
+public class LottoRankResult {
+ private List<Rank> ranks;
+
+ public LottoRankResult(WinningLotto winningLotto, LottoTicket lottoTicket) {
+ this.ranks = new ArrayList<>();
+
+ for (Lotto lotto : lottoTicket.getAllLottoGames()... | Java | 뭔가 이름이 결과를 담는 데이터 그릇 같은 느낌이라
LottoCalculator
LottoResultCalculator
LottoRankCalculator
같은 네이밍으로 변경해보면 어떨까요?
그에 맞춰서 메서드 네이밍도 변경하면 단순히 set 된 데이터를 get 하는 것보다
상태와 행위를 갖는 객체지향적인 네이밍이 될 것 같다는 생각이 듭니다 |
@@ -0,0 +1,22 @@
+import java.util.ArrayList;
+import java.util.List;
+
+public class Lottos {
+ private List<Lotto> lottos;
+
+ public Lottos() {
+ this.lottos = new ArrayList<>();
+ }
+
+ public List<Lotto> getLottos() {
+ return lottos;
+ }
+
+ public void addLotto(Lotto lotto) {
+ ... | Java | Lottos 가 가지는 행위가 하나도 없는데요,
다른 객체에서 위임할만한게 없을까요?
get이 사용되고 있다는 것은 Lottos 의 tell dont ask 원칙이 안지켜지고 있다는 뜻이고,
여기로 위임할만한 책임이 산재해 있다는 뜻이기도 합니다. |
@@ -0,0 +1,29 @@
+import java.util.List;
+
+public class WinningLotto {
+ private Lotto winningLotto;
+ private LottoNo bonusNo;
+
+ public WinningLotto(List<LottoNo> winningLottoNumbers, LottoNo lottoNo) {
+ if (winningLottoNumbers == null) {
+ throw new IllegalArgumentException("'lotto' mus... | Java | Lotto를 상속 받을 수도 있었는데 이렇게 합성을 사용하셨네요. 👍
혹시라도 우연히 이렇게 구현하신거라면,
상속과 합성을 구글링 해보시면 관련 자료를 찾으실 수 있을겁니다 ~ |
@@ -0,0 +1,43 @@
+import java.util.Scanner;
+
+public class LottoApplication {
+ private static boolean APP_SUCCESS = false;
+
+ public static void main(String[] args) {
+ runUntilAppSuccess();
+ }
+
+ public static void runUntilAppSuccess() {
+ while (!APP_SUCCESS) {
+ run();
+ ... | Java | LottoGame 이라는 네이밍은 어떨까요 |
@@ -0,0 +1,43 @@
+import java.util.Scanner;
+
+public class LottoApplication {
+ private static boolean APP_SUCCESS = false;
+
+ public static void main(String[] args) {
+ runUntilAppSuccess();
+ }
+
+ public static void runUntilAppSuccess() {
+ while (!APP_SUCCESS) {
+ run();
+ ... | Java | lottoService 에 set 하고 get 하고 절차지향적인 방식으로 코드가 짜여져 있습니다.
모든 로직이 lottoService 를 통하면서 결국 이 클래스는 점점 비대해질텐데요
좋은 개선 방법이 없을까요~? |
@@ -0,0 +1,48 @@
+import java.util.Arrays;
+
+public enum Rank {
+ FIRST(6, 2000000000),
+ SECOND(5, 30000000),
+ THIRD(5, 1500000),
+ FOURTH(4, 50000),
+ FIFTH(3, 5000),
+ MISS(0, 0);
+
+ private int countOfMatch;
+ private Money winningMoney;
+
+ Rank(int countOfMatch, int winningMoney) {
+... | Java | 중괄호가 빠졌습니다 |
@@ -0,0 +1,21 @@
+public class RankResult {
+ private Rank rank;
+ private int countOfRank;
+
+ RankResult(Rank rank) {
+ this.rank = rank;
+ this.countOfRank = 0;
+ }
+
+ public Rank getRank() {
+ return rank;
+ }
+
+ public int getCountOfRank() {
+ return countOfRank;
... | Java | 데이터들을 클래스로 묶는 것이 객체지향은 아닙니다~
RankResult 도 결국 데이터와 get 만 가지고 있고,
유의미한 행위가 없습니다 ㅠㅠ
불필요한 객체가 아닌지, 유의미한 행위를 가진 객체로 만들려면 어떤 행위를 부여해야하는지
고민해보시면 좋을 것 같아요~ |
@@ -0,0 +1,50 @@
+import java.util.List;
+
+public class LottoSeller {
+ private LottoPurchaseService lottoPurchaseService;
+ private Money change;
+
+ public LottoSeller() {
+ change = Money.ZERO;
+ lottoPurchaseService = new LottoPurchaseService();
+ }
+
+ public LottoTicket sellTicketTo(... | Java | Service 라는 네이밍을 쓰시는걸로 봐서
웹 쪽 자료를 보신 것 같은데,
controller, service, repository
이런 layered architecture 는 지금 저희가 하고 있는 객체지향과 거리가 좀 있습니다 ~
service 라는 네이밍을 사용하기보다는 좀 더 구체적이고 누구나 글 읽듯이 볼 수 있는 네이밍을 하시면
해당 객체에 부여하는 책임과 행위들도 달라지게 됩니다 ~
네이밍은 단순히 시각적인 효과 그 이상의 가치를 가지고 있습니다 |
@@ -0,0 +1,50 @@
+import java.util.List;
+
+public class LottoSeller {
+ private LottoPurchaseService lottoPurchaseService;
+ private Money change;
+
+ public LottoSeller() {
+ change = Money.ZERO;
+ lottoPurchaseService = new LottoPurchaseService();
+ }
+
+ public LottoTicket sellTicketTo(... | Java | 점 하나 찍을 때는 줄바꿈을 안하시는게 일반적입니다.
메소드 파라미터도 3개 이상부터 엔터를 치시는게 어떨까요? |
@@ -0,0 +1,42 @@
+import java.util.List;
+
+public class LottoService {
+ LottoUser lottoUser;
+ LottoSeller lottoSeller;
+ LottoTicket purchasedLottoTicket = null;
+ WinningLotto winningLotto = null;
+ PurchaseResultView purchaseResultView = null;
+ WinningResultView winningResultView = null;
+
+ ... | Java | set을 사용하지 않는다는 객체지향 생활체조 규칙을 적용해보시면
코드의 설계가 달라질 것 같습니다 |
@@ -0,0 +1,43 @@
+import java.util.ArrayList;
+import java.util.List;
+
+public class LottoTicket {
+ private Money ticketPrice;
+ private Lottos autoLottos;
+ private Lottos manualLottos;
+
+ public LottoTicket(Money ticketPrice, Lottos autoLottos, Lottos manualLottos) {
+ this.ticketPrice = ticketP... | Java | 여기도 행위가 없고 데이터 + getter 뿐이네요.
그런데 이렇게 클래스를 나눠보려고 최대한 시도하신 점 👍 |
@@ -0,0 +1,35 @@
+import java.util.List;
+
+public class LottoUser {
+ private Money investMoney;
+ private int countOfManualLotto;
+ private List<List<LottoNo>> numbersOfManualLottos;
+
+ private LottoTicket lottoTicket;
+
+ public LottoUser(Money investMoney, int countOfManualLotto, List<List<LottoNo>>... | Java | 여기도 setter getter 뿐 이네요 ㅠ |
@@ -0,0 +1,65 @@
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public final class LottoPurchaseService {
+ public final static Money LOTTO_PRICE = Money.valueOf(1000);
+
+ public static Money validatePurchase(Money inputMoney, int countOfManualLotto) throws OutOfConditionE... | Java | 데이터와 프로세스가 따로 있는 것 == 절차지향 프로그래밍
현 상황 :
데이터 = LottoSeller, Ticket, User 등 (데이터 + getter)
프로세스 = Service (데이터 get 해서 로직 처리)
답 : MVC와 layered architecture를 잊고 view 와 비즈니스 로직을 분리하는 것만 기억하고 짜보기 |
@@ -0,0 +1,65 @@
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Scanner;
+import java.util.stream.Collectors;
+
+public final class InputView {
+
+ public static Money scanMoney(Scanner scanner) {
+ System.out.println("\n구입금액을 입력해 주세요.");
+
+ return Mon... | Java | view 에서는 데이터를 scan 해오는 책임만 있습니다.
지금은 변환 로직까지 여기서 처리하고 있네요~! |
@@ -0,0 +1,29 @@
+public final class PurchaseResultView {
+ public void notifyIfChangeLeft(LottoSeller seller) {
+ if (!seller.getChange().equals(Money.ZERO)) {
+ System.out.println("잔돈 " + seller.getChange() + "원이 남았습니다.");
+ System.out.println();
+ }
+ }
+
+ public void pr... | Java | finall class 로 하신 이유가 궁금합니다~ |
@@ -0,0 +1,37 @@
+package nextstep.authentication;
+
+public class UsernamePasswordAuthenticationToken implements Authentication {
+
+ private final String principal;
+ private final String credentials;
+ private boolean authenticated;
+
+ public UsernamePasswordAuthenticationToken(String principal, String ... | Java | `AuthenticationToken`은 말그대로 인증된 토큰이기 때문에 `UserDetails`는 필요로 하지 않습니다.
`UserDetails`의 사용처를 생각해보면, 최초 인입된 유저가 인증이 가능한 유저인지 확인하기 위해서 사용될 뿐이지 이미 인증된 토큰에는 별도로 `UserDetails`를 사용하지 않습니다. 현재 만들어주신 코드에도 사용처가 없기도 하구요. |
@@ -0,0 +1,37 @@
+package nextstep.authentication;
+
+public class UsernamePasswordAuthenticationToken implements Authentication {
+
+ private final String principal;
+ private final String credentials;
+ private boolean authenticated;
+
+ public UsernamePasswordAuthenticationToken(String principal, String ... | Java | 사용되지 않는 메소드들은 모두 제거해주시면 좋을 것 같아요 :) |
@@ -0,0 +1,29 @@
+package nextstep.authentication;
+
+import nextstep.authentication.exception.AuthenticationException;
+import nextstep.authentication.exception.ProviderNotFoundException;
+
+import java.util.List;
+import java.util.Objects;
+
+public class ProviderManager implements AuthenticationManager {
+
+ priv... | Java | `toTest`보다 적절한 네이밍은 어떨까요? |
@@ -0,0 +1,29 @@
+package nextstep.authentication;
+
+import nextstep.authentication.exception.AuthenticationException;
+import nextstep.authentication.exception.ProviderNotFoundException;
+
+import java.util.List;
+import java.util.Objects;
+
+public class ProviderManager implements AuthenticationManager {
+
+ priv... | Java | ```suggestion
return providers.stream()
.filter(provider -> provider.supports(toTest))
.map(provider -> provider.authenticate(authentication))
.filter(Objects::nonNull)
.findAny()
.orElseThrow();
```
로 표현될 수 있을 것 같네요 :) |
@@ -0,0 +1,68 @@
+package nextstep.authentication.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.ser... | Java | 인증이 null일 때 바로 return하면 필터 동작이 어디로 향할까요? |
@@ -0,0 +1,85 @@
+package nextstep.authentication.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.ser... | Java | `attempAuthentication`하는 동작은 request에서 헤더를 보고 토큰을 읽어 `authenticationManager.authenticate`를 실행하는 과정인데요. 이 과정에서 `SecurityContext`는 사실 불필요한 동작입니다.
현재 필터에서의 동작은
1. 헤더에 원하는 값을 뽑아내어 토큰을 생성한다.
2. 토큰을 가지고 `AuthenticationManager.authenticate`를 실행한다.
3. 성공하면 SecurityContext에 인증 값을 넣는다.
4. 실패하면 초기화하고 401을 반환한다.
입니다. 즉, ... |
@@ -0,0 +1,38 @@
+package nextstep.authentication.context;
+
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpSession;
+
+public class HttpSessionSecurityContextRepository implements SecurityContextRepository {
+
+ private static fina... | Java | 로직이 복잡할 필요 없이 `loadContext`는 단순히
1. request.getSession의 값이 null이면 null을 반환한다.
2. httpSession.getAttribute(SPRING_SECURITY_CONTEXT_KEY)를 반환한다.
면 됩니다. `readSecurityContextFromSession`의 분기는 위 과정으로 이미 동일하게 로직이 구성될 수 있어 별도로 필요 없어보여요. |
@@ -0,0 +1,29 @@
+package nextstep.authentication;
+
+import nextstep.authentication.exception.AuthenticationException;
+import nextstep.authentication.exception.ProviderNotFoundException;
+
+import java.util.List;
+import java.util.Objects;
+
+public class ProviderManager implements AuthenticationManager {
+
+ priv... | Java | target으로 변수명을 수정했습니다! |
@@ -0,0 +1,68 @@
+package nextstep.authentication.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.ser... | Java | 인증이 null일 때 다음 필터로 이동할 수 있도록 `filterChain.doFilter(servletRequest, servletResponse);` 코드를 추가했습니다! |
@@ -0,0 +1,85 @@
+package nextstep.authentication.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.ser... | Java | SecurityContext를 사용하지 않으면 FormLoginTest.login_after_members() 테스트가 통과하지 않는데 테스트를 수정하는게 좋을까요? |
@@ -0,0 +1,85 @@
+package nextstep.authentication.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.ser... | Java | SecurityContext를 사용하지 않으려고 아래처럼 수정을 시도했었습니다.
```java
private Authentication attemptAuthentication(HttpServletRequest request) throws AuthenticationException {
String authorization = request.getHeader("Authorization");
String credentials = authorization.split(" ")[1];
String decodedS... |
@@ -0,0 +1,85 @@
+package nextstep.authentication.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.ser... | Java | 테스트는 그대로 두는 것이 맞습니다. 테스트가 터지는 원인은 `String authorization = request.getHeader("Authorization");`에서 헤더값이 없는데 가져오려고 하는 것으로, 없으면 null을 반환하게끔 동작시키면 됩니다. 해당 필터는 헤더에 `Authorization`이 없으면 동작할 필요가 없이 바이패스하면 되니까요.
현재단계에서는 별도 path에 따른 인가처리가 없기 때문에 그정도로만 처리하고 넘어가주셔도됩니다. |
@@ -0,0 +1,10 @@
+package nextstep.authentication;
+
+public interface Authentication {
+
+ String getPrincipal();
+
+ String getCredentials();
+
+ boolean isAuthenticated();
+} | Java | 실제 패키지 구조는 `authentication`안에 모든 것이 있는 것이 아닌 웹에 대한 호출을 처리하는 `FilterChainProxy`와 같은 클래스들은 `web`패키지에, `UserDetails`와 같이 유저정보를 표현하는 클래스들은 별도로 `userdetails`에서 관리합니다. |
@@ -0,0 +1,27 @@
+package nextstep.authentication.context;
+
+public class SecurityContextHolder {
+
+ private static final ThreadLocal<SecurityContext> contextHolder = new ThreadLocal<>();
+
+ public static SecurityContext getContext() {
+ SecurityContext context = contextHolder.get();
+ if (contex... | Java | `SecurityContextHolder`라는 구현체를 사용하게 되는 경우에는 이 클래스를 사용하는 다른 클래스에서 구현체에 의존하여 테스트하기 어려운 구조가 될 수 있어 실제로는 이를 래핑한 인터페이스를 사용하게끔 구성되어있습니다.
https://github.com/spring-projects/spring-security/blob/main/core/src/main/java/org/springframework/security/core/context/SecurityContextHolderStrategy.java |
@@ -0,0 +1,19 @@
+package nextstep.authentication.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(code = HttpStatus.UNAUTHORIZED)
+public class AuthenticationException extends RuntimeException {
+
+ public AuthenticationExce... | Java | 사용하고 있지 않고 있는 것 같네요. |
@@ -0,0 +1,85 @@
+package nextstep.authentication.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.ser... | Java | 특정 path로 사용한다고 하더라도 다른 path가 추가되는 경우 이 프레임워크를 사용하는 사람이 상수를 건드릴 수 없으니 주입받아 사용하는 형태가 더 적절하겠네요. |
@@ -0,0 +1,24 @@
+import { BASE_URL } from '@/constants';
+import { GetReviewsParams, ReviewScore } from '@/types/reviewType';
+
+export const getReviewScore = async ({
+ gatheringId,
+ type,
+}: GetReviewsParams): Promise<ReviewScore[]> => {
+ const params = new URLSearchParams();
+ if (gatheringId) params.append('gat... | TypeScript | [p5] BASE_URL을 import해서 사용한 부분 좋습니다!🐱 |
@@ -0,0 +1,18 @@
+export interface PageInfoData {
+ title: string;
+ description: string;
+ src: string;
+}
+
+export interface PageNavData {
+ id: string;
+ label: string;
+ icon?: string;
+ active: boolean;
+ subItems?: PageNavData[];
+}
+
+export interface FilteringData {
+ label: string;
+ value: string;
+} | TypeScript | [p5] type 파일을 따로 분리해서 가독성이 좋아졌네요~😁 |
@@ -0,0 +1,16 @@
+export interface ReviewScore {
+ teamId: number;
+ gatheringId: number;
+ type: string;
+ averageScore: number;
+ oneStar: number;
+ twoStars: number;
+ threeStars: number;
+ fourStars: number;
+ fiveStars: number;
+}
+
+export interface GetReviewsParams {
+ gatheringId?: string;
+ type?: '' | 'DALLAE... | TypeScript | [p5] type 파일을 따로 분리해서 보기 좋습니다~!🐱 |
@@ -3,21 +3,17 @@
<mapper namespace="com.midnear.midnearshopping.mapper.coupon_point.PointMapper">
<insert id="grantPoints" useGeneratedKeys="true" keyProperty="pointId">
INSERT INTO point (
- amount, reason
+ amount, reason, review_id, user_id, grant_date
) VALUES (
- #{amo... | Unknown | 감사합니다.. |
@@ -0,0 +1,91 @@
+package christmas.Controller;
+
+import christmas.Domain.EventBenefitSettler;
+import christmas.Domain.EventPlanner;
+import christmas.Event.EventBadge;
+import christmas.View.InputView;
+import christmas.View.OutputView;
+import java.util.Map;
+
+public class EventController {
+ public EventPlanne... | Java | ```suggestion
public void takeVisitDate() {
try {
String visitDate = InputView.readVisitDate();
eventBenefitSettler = new EventBenefitSettler(visitDate);
} catch (IllegalArgumentException e) {
OutputView.printException(e);
takeVisitDate();
... |
@@ -0,0 +1,92 @@
+package christmas.Util;
+
+import static christmas.Event.EventOption.EVENT_END_DATE;
+import static christmas.Event.EventOption.EVENT_START_DATE;
+import static christmas.Event.EventOption.MAX_ORDER_QUANTITY;
+import static christmas.Message.OutputMessage.NOT_A_VALID_DATE;
+
+import christmas.Domain.M... | Java | 정규표현식을 정말 잘 활용하시는군요!👍👍
그런데 `(?:,|$)` 는 어떤 역할을 하는지 궁금합니다! |
@@ -0,0 +1,92 @@
+package christmas.Util;
+
+import static christmas.Event.EventOption.EVENT_END_DATE;
+import static christmas.Event.EventOption.EVENT_START_DATE;
+import static christmas.Event.EventOption.MAX_ORDER_QUANTITY;
+import static christmas.Message.OutputMessage.NOT_A_VALID_DATE;
+
+import christmas.Domain.M... | Java | `isDrinkMenu` 는 `MenuBoard` 에게 넘겨주면 어떨까요??
음료를 확인하는 책임은 `MenuBoard` 가 가지고 있는게 더 어울릴 것 같아요! 😁 |
@@ -0,0 +1,92 @@
+package christmas.Util;
+
+import static christmas.Event.EventOption.EVENT_END_DATE;
+import static christmas.Event.EventOption.EVENT_START_DATE;
+import static christmas.Event.EventOption.MAX_ORDER_QUANTITY;
+import static christmas.Message.OutputMessage.NOT_A_VALID_DATE;
+
+import christmas.Domain.M... | Java | 해당 정규표현식이 반복되는 것 같아요! 그렇다면 Pattern 객체를 캐싱해주면 어떨까요??
디스코드 함께 나누기에 현지님이[ 공유하신 글](https://velog.io/@dlguswl936/%EA%B3%B5%EB%B6%80%ED%95%9C-%EA%B2%83-String.matches%EB%8A%94-%EC%99%9C-%EC%84%B1%EB%8A%A5%EC%97%90-%EC%95%88-%EC%A2%8B%EC%9D%84%EA%B9%8C#%EA%B2%B0%EB%A1%A0-pattern-%EA%B0%9D%EC%B2%B4%EB%A5%BC-%EC%BA%90%EC%8B%B1... |
@@ -0,0 +1,30 @@
+package christmas.Util;
+
+public class CommaFormatter {
+ public static String formatWithComma(int number) {
+ String numberStr = Integer.toString(number);
+ int length = numberStr.length();
+
+ if (length <= 3) {
+ return numberStr;
+ }
+ String resul... | Java | 콤마를 위해 전용 객체를 만들어주셨군요! 직접 만들어주는 것도 좋네요!
그런데 돈 단위를 위한 콤마를 넣어주는 기능을 자바에서 제공하고 있답니다! ㅎㅎ
DecimalFormat 에 대해서 알아보시면 좋을 것 같아요! 제가 [참고했던 글](https://jamesdreaming.tistory.com/203)을 공유합니다! |
@@ -0,0 +1,67 @@
+package christmas.Domain;
+
+import christmas.Util.OrderMenuValidator;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class EventPlanner {
+ private final List<Menu> o... | Java | ```suggestion
public Map<String, Integer> calculateCategoryCount() {
Map<String, Integer> categoryCount = new HashMap<>();
int count = 0;
for (Menu menu : orderMenu) {
String menuCategory = menu.getMenuCategory();
categoryCount.put(menuCategory, categoryCount.ge... |
@@ -0,0 +1,102 @@
+package christmas.Domain;
+
+import christmas.Event.EventBenefit;
+import christmas.Event.EventOption;
+import christmas.Event.SpecialDiscountDay;
+import christmas.Util.OrderMenuValidator;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.util.HashMap;
+import java.util.Map;
+
+... | Java | `LocalDate` 를 활용하면 요일을 파악할 수 있군요! 배워갑니다! 😁 |
@@ -1,23 +1,20 @@
<template>
- <button
- @click="
- () => {
- if (!props.disabled) props.onClick();
- }
- "
- :class="getNextButtonStyle()"
- >
- <slot></slot>
+ <button @click="handleNextButtonClick" :class="getNextButtonStyle()">
+ <slot />
</button>
</template>
<script setu... | Unknown | 단순 궁금증으로 질문드립니다.
undefined를 타입으로 지정하신 이유가 있을까요?
NextButton.vue의 부모 컴포넌트에서 isPrimary 값을 부여하지 않을 때가 있어 undefined를 포함한 것으로 보이는데,
이 경우는 ? 만으로도 충분히 표현이 된 것 같습니다.
특히 boolean이기때문에 undefined일 때 falsy하게 인식이 될 것 같은데
추가하신 이유가 궁금합니다~ |
@@ -3,8 +3,8 @@
<p class="text-medium font-semi_bold">{{ title }}</p>
<div class="flex gap-x-3">
<button
- v-for="size in sizes"
- :key="size.id"
+ v-for="(size, index) in sizes"
+ :key="getButtonKey(size, index)"
class="flex flex-col items-center justify-between ga... | Unknown | storeToRefs 를 사용해서 반응성을 살리셨네요 👍 |
@@ -3,16 +3,12 @@
<section
class="mx-auto flex h-full flex-col items-center justify-between bg-gray_00-light text-gray_05-light dark:bg-gray_00-dark dark:text-gray_05-dark sm:w-screen md:w-96"
>
- <ProgressNavBar prevPage="/size" pageName="ingredient" />
- <div v-if="isLoading">로딩중입니다.</div>
... | Unknown | 서버 상태관리와 클라이언트 상태관리를 분리하여 관리하셨군요 👍 |
@@ -1,23 +1,20 @@
<template>
- <button
- @click="
- () => {
- if (!props.disabled) props.onClick();
- }
- "
- :class="getNextButtonStyle()"
- >
- <slot></slot>
+ <button @click="handleNextButtonClick" :class="getNextButtonStyle()">
+ <slot />
</button>
</template>
<script setu... | Unknown | 사실 저도 추가하지 않았다가, 좀더 가시적으로 표현하려고 작성을 했어요! 음, 메이브님 말씀듣고 다시 생각해보니 가시성만으로 추가하는 건 좀 의미가 없는 것 같긴하네요!! |
@@ -3,20 +3,18 @@
class="text-gray_05-light dark:text-gray_05-dark w-6 h-6"
@click="goBack"
>
- <slot></slot>
+ <slot />
</button>
</template>
<script setup lang="ts">
-import { useRouter } from 'vue-router';
+import { pushPage } from '@router/route.helper';
const props = defineProps<{
p... | Unknown | 화살표 함수로 해주세요~ |
@@ -0,0 +1,210 @@
+import 'package:flutter/material.dart';
+
+class ReviewView extends StatelessWidget {
+ const ReviewView({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: _appBar(context),
+ floatingActionButtonLocation: FloatingActionButtonLocation.endFl... | Unknown | 플로팅 버튼 제거하셔도 됩니다. 이전 PR 참고해주세요. |
@@ -5,13 +5,15 @@
import com.somemore.domains.review.dto.response.ReviewDetailResponseDto;
import com.somemore.domains.review.dto.response.ReviewDetailWithNicknameResponseDto;
import com.somemore.domains.review.usecase.ReviewQueryUseCase;
+import com.somemore.global.auth.annotation.RoleId;
import com.somemore.globa... | Java | 빌더 로직을 컨디션 클래스의 of 정적 메서드에서 진행하면 더 깔끔할 것 같아요~
굳이 수정할 필요는 없다고 생각합니다! |
@@ -1,35 +1,34 @@
package com.somemore.domains.review.service;
-import com.somemore.domains.center.usecase.query.CenterQueryUseCase;
+import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_REVIEW;
+
import com.somemore.domains.review.domain.Review;
import com.somemore.domains.review.dto.condition.... | Java | 메서드로 코드를 포장하면 가독성이 더 좋을 것 같아요~ |
@@ -1,35 +1,34 @@
package com.somemore.domains.review.service;
-import com.somemore.domains.center.usecase.query.CenterQueryUseCase;
+import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_REVIEW;
+
import com.somemore.domains.review.domain.Review;
import com.somemore.domains.review.dto.condition.... | Java | 복수형 정적 팩토리 메서드 |
@@ -1,8 +1,79 @@
import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = event => {
+ const { name, value } = ev... | JavaScript | 오 구조분해 할당~ |
@@ -1,8 +1,79 @@
import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = event => {
+ const { name, value } = ev... | JavaScript | this.state.id.includes('@') &&
this.state.id.length >= 5 &&
this.state.pw.length >= 8 이걸 true/false Boolean?? 이값을 사용해서 삼항연산자로 해도 되지 않을까요 수정님은 잘하시니 아마가능하실듯! |
@@ -0,0 +1,61 @@
+.Login {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 100vh;
+
+ main {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-around;
+ width: 350px;
+ height: 380px;
+ padding: 40px;
+ border: 1px solid #ccc;
+
+ header {
+ ... | Unknown | 이건 왜 주석으로 되있나요??? |
@@ -0,0 +1,134 @@
+[
+ {
+ "id": 1,
+ "userName": "eessoo__",
+ "src": "../images/soojeongLee/user2.jpg",
+ "feedText": "💟",
+ "commentData": [
+ {
+ "id": 1,
+ "userName": "wecode",
+ "content": "Welcome to world best coding bootcamp!",
+ "commnetLike": false
+ },... | Unknown | 제이슨 파일도 있었군요! |
@@ -0,0 +1,175 @@
+import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import Comment from './Comment/Comment';
+
+import '../Feed/Feed.scss';
+
+export class Feed extends Component {
+ constructor() {
+ super();
+ this.state = {
+ comment: '',
+ // commentList: [],
+... | JavaScript | 오 이렇게 다시 볼 수 있는 방법도 나쁘지 않은 듯 ?
나중에 가서는 지워야 될 수도 있지만...? |
@@ -0,0 +1,175 @@
+import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import Comment from './Comment/Comment';
+
+import '../Feed/Feed.scss';
+
+export class Feed extends Component {
+ constructor() {
+ super();
+ this.state = {
+ comment: '',
+ // commentList: [],
+... | JavaScript | 버튼으로 한 이유가 있나요? 궁금 |
@@ -0,0 +1,175 @@
+import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import Comment from './Comment/Comment';
+
+import '../Feed/Feed.scss';
+
+export class Feed extends Component {
+ constructor() {
+ super();
+ this.state = {
+ comment: '',
+ // commentList: [],
+... | JavaScript | autoComplete 이거는 뭔가요? 궁금~ |
@@ -0,0 +1,128 @@
+@import '../../../../styles/variables.scss';
+
+article {
+ margin-bottom: 20px;
+ background-color: #fff;
+ border-radius: 3px;
+ border: 1px solid $border-color;
+
+ header {
+ @include flex-center;
+ justify-content: space-between;
+ align-content: center;
+ padding: 10px;
+
+ ... | Unknown | 이런 scss 기능 저는 헷갈려서 잘 못하겠던데 잘하시네요.. |
@@ -0,0 +1,23 @@
+//라이브러리
+import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+//컴포넌트
+import { FOOTLIST } from '../FootLists/footData';
+
+// css
+import './FootLists.scss';
+
+export class FootLists extends Component {
+ render() {
+ return FOOTLIST.map(footlists => {
+ ret... | JavaScript | 댓글 프랍스! |
@@ -0,0 +1,46 @@
+export const FOOTLIST = [
+ {
+ id: 1,
+ footlist: '소개',
+ },
+ {
+ id: 2,
+ footlist: '도움말',
+ },
+ {
+ id: 3,
+ footlist: '홍보 센터',
+ },
+ {
+ id: 4,
+ footlist: 'API',
+ },
+ {
+ id: 5,
+ footlist: '채용 정보',
+ },
+ {
+ id: 6,
+ footlist: '개인정보처리방침',
+ }... | JavaScript | 화이팅 푸터 만들어서 강의 부탁드려요 |
@@ -1,14 +1,148 @@
-// 필수
import React from 'react';
+import { Link } from 'react-router-dom';
-// 컴포넌트
import Nav from '../../../components/Nav/Nav';
+import Feed from '../Main/Feed/Feed';
+import OtherUserPro from './OtherUserPro/OtherUserPro';
+import FootLists from '../Main/Feed/FootLists/FootLists';
+
+import ... | JavaScript | 데이터 확인 다 하셨나요~~? |
@@ -1,14 +1,148 @@
-// 필수
import React from 'react';
+import { Link } from 'react-router-dom';
-// 컴포넌트
import Nav from '../../../components/Nav/Nav';
+import Feed from '../Main/Feed/Feed';
+import OtherUserPro from './OtherUserPro/OtherUserPro';
+import FootLists from '../Main/Feed/FootLists/FootLists';
+
+import ... | JavaScript | 피어 리뷰 중 Return의 비밀을? 감사합니다. |
@@ -1,8 +1,79 @@
import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = event => {
+ const { name, value } = ev... | JavaScript | Boolean 데이터 타입 적용시켜보았아요. 잘 세웠던 코드가 작동되지 않을까 시도하기 어려웠는데 격려 감사합니당~ |
@@ -0,0 +1,61 @@
+.Login {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 100vh;
+
+ main {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-around;
+ width: 350px;
+ height: 380px;
+ padding: 40px;
+ border: 1px solid #ccc;
+
+ header {
+ ... | Unknown | 기존 html 코드를 옮기다 보니 발생한 문제였어요 :) 해결되었답니당 !! |
@@ -0,0 +1,134 @@
+[
+ {
+ "id": 1,
+ "userName": "eessoo__",
+ "src": "../images/soojeongLee/user2.jpg",
+ "feedText": "💟",
+ "commentData": [
+ {
+ "id": 1,
+ "userName": "wecode",
+ "content": "Welcome to world best coding bootcamp!",
+ "commnetLike": false
+ },... | Unknown | fetching 을 연습해보려고 만들어보았어요 |
@@ -0,0 +1,175 @@
+import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import Comment from './Comment/Comment';
+
+import '../Feed/Feed.scss';
+
+export class Feed extends Component {
+ constructor() {
+ super();
+ this.state = {
+ comment: '',
+ // commentList: [],
+... | JavaScript | 인스타그램에서 실제 좋아요를 좋아한 숫자에 접근하게 되면 누가 좋아요를 눌렀는지 목록을 볼 수 있어서, 추후에 기능을 넣게 된다면 button을 넣어야 하지 않을까 생각이 들어서 넣어봤습니다. |
@@ -0,0 +1,23 @@
+//라이브러리
+import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+//컴포넌트
+import { FOOTLIST } from '../FootLists/footData';
+
+// css
+import './FootLists.scss';
+
+export class FootLists extends Component {
+ render() {
+ return FOOTLIST.map(footlists => {
+ ret... | JavaScript | 꼭 풋 리스트를... 컴포넌트화해보겠어요...!!!! |
@@ -1,14 +1,148 @@
-// 필수
import React from 'react';
+import { Link } from 'react-router-dom';
-// 컴포넌트
import Nav from '../../../components/Nav/Nav';
+import Feed from '../Main/Feed/Feed';
+import OtherUserPro from './OtherUserPro/OtherUserPro';
+import FootLists from '../Main/Feed/FootLists/FootLists';
+
+import ... | JavaScript | 네..! 무엇이 어디에 전달되었는지 확인하기가 어려워서 넣어뒀어요 ...! |
@@ -1,14 +1,148 @@
-// 필수
import React from 'react';
+import { Link } from 'react-router-dom';
-// 컴포넌트
import Nav from '../../../components/Nav/Nav';
+import Feed from '../Main/Feed/Feed';
+import OtherUserPro from './OtherUserPro/OtherUserPro';
+import FootLists from '../Main/Feed/FootLists/FootLists';
+
+import ... | JavaScript | ㅎㅎㅎ Return 은 생략될 수 있다 ~ |
@@ -1,8 +1,79 @@
import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = event => {
+ const { name, value } = ev... | JavaScript | 계산된속성명 굿 |
@@ -0,0 +1,175 @@
+import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import Comment from './Comment/Comment';
+
+import '../Feed/Feed.scss';
+
+export class Feed extends Component {
+ constructor() {
+ super();
+ this.state = {
+ comment: '',
+ // commentList: [],
+... | JavaScript | 오.... |
@@ -0,0 +1,175 @@
+import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import Comment from './Comment/Comment';
+
+import '../Feed/Feed.scss';
+
+export class Feed extends Component {
+ constructor() {
+ super();
+ this.state = {
+ comment: '',
+ // commentList: [],
+... | JavaScript | 이런방법이.. 피드마다 댓글 데이터를 스테이트로 포함하게 해주니 보기 쉽고 좋네요 |
@@ -1,8 +1,79 @@
import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = event => {
+ const { name, value } = ev... | JavaScript | 이런 주석들은 불필요하니까 삭제해주시는게 좋아보입니다! |
@@ -1,8 +1,79 @@
import React, { Component } from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = event => {
+ const { name, value } = ev... | JavaScript | event.target 반복되고 있는데 구조분해해서 활용해볼 수 있겠네요!
```const {name,value} = event.target;``` |
@@ -1,14 +1,77 @@
-import React from "react";
-import "./PostAdd.scss";
+import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import './PostAdd.scss';
+import { Button } from '../PostAdd/components/Post.jsx';
const PostAdd = () => {
+ const [comment, setComment] = useState('');... | JavaScript | import 순서에도 유지보수 및 가독성을 위한 컨벤션이 있습니다.
위코드의 컨벤션은 간략하게 아래와 같고, 참고해서 수정해 주세요!
- 라이브러리
- React 관련 패키지
- 외부 라이브러리
- 컴포넌트
- 공통 컴포넌트 → 먼 컴포넌트 → 가까운 컴포넌트
- 함수, 변수 및 설정 파일
- 사진 등 미디어 파일(`.png`)
- css 파일 (.`scss`) |
@@ -1,14 +1,77 @@
-import React from "react";
-import "./PostAdd.scss";
+import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import './PostAdd.scss';
+import { Button } from '../PostAdd/components/Post.jsx';
const PostAdd = () => {
+ const [comment, setComment] = useState('');... | JavaScript | event 객체에는 여러 데이터가 담겨있습니다.
그 중에서 target의 value(input에 입력한 값)만을 사용하기 때문에, 함수를 호출할 때 인자로 아예 event.target.value만을 인자로 넘겨서 사용하면 이 함수의 사용이 좀 더 명확하겠네요! |
@@ -1,14 +1,77 @@
-import React from "react";
-import "./PostAdd.scss";
+import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import './PostAdd.scss';
+import { Button } from '../PostAdd/components/Post.jsx';
const PostAdd = () => {
+ const [comment, setComment] = useState('');... | JavaScript | 실수로 눌렀을 경우에도 무조건 list 페이지로 이동하게 될 텐데, 선택권을 줄 수도 있겠네요.
`window.confirm` 함수에 대해 찾아보고 적용해보셔도 좋을 것 같습니다! |
@@ -1,14 +1,77 @@
-import React from "react";
-import "./PostAdd.scss";
+import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import './PostAdd.scss';
+import { Button } from '../PostAdd/components/Post.jsx';
const PostAdd = () => {
+ const [comment, setComment] = useState('');... | JavaScript | fetch 함수의 인자는 보통 2개가 들어가는데, 지금은 옵션에 관련된 두 번째 인자만 작성되어 있네요!
실제로 통신하실 때에는 첫 번째 인자인 `API` 값도 잘 전달해 주세요! |
@@ -1,14 +1,77 @@
-import React from "react";
-import "./PostAdd.scss";
+import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import './PostAdd.scss';
+import { Button } from '../PostAdd/components/Post.jsx';
const PostAdd = () => {
+ const [comment, setComment] = useState('');... | JavaScript | 불필요하게 3중으로 감싸고 있는 것 같은데, 일단 최상위의 div는 불필요해 보이네요!
요소가 중첩될 수록, 프로젝트의 규모가 커질 수록 로딩되는 시간이 길어지기 때문에 불필요하게 중첩된 요소는 지워주셔야 합니다! |
@@ -1,14 +1,77 @@
-import React from "react";
-import "./PostAdd.scss";
+import React, { useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+import './PostAdd.scss';
+import { Button } from '../PostAdd/components/Post.jsx';
const PostAdd = () => {
+ const [comment, setComment] = useState('');... | JavaScript | img 태그의 alt 값은 어디에 활용될까요?
찾아보시고 올바르게 작성해 주세요! |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.