code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -1,51 +1,45 @@
package nextstep.auth.token;
import com.fasterxml.jackson.databind.ObjectMapper;
-import nextstep.auth.authentication.AuthenticationException;
-import nextstep.member.application.LoginMemberService;
-import nextstep.member.domain.LoginMember;
+import nextstep.auth.authentication.AuthenticationToke... | Java | `ObjectMapper` ๋ ์์ฑ ๋น์ฉ์ด ๋น์ธ๋ค๊ณ ์๋ ค์ง ๊ฐ์ฒด์
๋๋ค. ์์กด์ฑ ์ฃผ์
์ ํตํด ํด๊ฒฐํด๋ณผ ์ ์์๊น์? ๐ |
@@ -0,0 +1,8 @@
+package nextstep.member.application;
+
+import nextstep.member.domain.User;
+
+public interface UserDetailsService {
+
+ User loadUserByUsername(String email);
+} | Java | ์ด ์ธํฐํ์ด์ค๊ฐ `member` ํจํค์ง์ ์๋๊ฒ ๋ง์๊น์? ๐ค |
@@ -0,0 +1,83 @@
+package nextstep.subway.unit;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import nextstep.auth.authentication.AuthenticationToken;
+import nextstep.auth.authentication.LoginMember;
+import nextstep.auth.token.JwtTokenProvider;
+import nextstep.auth.token.TokenAuthenticationInterceptor;
+im... | Java | ์ด๋ฐํํ๋ก ๊ฒ์ฆ๋ ๊ฐ๋ฅํฉ๋๋ค ๐
```suggestion
given(jwtTokenProvider.createToken(any(), any())).willReturn(JWT_TOKEN);
boolean result = interceptor.preHandle(createMockRequest(), response, new Object());
assertThat(result).isFalse();
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK... |
@@ -10,7 +10,7 @@
import static org.assertj.core.api.Assertions.assertThat;
class MemberAcceptanceTest extends AcceptanceTest {
- public static final String EMAIL = "email@email.com";
+ public static final String EMAIL = "email2@email.com";
public static final String PASSWORD = "password";
public st... | Java | ์ธ์ํ
์คํธ๋ฅผ ์ฝ๋ ์ฌ๋์ด ๋๊ตฌ์ธ๊ฐ์ ๋ํด ๊ณ ๋ฏผํด๋ด์ผ ํ๋๋ฐ์.
ํด๋ฆฐ ์ ์์ผ์ ๊ตฌ์ ์ ์ธ์ฉํ๋ฉด
>์ธ์ํ
์คํธ๋ ์
๋ฌด ๋ถ์๊ฐ์ QA, ๊ฐ๋ฐ์๊ฐ ํจ๊ป ํ์ ๋ชจ์ ์์ฑํ๋ค.
์ด์ ๊ฐ์ด ์ธ์ํ
์คํธ๋ฅผ ์ฝ๋ ์ฌ๋์ด ๋ชจ๋ ๊ฐ๋ฐ์๋ ์๋ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค ๐. |
@@ -0,0 +1,8 @@
+package nextstep.member.application;
+
+import nextstep.member.domain.User;
+
+public interface UserDetailsService {
+
+ User loadUserByUsername(String email);
+} | Java | ๋ง๋ค๋ฉด์ ๋ฐฐ์ฐ๋ ํด๋ฆฐ์ํคํ
์ณ๋ฅผ ๋ณด๋ฉด ์๋น์ค์ ์ธํฐํ์ด์ค์ ๊ทธ ๊ตฌํ์ฒด๋ฅผ ๊ฐ์ด ๋๊ธฐ์ ๊ทธ๊ฒ ์ต์ํด์ member์ ๋์๋ค์ ใ
ใ
UserDetailService๋ฅผ auth์์๋ง ์ฌ์ฉํ์ง ์์ ์๋ ์๊ธฐ์ ๊ตฌํ์ฒด์ ๊ฐ์ด ๋๋๊ฒ ํ๋์ ๋ ๋ค์ด์ฌ ๊ฒ ๊ฐ์ต๋๋ค!
๋ฌผ๋ก ์ธํฐํ์ด์ค์ ๊ตฌํ์ฒด์ ๊ตฌ๋ถ์ ํด๋๋ก๋ผ๋ ํ๋ฉด ์ข์๋ฐ ๊ธํ๊ฒ ํ๋๋ผ... ๐ |
@@ -0,0 +1,83 @@
+package nextstep.subway.unit;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import nextstep.auth.authentication.AuthenticationToken;
+import nextstep.auth.authentication.LoginMember;
+import nextstep.auth.token.JwtTokenProvider;
+import nextstep.auth.token.TokenAuthenticationInterceptor;
+im... | Java | bool๋ง ํ์ธํ๊ธฐ์๋ ๋ถ์กฑํ๋ค๊ณ ์๊ฐํ๋๋ฐ ์ข๋ค์! ๊ฐ์ฌํฉ๋๋ค. |
@@ -10,7 +10,7 @@
import static org.assertj.core.api.Assertions.assertThat;
class MemberAcceptanceTest extends AcceptanceTest {
- public static final String EMAIL = "email@email.com";
+ public static final String EMAIL = "email2@email.com";
public static final String PASSWORD = "password";
public st... | Java | ๋ตใ
ใ
์ข๋ ํ๊ธํ๊ฐ ๋ค์ด๊ฐ๋ฉด ์ข์ ๊ฒ ๊ฐ๊ตฐ์ |
@@ -0,0 +1,39 @@
+package nextstep.auth.authentication;
+
+import nextstep.member.application.UserDetailsService;
+import nextstep.member.domain.User;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java... | Java | ๋ฏธ์
์ `auth` ํจํค์ง ๋ด์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ ์ธํ ๋น์ฆ๋์ค ํจํค์ง๋ค์ด ๋ค์ด์ค์ง ์์์ผ ์๋ฃ๋ฉ๋๋ค ๐ข
ํ์ฌ `auth` ํจํค์ง๊ฐ `member` ์ ์์กดํ๊ณ ์์ด์ |
@@ -1,9 +1,12 @@
-package nextstep.member.domain;
+package nextstep.auth.authentication;
+import nextstep.member.domain.Member;
+import nextstep.member.domain.User;
+
import java.util.List;
-public class LoginMember {
+public class LoginMember implements User {
private String email;
private String pass... | Java | `LoginMember` ๋ฅผ ์ฎ๊ธฐ์์ง ์์์ ๋ฉ๋๋ค ๐ข |
@@ -0,0 +1,8 @@
+package nextstep.member.application;
+
+import nextstep.member.domain.User;
+
+public interface UserDetailsService {
+
+ User loadUserByUsername(String email);
+} | Java | ํด๋น ์ฑ
์์์ ๊ตฌํ์๋๋ ๋จ์ํ ์ธํฐํ์ด์ค์ ๊ตฌํ์ฒด๋ฅผ ๊ฐ์ ํจํค์ง์ ๋๋ ๊ฒ์ ์๋๋๋ค ๐
ํด๋ฆฐ ์ํคํ
์ฒ์์ ๋ก๋ฒํธ C.๋งํด์ ์๋์ ๊ฐ์ ์์ ๊ทธ๋ ค์ ์ค๋ช
ํ๋๋ฐ์.
์กฐ๊ธ ๋จ์ํํด์ ๋ง์๋๋ฆฌ๋ฉด ์ ์ธ๋ถ์ ๊ฐ์ฒด๋ง์ด ์ ๋ด๋ถ์ ๊ฐ์ฒด์ ์์กดํด์ผ ํ๋ค๋ ๊ฒ์ ์ฃผ์ฅํฉ๋๋ค.
๋ง์ํ์ ๋ง๋ค๋ฉด์ ๋ฐฐ์ฐ๋ ํด๋ฆฐ์ํคํ
์ฒ๋ `DIP`๋ฅผ ํตํด ์์กด์ฑ ๊ฒฉ๋ฆฌํ๊ธฐ ์ํด ์ธํฐํ์ด์ค๋ฅผ ๋๊ณ , ํด๋น ์ธํฐํ์ด์ค๋ฅผ ๋ด๋ถ์ ๊ฐ์ฒด๊ฐ ๊ตฌํํ๊ณ , ์ธ๋ถ์ ๊ฐ์ฒด๋ ๊ทธ ์ธํฐํ์ด์ค๋ฅผ `์ฌ์ฉ`ํจ์ผ๋ก์จ ์ธ๋ถ์ ๊ฐ์ฒด๊ฐ ๋ด๋ถ์ ์ค์ ๊ตฌํ๊ฐ์ฒด๋ฅผ ์์ง ๋ชปํ๊ฒ ๋๋ ์ญํ ์ ํฉ๋๋ค.
์ง๊ธ ๋ฏธ์
์์ ์๊ตฌํ๋ ๊ฒ๋ ์ฌ์ค์ `... |
@@ -0,0 +1,8 @@
+package nextstep.member.application;
+
+import nextstep.member.domain.User;
+
+public interface UserDetailsService {
+
+ User loadUserByUsername(String email);
+} | Java | ๋ค ๋ง์ํ์ ๋๋ก ์ ์ธ๋ถ์ ๊ฐ์ฒด๋ง์ด ์ ๋ด๋ถ์ ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํด์ผ ํ๋ค๋ ๊ฒ์ ๋์ํฉ๋๋ค.
๊ทธ๋ฐ๋ฐ ํ์ฌ ๊ตฌ์กฐ๋ก๋ ์์กด์ฑ ๊ฒฉ๋ฆฌ๊ฐ ์ถฉ๋ถํ ๋์ง ์์๋ค๋ ๋ง์์ผ๊น์? ํ์ฌ๋ member ๊ณผ auth๊ฐ์ usecase๋ฅผ ํตํด ํต์ ์ด ์ด๋ฃจ์ด์ง๊ณ ์๊ธฐ์, dip๋ฅผ ํตํด ๊ตฌํ์ฒด๋ ์ง์ ์ ์ผ๋ก ์ฐธ์กฐ๊ฐ ์ด๋ค์ง์ง ์๊ณ ์์ด์ usecase๋ฅผ ์ด๋์ ๋ ๊ฒ์ธ๊ฐ๋ ๋ถ์ฐจ์ ์ธ ๋ฌธ์ ๋ผ๊ณ ์๊ฐํ์ต๋๋ค. (๊ทธ๋์ ๊ทธ์ค ํ๋๋ก ๋ง๋ค๋ฉด์ ๋ฐฐ์ฐ๋ ํด๋ฆฐ์ํคํ
์ณ ๋ด์ฉ์ ์์๋ก ๋ ๊ฒ์ด๊ณ ์. ์ฒจ๋ถํด์ฃผ์ ์์์์๋ import๋ฌธ์ด ์กด์ฌํ๊ธฐ๋ง ํด๋ ์์กด๊ด๊ณ๊ฐ ์๋ค๊ณ ํ๋ค์!)
๋ฏธ์
์ด ๊ทธ๋ฐ ์๋ฏธ๋ผ๋ฉด ์์ ํ๋๊ฑด ... |
@@ -0,0 +1,8 @@
+package nextstep.member.application;
+
+import nextstep.member.domain.User;
+
+public interface UserDetailsService {
+
+ User loadUserByUsername(String email);
+} | Java | ํด๋ฆฐ์ํคํ
์ฒ๋ฅผ ์ธ๊ธํ๊ฑด ์์๋์ด ์๊ธฐํ์ ๋ถ๋ถ์ ๋ํด ์ถ๊ฐ์ ์ธ ์ธ๊ธ์ ๋๋ฆฌ๋ค๋ณด๋ ๊ทธ๋ ๊ฒ ๋์๋ค์ ๐
ํด๋ฆฐ์ํคํ
์ฒ์ ๋ด์ฉ์ด ๋จ์ํ ์ธํฐํ์ด์ค์ ๊ตฌํ์ฒด๋ฅผ ๊ฐ์ ํจํค์ง์ ๋๋ผ๋ ์๋ฏธ๋ ์๋๋ผ๊ณ ์๊ฐํด์ ์ฒจ์ธ์ ๋๋ ค๋ดค์ต๋๋ค
ํ์ฌ ๋ฏธ์
์ ๋ํด ์ด์ผ๊ธฐํ๋ฉด auth ์ member ์ ์ฑ์ง์ ๋ํด ๊ณ ๋ฏผํด๋ด์ผํ๋ ๋ฐ์.
`auth` ๋ ์ธ์ฆ/์ธ๊ฐ์ ๋ํ ์ฑ
์์ ๊ฐ์ง๋ `๋น์ฆ๋์ค ๊ท์น`๊ณผ๋ ์กฐ๊ธ ๋๋จ์ด์ง `๊ณตํต`์ ์ฑ์ง์ ์ง๋ ํจํค์ง๋ผ๊ณ ์๊ฐ๋ฉ๋๋ค
๋ฐ๋ฉด์ `member`๋ ์ด ์ ํ๋ฆฌ์ผ์ด์
๋ง์ `๋น์ฆ๋์ค ๊ท์น`์ ๋ด์์๋ ์๋ ์ฌ์ฉ์์ ๋ํ ํจํค์ง๋ผ๊ณ ๋ณผ ์ ์์ ๊ฒ ๊ฐ... |
@@ -0,0 +1,8 @@
+package nextstep.member.application;
+
+import nextstep.member.domain.User;
+
+public interface UserDetailsService {
+
+ User loadUserByUsername(String email);
+} | Java | ์์๋ฅผ ๋ค์ด์ฃผ์ ๋ง๋ค๋ฉด์ ๋ฐฐ์ฐ๋ ํด๋ฆฐ ์ํคํ
์ฒ์์๋ application ํจํค์ง์ ์ธํฐํ์ด์ค๋ฅผ adapter ์์ ๊ตฌํ ํ๋ ํํ๋ก ๊ฐ๋ฐ์ ํ๊ณ ์์ต๋๋ค. ์์กด์ฑ ๊ฒฉ๋ฆฌ๋ฅผ ์ํด `DIP`๋ฅผ ์ฌ์ฉํ๋ฉด ๊ฐ๋
์์ผ๋ก๋ ์ด๊ฒ ์ ๊ฒ ์ด์ผ๊ธฐ ํ ์ ์๊ฒ ์ง๋ง, ๊ฒฐ๊ตญ์ ๋ด๋ถ์ ๊ฐ์ฒด๋ค์ด ์ธ๋ถ์ ์์กดํ์ง ์๋๋ก ๋ง๋๋ ์ฌ๋ฌ๊ฐ์ง ๋ฐฉ๋ฒ๋ค์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค ๐ |
@@ -0,0 +1,8 @@
+package nextstep.member.application;
+
+import nextstep.member.domain.User;
+
+public interface UserDetailsService {
+
+ User loadUserByUsername(String email);
+} | Java | > MemberControllerย ๊ฐย @AuthenticationPrincipal๋ฅผ ์ฌ์ฉํ๊ณ ,ย LoginMember๊ฐย User๋ฅผ ๊ตฌํํ๊ธฐ ๋๋ฌธ์ ํจํค์ง ๊ฐ์ ์ํ์ฐธ์กฐ๊ฐ ์๊ฒผ์ต๋๋ค.
์ฌ๊ธฐ์ ์ฐธ์กฐ๊ฐ ์๋ค๋๊ฑด ์๊ฐ๋ชปํ๋ค์! ๋ต ์์ ํ๊ฒ ์ต๋๋ค
> ์์๋ฅผ ๋ค์ด์ฃผ์ ๋ง๋ค๋ฉด์ ๋ฐฐ์ฐ๋ ํด๋ฆฐ ์ํคํ
์ฒ์์๋ application ํจํค์ง์ ์ธํฐํ์ด์ค๋ฅผ adapter ์์ ๊ตฌํ ํ๋ ํํ๋ก ๊ฐ๋ฐ์ ํ๊ณ ์์ต๋๋ค
๋ต ์ฒ์ ๋๊ธ์์ ๋ง์๋๋ ธ๋ฏ์ด `๋ฌผ๋ก ์ธํฐํ์ด์ค์ ๊ตฌํ์ฒด์ ๊ตฌ๋ถ์ ํด๋๋ก๋ผ๋ ํ๋ฉด ์ข์๋ฐ ๊ธํ๊ฒ ํ๋๋ผ...ย ๐` ๐ ์์ผ๋ก ์ฐธ๊ณ ํ๊ฒ ์ต๋๋ค. ์ง๊ธ๊น์ง ๊ธด ์ค๋ช
... |
@@ -0,0 +1,8 @@
+package nextstep.member.application;
+
+import nextstep.member.domain.User;
+
+public interface UserDetailsService {
+
+ User loadUserByUsername(String email);
+} | Java | ์ ๋ ํ ๋ก ํ๋ฉฐ ์ฌ๋ฏธ์์์ต๋๋ค
[์ฐธ๊ณ ](https://github.com/wikibook/clean-architecture) ์ ์์ ์ ์์กด๊ด๊ณ๋ฅผ ์ง์ ๊ทธ๋ฆผ์ผ๋ก ๊ทธ๋ ค๋ณด์๋ฉด ๋ ์ข์ ์ธ์ฌ์ดํธ๋ฅผ ์ป์ผ ์ค ์ ์์๊ฒ ๊ฐ์์ ๐ |
@@ -0,0 +1,39 @@
+package nextstep.subway.unit;
+
+import nextstep.subway.applicaion.LineService;
+import nextstep.subway.applicaion.PathService;
+import nextstep.subway.applicaion.StationService;
+import nextstep.subway.domain.Station;
+import nextstep.subway.utils.TestObjectFactory;
+import org.junit.jupiter.api.Disp... | Java | StationService์ createStationResponse ๋ฉ์๋๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉํ๊ณ ์ถ์ด์, stationService๋ฅผ ๋ชจํนํ์ง ์๊ณ ๋ฐ๋ก ์์ฑํ๋๋ก ํ์๋๋ฐ์
@InjectMocks๋ ์ฌ์ฉํ ์ ์์ด ๋ถํธํ๊ณ , ํ
์คํธํ ๋์ ํ๋๋ง ์๋ณธ ํด๋์ค๋ฅผ ๊ฐ์ ธ๋ค ์ฐ๊ณ ๋๋จธ์ง๋ ๋ค ๋ชฉ์ผ๋ก ์งํํด์ผ ํ๋ค๋ ๋ชฉ ํ
์คํธ์ ์ด๋
(?) ์๋ ๋ง์ง ์๋ ๊ฒ ๊ฐ์ ๊ณ ๋ฏผ์ด ๋ฉ๋๋ค.
ํน์ ๋ค๋ฅธ ๊น๋ํ ํ
์คํธ ๋ฐฉ๋ฒ์ด๋ ๋ฆฌํฉํ ๋ง ๋ฐฉ๋ฒ์ด ์์๊น์? |
@@ -0,0 +1,39 @@
+package nextstep.subway.unit;
+
+import nextstep.subway.applicaion.LineService;
+import nextstep.subway.applicaion.PathService;
+import nextstep.subway.applicaion.StationService;
+import nextstep.subway.domain.Station;
+import nextstep.subway.utils.TestObjectFactory;
+import org.junit.jupiter.api.Disp... | Java | ์ฃผ๋ก ์ง๊ธ๊ณผ ๊ฐ์ด layered ์ํคํ
์ฒ์์๋ application(service) layer๋ domain ๊ฐ์ฒด๋ค์ ์กฐํฉํ๋ ์ญํ ์ ํ๋๋ฐ์,
์ง๊ธ ์ฝ๋์์๋ ์๋ต Response ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ์ญํ ๋ํ service๊ฐ ๊ฐ๊ณ ์์ด์ injectํด์ผํ๋ ๋ฌธ์ ๊ฐ ์๊ธฐ๋ ๊ฒ ๊ฐ์์.
mock testing ๋ฐฉ์์ ์ฌ์ฉํ์ ๋ ํฌ๊ฒ ๋๊ปด์ง๋ ๋จ์ ์ค ํ๋๋ ์์กดํ๋ ๊ฐ์ฒด๊ฐ ๋ง์ผ๋ฉด ๋ง์์ง์๋ก ํ
์คํธ ์์ฑ์ด ๊น๋ค๋ก์์ง๋ค๋ ๊ฑฐ์์.
(when, thenReturn์ ํด์ผํ๋ ๋ด๋ถ ๊ตฌํ ์์ฒด๋ฅผ ์ง์ ์ ์ผ๋ก ์์์ผ๊ฒ ์ฃ )
๊ทธ๋ฐ ์ ์์ service๋ผ๋ฆฌ ์์กด์ ํด์ผ๋๋... |
@@ -0,0 +1,134 @@
+package nextstep.subway.acceptance;
+
+import io.restassured.response.ExtractableResponse;
+import io.restassured.response.Response;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.http.HttpStatus;
+
... | Java | ๊ณต๊ฐ๊ณผ ๊ด๋ จ๋ ์๊ณ ๋ฆฌ์ฆ์ ํ
์คํธ๋ฅผ ํ๊ธฐ ๋๋ฌธ์
๋์ค์ ์์ ์ด ๋ณด๊ฑฐ๋ ๋ค๋ฅธ ๊ฐ๋ฐ์๊ฐ ์ด ํ
์คํธ ์ฝ๊ณ ํ์
ํ๊ธฐ๊ฐ ํ๋ค ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค.

์ด๋ฒ ๋จ๊ณ ์์์ ์๋ ๊ฒ ์ฒ๋ผ ์ฃผ์์ผ๋ก ํฝ์ค์ณ๋ฅผ ์ค๋ช
ํด์ฃผ๋ฉด ๋์ค์ ๋ค์ ๋ณด์์ ๋๋ ์ฝ๊ฒ ํ
์คํธ๋ฅผ ํ์
ํ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค :) |
@@ -0,0 +1,39 @@
+package nextstep.subway.unit;
+
+import nextstep.subway.applicaion.LineService;
+import nextstep.subway.applicaion.PathService;
+import nextstep.subway.applicaion.StationService;
+import nextstep.subway.domain.Station;
+import nextstep.subway.utils.TestObjectFactory;
+import org.junit.jupiter.api.Disp... | Java | ์ถ๊ฐ์ ์ผ๋ก ์์ธ ์ํฉ์ ๋ํด์ ํ
์คํธ๋ฅผ ํด์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค!

๋์ ์ ์ง๊ธ๊ณผ ๊ฐ์ด service layer์ ๋น์ฆ๋์ค ๋ก์ง์ด ๋ค์ด๊ฐ๊ฒ ๋๋ฉด ํ
์คํธ ํด๋ด์ ์์๊ฒ ์ง๋ง
service์์ ํ์ํ (test double์ด๋ ์ค์ ๊ฐ์ฒด๋ )์์กด์ฑ์ด ๊ฐ์ถฐ์ง ์ํ์์ ํ
์คํธ๋ฅผ ํด์ผํ๋ ํ
์คํธ ์์ฑ์ด ๋ฒ๊ฑฐ๋กญ๊ฑฐ๋ ๊น๋ค๋ก์์ง๋๋ฐ์.
์ฒซ๋ฒ์งธ ๋จ๊ณ์ ์๊ตฌ์ฌํญ์ ํตํด ๊ฒฝํ... |
@@ -0,0 +1,39 @@
+package nextstep.subway.unit;
+
+import nextstep.subway.applicaion.LineService;
+import nextstep.subway.applicaion.PathService;
+import nextstep.subway.applicaion.StationService;
+import nextstep.subway.domain.Station;
+import nextstep.subway.utils.TestObjectFactory;
+import org.junit.jupiter.api.Disp... | Java | ํด๋น ๋ฆฌ๋ทฐ๋ฅผ ๋ฐ์ํ๋ฉด์
`์ถ๋ฐ์ญ๊ณผ ๋์ฐฉ์ญ์ด ์ฐ๊ฒฐ์ด ๋์ด ์์ง ์์ ๊ฒฝ์ฐ` ์ ๋ํด pathService ์๋น์ค ๋ ์ด์ด mock ํ
์คํธ๋ฅผ ์ง๋๋ฐ,
์ด๋ฅผ pathService์์ ํ
์คํธํ๋ ค๋ stationService๋ฅผ ๋ชฉ์ฒ๋ฆฌํด๋ฌ์, ํ
์คํธ๋ฅผ ์ง๋ ค๋ฉด stationService.findById์์ ์๋ฌ๋ฅผ ๋์ง๋๋ก ๋ชฉ ํ
์คํธ๋ฅผ ์งํํด์ผ ํ์ต๋๋ค. ํ์ง๋ง, ์ด๋ ์ฝ๋์ ๋ํ ํ
์คํธ๋ฅผ ์ง๊ธฐ๋ณด๋ค๋ ํ
์คํธ๋ฅผ ์ํ ํ
์คํธ๋ผ๋ ์๊ฐ์ด ๋ค์ด์ ๊ฒฐ๊ตญ ์ด ๊ฒฝ์ฐ๋ ์ค์ ๊ฐ์ฒด ํ
์คํธ์์ ์งํํด์ผ ํ๋๋ฐ์.
์ด์ ๊ฐ์ ๊ฒฝ์ฐ๋ ์ ๊ฐ ํ ๊ฒ์ฒ๋ผ mockํ
์คํธ๋ฅผ ํผํ๋๊ฒ ๋ง๋ ๊ฒ์ธ์ง? ์๋๋ฉด ... |
@@ -0,0 +1,39 @@
+package nextstep.subway.unit;
+
+import nextstep.subway.applicaion.LineService;
+import nextstep.subway.applicaion.PathService;
+import nextstep.subway.applicaion.StationService;
+import nextstep.subway.domain.Station;
+import nextstep.subway.utils.TestObjectFactory;
+import org.junit.jupiter.api.Disp... | Java | @sang-eun
๋ค๋ค mock์ ์ฌ์ฉํ ํ
์คํ
์ ๊ฒฝ์ฐ ์์กดํ๋ ๊ฐ์ฒด๋ฅผ ๋งค๋ฒ ์ค์ ์ ํ๋ ๊ฒ์ด ๋งค์ฐ ๋ฒ๊ฑฐ๋กญ์ฃ ...!
๊ทธ๋์ ์ฒซ๋ฒ์งธ ๋จ๊ณ์์ ์๊ธฐ๋๋ ธ๋ฏ์ด ์ ๋ fake ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ๋ ๊ฑธ ์ ํธํ๋ ํธ์
๋๋ค!
์ง๊ธ๊ณผ ๊ฐ์ ๊ฒฝ์ฐ ๊ธธ์ ์ฐพ๋ ์ญํ ์ ๊ฐ๋ ๊ฐ์ฒด๋ฅผ ๋ฐ๋ก ๋ง๋ ๋ค๋ฉด ์ข ๋ ๊ฐ๋ฒผ์ด ํ
์คํ
์ด ๊ฐ๋ฅํ ๊ฒ ๊ฐ์ต๋๋ค!
(์ด๋ฏธ `Path` ๊ฐ์ฒด์์ ์ฒ๋ฆฌํ๋๋ก ํ์
จ๋ค์ ๐ ) |
@@ -0,0 +1,25 @@
+package com.example.chatgptcodereviewtest.controller;
+
+import com.example.chatgptcodereviewtest.dto.InputDto;
+import com.example.chatgptcodereviewtest.service.TestService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * ์ค๋ช
:
+ *
+ * @author ์ตํ๋ฒ(J... | Java | ์ ์ฝ๋ ์กฐ๊ฐ์์๋ `TestController` ํด๋์ค๋ฅผ ์ ์ํ๊ณ ์์ผ๋ฉฐ, ํด๋น ์ปจํธ๋กค๋ฌ์ `convertText` ๋ฉ์๋๋ `InputDto` ๊ฐ์ฒด๋ฅผ ๋ฐ์๋ค์ฌ `testService`์์ `addAgeAndNameLength` ๋ฉ์๋๋ฅผ ํธ์ถํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํฉ๋๋ค.
์ด ์ฝ๋ ์กฐ๊ฐ์ ๋ํ ์ฃผ์ ๊ฐ์ ์ ์์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
1. ์ปจํธ๋กค๋ฌ์ ์๋น์ค ํด๋์ค์ ์ด๋ฆ์ ๋ ๋ช
ํํ๊ฒ ๋ํ๋ผ ์ ์๋๋ก ๋ณ๊ฒฝํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
2. ์ปจํธ๋กค๋ฌ์์ ์ฌ์ฉ๋ ๊ฒฝ๋ก๋ช
(`"/test"`) ๋ฐ HTTP ๋ฉ์๋(`@PostMapping`)์ ๋ํด ์ถฉ๋ถํ ์ค๋ช
์ด ์์ผ๋ฏ๋ก API์ ์๋๋ฅผ ๋ ... |
@@ -0,0 +1,22 @@
+package com.example.chatgptcodereviewtest.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+/**
+ * ์ค๋ช
:
+ *
+ * @author ์ตํ๋ฒ(Jayce) / hb.choi@dreamus.io
+ * @since 2023/03/23
+ */
+@Getter
+@ToString
+@NoArgsConstructor
+@AllA... | Java | ์ ์ฝ๋๋ lombok ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ด์ฉํด InputDto ํด๋์ค๋ฅผ ์์ฑํ๊ณ ์๋ ๊ฒ์ผ๋ก ๋ณด์
๋๋ค.
๊ฐ์ ์ :
1. ํด๋์ค์ ๋ณ์ ์ด๋ฆ์ ๋ ๋ช
ํํ๊ฒ ์ ์ด์ฃผ๋ฉด ์ข๊ฒ ์ต๋๋ค.
2. Setter๊ฐ ์๊ธฐ ๋๋ฌธ์ name๊ณผ age์ ๋ํ ์ผ๋ถ ์ ๋ณด ๋ณ๊ฒฝ์ด ๋ถ๊ฐ๋ฅํฉ๋๋ค. ๋ฐ๋ผ์, ํด๋น DTO๋ฅผ ์ฌ์ฉํ๋ ํด๋์ค์์ ์ ์ดํ ์ ์๋๋ก Setter ๋ฉ์๋ ์ถ๊ฐ๋ฅผ ๊ณ ๋ คํด๋ณผ ํ์์ฑ์ด ์์ต๋๋ค.
๋ฒ๊ทธ ๊ฐ๋ฅ์ฑ:
ํ์ฌ ํด๋น ์ฝ๋์์ ๋ฒ๊ทธ๋ ๋ณด์ด์ง ์์ต๋๋ค. |
@@ -0,0 +1,20 @@
+package com.example.chatgptcodereviewtest.service;
+
+import com.example.chatgptcodereviewtest.dto.InputDto;
+import org.springframework.stereotype.Service;
+
+/**
+ * ์ค๋ช
:
+ *
+ * @author ์ตํ๋ฒ(Jayce) / hb.choi@dreamus.io
+ * @since 2023/03/23
+ */
+@Service
+public class TestService {
+
+ public int... | Java | ์์ ์ฝ๋ ๋ฆฌ๋ทฐ์ ๋ํ ์ ์๊ฐ์
๋๋ค.
๊ธฐ๋ฅ์ ์ผ๋ก ๋ฌธ์ ๊ฐ ์์ด ๋ณด์ด๋ฉฐ, ์ถ๊ฐ ๊ฐ์ ์ฌํญ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ช ๊ฐ์ง ์์ ์์ ์ฌํญ์ ์ ์ํด ๋๋ฆฌ๊ฒ ์ต๋๋ค:
- ์ฃผ์์ด ์์ธํ์ง ์์ ๋ณ๊ฒฝ ๋ ํ๋ก์ ํธ์ ๋ํด ์ถฉ๋ถํ ์ค๋ช
์ ์ ๊ณตํ์ง ์์ต๋๋ค. ๋ฉ์๋ ์ด๋ฆ 'addAgeAndNameLength' ์์ฒด๊ฐ ๊ธฐ๋ฅ์ ์ค๋ช
ํ๋ ๋ฐ ๋งค์ฐ ํฌ๊ด์ ์
๋๋ค. ์ข ๋ ๊ตฌ์ฒด์ ์ธ ๋ฉ์๋ ๋ฐ ํด๋์ค ์ค๋ช
๊ณผ ํจ๊ป ์ฃผ์์ ์ถ๊ฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
- ๋ชจ๋ ์์ธ๋ฅผ ์ฒ๋ฆฌ ํ ์ ์๋๋ก try-catch ๋ธ๋ก์ ์ถ๊ฐํ ์ ์์ต๋๋ค.
์์ธกํ ์์๋ ๊ฐ์ ์ ๋ฌํ์ฌ ์ถ๋ ฅ ๊ฐ์ด ์์๊ฐ๋๋ ๊ฒฝ์ฐ ๋ฑ ์ํ์ฑ์ด ... |
@@ -0,0 +1,32 @@
+package nextstep.subway.exception;
+
+import nextstep.subway.auth.application.AuthorizationException;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.anno... | Java | ๊ณตํต ์์ธ ์ฒ๋ฆฌ ์ข์ต๋๋ค. ๐ |
@@ -0,0 +1,50 @@
+package nextstep.subway.fare.domain;
+
+import java.util.Arrays;
+
+public enum DiscountPolicy {
+ ADULT(19, 500, 0, 0),
+ TEENAGER(13, 19, 350, 0.2),
+ CHILD(6, 13, 350, 0.5),
+ INFANT(0, 6, 0, 1);
+
+ private int ageStart;
+ private final int ageEnd;
+ private final int minusFar... | Java | ๋์ด์ ๋ฐ๋ฅธ ํ ์ธ ์๊ธ ๊ณ์ฐ ๋ก์ง ์ ๊ตฌํํด์ฃผ์
จ์ต๋๋ค. ๐
`ageStart`, `ageEnd`๋ ์ถฉ๋ถํ ๋ฌด์จ ์ญํ ์ ํ๋์ง ์ ์ ์๋ ์ด๋ฆ์ธ๋ฐ, ๋น๊ต์ ์ฌ์ฉ๋๋๊น ์ด์/์ด๊ณผ, ์ดํ/๋ฏธ๋ง ๊ตฌ๋ถ์ ์ํด `ageMinInclusive`, ageMaxExclusive`์ ๊ฐ์ด ์์ ํด๋ณด์
๋ ์ข๊ฒ ์ต๋๋ค. |
@@ -0,0 +1,50 @@
+package nextstep.subway.fare.domain;
+
+import java.util.Arrays;
+
+public enum DiscountPolicy {
+ ADULT(19, 500, 0, 0),
+ TEENAGER(13, 19, 350, 0.2),
+ CHILD(6, 13, 350, 0.5),
+ INFANT(0, 6, 0, 1);
+
+ private int ageStart;
+ private final int ageEnd;
+ private final int minusFar... | Java | ์์ธ๋ฅผ ๋ฐ์์ํฌ ๋ ์์ธ ๋ด์ฉ, ๋๋ฒ๊น
์ ํ์ํ ๊ฐ์ ๋ฉ์์ง๋ก ํจ๊ป ์ ๋ฌํ์๋ฉด, ๋ฌธ์ ์ํฉ์์ ์์ธ ์ถ์ ์ด ์์ํด์ ์ข์ต๋๋ค. :) |
@@ -0,0 +1,42 @@
+package nextstep.subway.fare.domain;
+
+import java.util.Arrays;
+
+public enum DistanceExtraFare {
+ NEAR(10, 50, 100, 5),
+ FAR(50, 500, 100, 8);
+
+ private final int distanceStart;
+ private final int distanceEnd;
+ private final int fare;
+ private final int unitDistanceInKiloMe... | Java | 16km๋ฅผ ๊ฐ๋ ๊ฒฝ์ฐ ์ถ๊ฐ ์๊ธ์ ((16 - 10) / 5) * 100 = 100์์ด ๋ ๊ฒ ๊ฐ์์!
์ฐธ๊ณ ๋งํฌ์ ์๋ ๊ฐ๊ณผ ๊ฒฐ๊ณผ๊ฐ ๋ค๋ฅธ ๊ฒ ๊ฐ์ต๋๋ค.
> http://www.seoulmetro.co.kr/kr/page.do?menuIdx=354
๋ฏธ์
ํ์ด์ง์ ์๋ ์์ ์ฌ์ฉํด์ ์ถ๊ฐ ์๊ธ์ ๊ณ์ฐํด๋ณด์๋ฉด ์ข๊ฒ ์ต๋๋ค. :)
> https://edu.nextstep.camp/s/urD8knTu/ls/4r6iyUcO |
@@ -0,0 +1,44 @@
+package nextstep.subway.fare.domain;
+
+import java.util.Objects;
+
+public class Fare {
+ private static final int basicFare = 1250;
+
+ private int fare;
+ private final DiscountPolicy discountPolicy;
+
+ private Fare(int fare, DiscountPolicy discountPolicy) {
+ this.fare = fare;
... | Java | ๊ฐ ๊ฐ์ฒด ์ฌ์ฉ ์ข์ต๋๋ค. ๐
๊ณ ๋ฏผํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ ๋ถ๋ถ์, `Fare` ํด๋์ค๋ฅผ ์ฌ์ฉํ๋ ์ฌ๋์ด `plus`, `discount` ์์๋ฅผ ์ ์๊ณ ํธ์ถํด์ผ ์๊ธ ๊ณ์ฐ์ด ์ ์์ ์ผ๋ก ๋ ๊ฒ ๊ฐ์์. ๊ทธ๋ฆฌ๊ณ , ํ ์ธ ์ ์ฑ
์ ์์ฑํ๋ ์์ ์ ๋ฐ์ง๋ง, ์ค์ ๋ก๋ ์ถ๊ฐ ์๊ธ ๊ณ์ฐ์ด ๋๋ ํ ์ฌ์ฉ์ด ๋์ด์ผ ํ๋ค์.
์๊ธ ๊ณ์ฐ์ `FareCalculator`๊ฐ ๋ด๋นํ๋ ๊ฒ์ผ๋ก ๋ณด์ด๋, `DiscountPolicy`๋ฅผ ์๊ธ ๊ณ์ฐ ๋ฉ์๋์์ ๊ด๋ฆฌํด๋ณด์
๋ ์ข๊ฒ ์ต๋๋ค. :) |
@@ -17,12 +17,11 @@
import java.util.stream.Collectors;
@Service
-@Transactional(readOnly = true)
+@Transactional
public class FavoriteService {
private final String MESSAGE_FAVORITE_ENTITY_NOT_FOUND = "์ฆ๊ฒจ์ฐพ๊ธฐ๊ฐ๊ฐ ์กด์ฌํ์ง ์์ต๋๋ค";
-
private FavoriteRepository favoriteRepository;
private MemberService mem... | Java | ์ต๋จ ๊ฒฝ๋ก๋ฅผ ์กฐํํ๋ ๋ฉ์๋๊ฐ ์๊ธ ๊ณ์ฐ๋ ํ๊ธฐ ๋๋ฌธ์ `memberId`๊ฐ ํ์ํ๊ฒ ๋ ๊ฑธ๊น์?
๊ฒฝ๋ก ์กฐํ์ ์๊ธ ๊ณ์ฐ์ ๋ถ๋ฆฌํด๋ด๋ ์ข์ ๊ฒ ๊ฐ๋ค์! :) |
@@ -1,14 +1,16 @@
package nextstep.subway.path.application;
import nextstep.subway.line.domain.Section;
+import nextstep.subway.path.domain.SectionEdge;
+import nextstep.subway.path.domain.ShortestPath;
import nextstep.subway.station.domain.Station;
-import org.jgrapht.graph.DefaultWeightedEdge;
+import org.jgraph... | Java | ์ฌ์ฉ์ฒ๊ฐ ์์ด์ง ๊ฒ ๊ฐ์ผ๋, ์ด ๋ฉ์๋๋ฅผ ํฌํจํด `PathFindAlgorithm`์ `findShortestPathStations`๋ฅผ ์ญ์ ํ์๋ฉด ์ข๊ฒ ์ต๋๋ค. :) |
@@ -1,8 +1,12 @@
package nextstep.subway.path.application;
+import nextstep.subway.fare.domain.FareCalculator;
import nextstep.subway.line.domain.Section;
import nextstep.subway.line.domain.SectionRepository;
import nextstep.subway.line.dto.PathResponse;
+import nextstep.subway.member.application.MemberService;
+... | Java | ๊ฒฝ๋ก ๊ณ์ฐํ๋ ๋ถ๋ถ๊ณผ ์๊ธ ๊ณ์ฐํ๋ ๋ก์ง์ ์ ๋ถ๋ฆฌํ ์ ์๊ฒ ๊ตฌํํ์ ๊ฒ์ผ๋ก ๋ณด์ฌ์.
์ค์ ๋ก ๋ด๋นํ๋ ํด๋์ค๋ฅผ ๋๋ ๋ณด๋ฉด ์ด๋จ๊น์? `FavoriteService` ์์๋ ๊ฒฝ๋ก๊ฐ ์กด์ฌํ๋์ง๋ง ํ์ธํ๋ฉด ๋๋ ์ฌ์ฌ์ฉ๋ ์ข ๋ ํจ์จ์ ์ผ๋ก ํ ์ ์์ ๊ฒ ๊ฐ๋ค์! |
@@ -1,14 +1,13 @@
package nextstep.subway.path.ui;
+import nextstep.subway.auth.domain.AuthenticationPrincipal;
+import nextstep.subway.auth.domain.LoginMember;
import nextstep.subway.line.dto.PathResponse;
-import nextstep.subway.member.dto.MemberRequest;
-import nextstep.subway.member.dto.MemberResponse;
import ... | Java | ๋ก๊ทธ์ธํ์ง ์์ ๊ฒฝ์ฐ์๋ ๊ฒฝ๋ก๋ฅผ ์กฐํํ ์ ์์ด์ผ ํ ๊ฒ ๊ฐ์์.
์ด๋ฅผ ์ํด AuthenticationPrincipal์ ์ธ์ฆ์ด ํ์ํ์ง ์ฌ๋ถ ํ๋๋ฅผ ์ถ๊ฐํ๊ณ , ์ด๋ฅผ ํตํด ์ธ์ฆ์ ํ์ง ์์ ํ์๋ ์ฌ์ฉํ ์ ์๋ ๊ธฐ๋ฅ(๊ฒฝ๋ก ์กฐํ ๋ฑ)๊ณผ ์ธ์ฆ์ ํด์ผ๋ง ์ฌ์ฉํ ์ ์๋ ๊ธฐ๋ฅ(ํ์ ์ ๋ณด ๋ณ๊ฒฝ ๋ฑ)์์ ๋ชจ๋ LoginMember๋ฅผ ์ด์ฉํ ์ ์๋๋ก ๊ด๋ฆฌํด๋ณด์๋ฉด ์ข๊ฒ ์ต๋๋ค.
> https://edu.nextstep.camp/s/urD8knTu/ls/4r6iyUcO
"/paths ์์ฒญ ์ LoginMember ๊ฐ์ฒด ์ฒ๋ฆฌ" ๋ถ๋ถ์ ์ฐธ๊ณ ๋ถํ๋๋ฆฝ๋๋ค. |
@@ -1,7 +1,111 @@
package lotto;
+import camp.nextstep.edu.missionutils.Console;
+import lotto.domain.*;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
public class Application {
+ private static final String REQUEST_PURCHASE_AMOUNT = "๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.";
+ private s... | Java | ์์ฃผ ํน๋ณํ ๊ฒฝ์ฐ๊ฐ ์๋๋ผ๋ฉด, static๋ณ์๋ฅผ ๋ง๋ค๊ณ , ๊ทธ ๊ฐ์ ๊ด๋ฆฌํ๋ application์ ๋ง๋๋ ๊ฒ์ ์ข์ ๋ฐฉ๋ฒ์ ์๋๋๋ค. ์๋ํ๋ฉด, ์ด๋ ๊ฒ ํ์๋ฉด, ํ๋์ ์ดํ๋ฆฌ์ผ์ด์
์ lottery๋ณ์๋ ํ๋๋ฐ์ ์๊ฒ ๋๊ณ , ๊ทธ๋ ๊ฒ ๋๋ฉด, ๋ ๋ช
์ด์์ด ์ด ๋ก์ง์ ์ฌ์ฉํ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ์๊ธธ ์ ์๊ธฐ ๋๋ฌธ์
๋๋ค. ์ฆ ํ์ฅ์ฑ์ ๋ฌธ์ ๊ฐ ์๊น๋๋ค. |
@@ -1,7 +1,111 @@
package lotto;
+import camp.nextstep.edu.missionutils.Console;
+import lotto.domain.*;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
public class Application {
+ private static final String REQUEST_PURCHASE_AMOUNT = "๊ตฌ์
๊ธ์ก์ ์
๋ ฅํด ์ฃผ์ธ์.";
+ private s... | Java | ```suggestion
private static boolean setLottery() {
System.out.println(REQUEST_PURCHASE_AMOUNT);
int price = getNumber();
if (price % 1000 != 0) {
System.out.println("[ERROR] ์ฒ์ ๋จ์๋ก ์
๋ ฅํด์ฃผ์ธ์.");
return false;
}
lottery = price / 1000;
... |
@@ -0,0 +1,80 @@
+## ๋ก๋
+
+### ๊ท์น
+1. ๋ก๋ ๋ฒํธ์ ์ซ์ ๋ฒ์๋ 1~45๊น์ง ์ด๋ค.
+2. ๋ก๋ ๋ฒํธ๋ ์ด 6๊ฐ์ ์ซ์๋ก ์ด๋ฃจ์ด์ ธ์๋ค.
+3. ๋ณต๊ถ์ ํ์ฅ๋น 1,000์์ด๋ค.
+4. ์ฌ์ฉ์๋ ๊ตฌ์
ํ ๋ณต๊ถ ์ฅ ์ ๋งํผ ๋น์ฒจ์ ๊ณ์ฐํ๋ค.
+5. ์ฌ์ฉ์๋ ๋น์ฒจ ๋ฒํธ์ ๋ณด๋์ค ๋ฒํธ๋ฅผ ์
๋ ฅํ๋ค.
+6. ๊ตฌ๋งคํ ๋ก๋ ๋ฒํธ์ ๋น์ฒจ ๋ฒํธ๋ฅผ ๋น๊ตํ์ฌ ๋น์ฒจ ๊ธฐ์ค์ ๋ฐ๋ผ ๊ธ์ก์ ๋ฐ๋๋ค. ๋น์ฒจ ๊ธฐ์ค๊ณผ ๊ธ์ก์ ์๋์ ๊ฐ๋ค.
+ - 1๋ฑ: 6๊ฐ ๋ฒํธ ์ผ์น / 2,000,000,000์
+ - 2๋ฑ: 5๊ฐ ๋ฒํธ + ๋ณด๋์ค ๋ฒํธ ์ผ์น / 30,000,000... | Unknown | ~~์ด ๋ถ๋ถ์ด ๊ถ๊ธํ๊ฒ ์๋๋ฐ, ์ผ๋ฐ์ ์ผ๋ก ์ฐ๋ฆฌ๊ฐ ๋ก๋๋ฅผ ์ด ๋๋ ๊ทธ๋ฅ ์ซ์ 6๊ฐ๋ฅผ ์ ํํ๊ณ , 2๋ฑ์ ๋ฝ์ ๋, ๋ณด๋์ค ๋ฒํธ๋ฅผ ์ถ์ฒจํด์ ๋น๊ตํ๋๋ฐ, ์ด๊ฒ๊ณผ๋ ๋ค๋ฅธ ์๊ตฌ์ฌํญ์ด์๋ ๊ฒ์ธ๊ฐ์?~~
์ // ์ฝ๋ ํ์ธํ์ต๋๋ค. WinningLotto๋ผ๋ ํด๋์ค๊ฐ ์๋ ๊ฒ์ด๊ตฐ์. |
@@ -0,0 +1,65 @@
+package oncall.domain.date;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class Day {
+ private static final String WEEK_HOLIDAY_MESSAGE = "(ํด์ผ) ";
+
+ private final Month month;
+ private final Date date;
+ private final DayOfWeek da... | Java | ์ ๋ ๋์น ๋ถ๋ถ์ด๊ธด ํ๋ฐ, "(ํด์ผ)"์ ๋ถ์ด๋ ๊ฒฝ์ฐ๊ฐ ๋ฌด์กฐ๊ฑด ๊ณตํด์ผ์ธ ๊ฒฝ์ฐ์ ๋ถ์ด๋ ๊ฒ์ด ์๋๋ผ ์ฃผ๋ง์ด ์๋ ๊ณตํด์ผ์๋ง ๋ถ์ด๋ ์กฐ๊ฑด์ด๋๋ผ๊ตฌ์..! |
@@ -0,0 +1,54 @@
+package oncall.domain.employee;
+
+import java.util.List;
+import oncall.util.exception.ErrorMessage;
+import oncall.util.exception.MyIllegalArgumentException;
+
+public class EmployeeRepository {
+ private static final int MIN_EMPLOYEES_NUMBER = 5;
+ private static final int MAX_EMPLOYEES_NUMBE... | Java | ์ค๋ณตํ์ธ ๋ก์ง์ ๋ฉ์๋๋ก ๋ถ๋ฆฌํ ๊ฒ ์ฒ๋ผ ๊ธธ์ด ๊ฒ์ฆ๋ ๋ฉ์๋๋ก ๋ถ๋ฆฌํ๋ฉด ์ข์ ๊ฑฐ ๊ฐ๋ค์! |
@@ -0,0 +1,33 @@
+package oncall.domain.schedule;
+
+import java.util.List;
+import oncall.domain.date.Day;
+import oncall.domain.employee.Employee;
+
+public class DaySchedule {
+ private final Day day;
+ private final Employee employee;
+
+ public DaySchedule(Day day, Employee employee) {
+ this.day =... | Java | ์ด๋ถ๋ถ ์๋ฐ ์ปจ๋ฒค์
์ ๋ฐ๋ผ ์นด๋ฉ์ผ์ด์ค๋ฅผ ์ฌ์ฉํ๋๊ฒ ์ข์ ๊ฑฐ ๊ฐ๊ตฐ์! ์๋๋ฉด ํน์ ์ด๋ถ๋ถ๋ง ์ค๋ค์ดํฌ์ผ์ด์ค๋ฅผ ์ฌ์ฉํ์ ์ด์ ๊ฐ ์์ผ์ ๊ฑธ๊น์? |
@@ -0,0 +1,33 @@
+package oncall.domain.schedule;
+
+import java.util.List;
+import oncall.domain.date.Day;
+import oncall.domain.employee.Employee;
+
+public class DaySchedule {
+ private final Day day;
+ private final Employee employee;
+
+ public DaySchedule(Day day, Employee employee) {
+ this.day =... | Java | @Override ์ ๋
ธํ
์ด์
์ ๋ถ์ฌ์ฃผ๋ ๊ฒ์ด ์ข์ ๊ฑฐ ๊ฐ์์ |
@@ -0,0 +1,24 @@
+package oncall.util.exception;
+
+public enum ErrorMessage {
+ WRONG_DELIMITER ("[ERROR]", "๊ตฌ๋ถ์๋ฅผ ์๋ชป ์
๋ ฅํ์
จ์ต๋๋ค. ์ฝค๋ง(,) ๋ฅผ ์ฌ์ฉํด์ฃผ์ธ์."),
+ NOT_NUMBER ("[ERROR]", "์์๋ ์ซ์๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์."),
+ NOT_DAY_OF_WEEK ("[ERROR]", "์๋ชป๋ ์์ผ์ ์
๋ ฅํ์ต๋๋ค."),
+ WRONG_MONTH_VALUE("[ERROR]", "์์๋ 0~12์ ์ซ์๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์."),
+ WRO... | Java | ์์๋ 1~12์ ์ซ์๋ฅผ ์
๋ ฅํด๋ฌ๋ผ๋ ๋ฉ์ธ์ง๊ฐ ๋ง์ง ์๋์? |
@@ -0,0 +1,60 @@
+package oncall.view;
+
+
+import camp.nextstep.edu.missionutils.Console;
+import java.util.List;
+import oncall.util.converter.ViewConverter;
+import oncall.util.exception.ErrorMessage;
+import oncall.util.exception.MyIllegalArgumentException;
+import oncall.view.dto.InputMonthAndDayDto;
+
+public cla... | Java | ์ฌ์ํ๊ธด ํ์ง๋ง ์์ ์
๋ ฅ ํํ๋ณด๋ฉด "๋น์ ๊ทผ๋ฌด๋ฅผ ๋ฐฐ์ ํ ์๊ณผ ์์ ์์ผ์ ์
๋ ฅํ์ธ์> " ๋ฉ์์ง ๋ฐ๋ก ์์์๋ถํฐ ์
๋ ฅํ ์ ์๋ ํํ์
๋๋ค!
System.out.println(...) ๋์ System.out.print() ๋ฅผ ์ฌ์ฉํ๋ฉด ์์ฒ๋ผ ํ์ค ๋ฐ์ด์ ์
๋ ฅ๋ฐ๋๊ฒ ์๋๋ผ ์ถ๋ ฅํ๊ณ ๋ฐ๋ก ๋ค์ ์
๋ ฅ๋ฐ์ ์ ์์ต๋๋ค |
@@ -0,0 +1,78 @@
+package oncall.domain.schedule;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import oncall.domain.date.Month;
+
+public class MonthSchedule {
+ private final Month month;
+ private final List<DaySchedule> daySchedules;
+
+ public MonthSchedule(M... | Java | ์ด ๋ถ๋ถ์์ ์ฌ๊ท๋ฅผ ํ์ถํ์ง ๋ชปํด ์คํ์ค๋ฒํ๋ก์ฐ๊ฐ ๋ฐ์ํ๊ณ ์์ด์..! |
@@ -0,0 +1,31 @@
+package oncall.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import oncall.domain.date.Day;
+import oncall.domain.employee.Employee;
+import oncall.domain.employee.EmployeeProvider;
+import oncall.domain.schedule.DaySchedule;
+import oncall.domain.schedule.MonthSchedule;
+
+public c... | Java | ์ ๋ฒํผ๋ ์ด๋ค ์ญํ ์ ํ๋์? |
@@ -0,0 +1,24 @@
+package oncall.util.exception;
+
+public enum ErrorMessage {
+ WRONG_DELIMITER ("[ERROR]", "๊ตฌ๋ถ์๋ฅผ ์๋ชป ์
๋ ฅํ์
จ์ต๋๋ค. ์ฝค๋ง(,) ๋ฅผ ์ฌ์ฉํด์ฃผ์ธ์."),
+ NOT_NUMBER ("[ERROR]", "์์๋ ์ซ์๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์."),
+ NOT_DAY_OF_WEEK ("[ERROR]", "์๋ชป๋ ์์ผ์ ์
๋ ฅํ์ต๋๋ค."),
+ WRONG_MONTH_VALUE("[ERROR]", "์์๋ 0~12์ ์ซ์๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์."),
+ WRO... | Java | ```suggestion
private static final String prefix = "[ERROR] ";
```
ํญ์ `prefix` ๋ถ๋ถ์ ์ค๋ณต๋๊ธฐ์ ํด๋น ๋ถ๋ถ์ ์์๋ก ์ถ์ถํ๋ ๊ฒ๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ๋ค๊ณ ์๊ฐํด์. |
@@ -0,0 +1,43 @@
+package oncall.domain.date;
+
+import java.util.Arrays;
+import oncall.util.exception.ErrorMessage;
+import oncall.util.exception.MyIllegalArgumentException;
+
+public enum Month {
+ JAN(1, 31),
+ FEB(2, 28),
+ MAR(3, 31),
+ APR(4, 30),
+ MAY(5,31),
+ JUN(6, 30),
+ JUL(7, 31),
+ ... | Java | ํด๋น ํด๋์ค๋ `java.time.Month` enum์ผ๋ก ์๋ฒฝํ ๋์ฒด ๊ฐ๋ฅํ ๊ฒ ๊ฐ์ต๋๋ค!
(๋ฌผ๋ก ์ ๋ ์ด ์ฌ์ค์ ์ํ์ด ๋๋ ํ ๊นจ๋ฌ์์ต๋๋ค...ใ
ใ
) |
@@ -0,0 +1,43 @@
+package oncall.domain.date;
+
+import java.util.Arrays;
+import java.util.Objects;
+import oncall.util.exception.ErrorMessage;
+import oncall.util.exception.MyIllegalArgumentException;
+
+public enum DayOfWeek {
+ SUN(0, "์ผ"), MON(1, "์"), TUE(2, "ํ"), WED(3, "์"),
+ THU(4, "๋ชฉ"), FRI(5, "๊ธ"), SA... | Java | `code`๋ฅผ ๊ธฐ์ค์ผ๋ก ์ ๋ ฌ๋ ๋ฐฐ์ด, ๋๋ ๋ฆฌ์คํธ๋ฅผ ๋ฏธ๋ฆฌ ์บ์ฑํด ๋๋ค๋ฉด ๋ฐ๋ณต์ ์ธ `getNextDayOfWeek()` ํธ์ถ ์ํฉ์์ ๋งค๋ฒ `Stream` ๊ฐ์ฒด๋ฅผ ์์ฑํ์ง ์์๋ ๋๋ฉฐ `code`๋ฅผ ์ฌ์ฉํด ์ธ๋ฑ์ค๋ก ์ ๊ทผ๋ง ํ๋ฉด ๋๊ธฐ์ ์ฑ๋ฅ์ด ํจ์ฌ ์ข์์ง ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,32 @@
+package oncall.domain.employee;
+
+import java.util.Objects;
+import oncall.util.exception.ErrorMessage;
+import oncall.util.exception.MyIllegalArgumentException;
+
+public class Employee {
+ private final String name;
+
+ public Employee(String name) {
+ validateEmployeeName(name);
+ ... | Java | ์์ ์ถ์ถ์ด ๊ฐ๋ฅํ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,17 @@
+package oncall.domain.employee;
+
+import java.util.List;
+
+public class EmployeeGenerator {
+ public static List<WeekWorkEmployee> generateWeekWorkEmployees(List<String> input) {
+ return input.stream()
+ .map(WeekWorkEmployee::new)
+ .toList();
+ }
+
+ ... | Java | ์ดํ๋ฆฌ์ผ์ด์
์์ ๋ ๊ฐ์ ์๋ก ๋ค๋ฅธ ํด๋์ค๋ก ๊ตฌ๋ถ๋๋ `WeekWorkEmployee`์ `WeekendWorkEmployee`๊ฐ ๊ธฐ๋ฅ์ ์ธ ์ฐจ์ด๊ฐ ์์ด ๋ณด์ด๋๋ฐ์.
๋์ผํ `Employee`๋ฅผ ๋ณ์ ๋ช
์ผ๋ก ๊ตฌ๋ถํด ์ฃผ๋ ๋์ ๋ณ๋์ ํด๋์ค๋ก ๊ตฌํํ์ ์ด์ ๊ฐ ์์๊น์? |
@@ -0,0 +1,54 @@
+package oncall.domain.employee;
+
+import java.util.List;
+import oncall.util.exception.ErrorMessage;
+import oncall.util.exception.MyIllegalArgumentException;
+
+public class EmployeeRepository {
+ private static final int MIN_EMPLOYEES_NUMBER = 5;
+ private static final int MAX_EMPLOYEES_NUMBE... | Java | getter๋ฅผ ํตํด ์ธ๋ถ์ ์ปฌ๋ ์
์ ํฌ๊ธฐ๋ฅผ ๋
ธ์ถ์ํค๋ ๋์ , `getXXXEmployees(int index)` ๋ฉ์๋์์ % ๋๋จธ์ง ์ฐ์ฐ์ ํจ๊ป ์ํํด ์ฃผ๋ ๊ฒ์ ์ด๋จ๊น์?
์ธ๋ถ์์๋ ์ด ํด๋์ค๋ฅผ ์ด์ฉํ ๋ ๋ด๋ถ์์ ์ด๋ค ์์ผ๋ก ์์๋ฅผ ์ ์ง์ํจ ์ฑ ๋ฐ๋ณต์ ์ผ๋ก ๋ฉค๋ฒ๋ฅผ ํ์ํ๋์ง์ ๊ตฌํ์ ์ ๊ฒฝ์ฐ์ง ์๊ณ "`index` ๋ฒ์งธ์ ๊ทผ๋ฌด์"๋ฅผ ๊ตฌํ ์ ์์ ๊ฒ ๊ฐ์์!
์ด๋ ๊ฒ ๋๋ฉด ์ธ์ ๊ฐ ๋ด๋ถ ์๋ฃ๊ตฌ์กฐ๊ฐ `List<>`์์ ๋ฐฐ์ด๋ก ๋ณ๊ฒฝ๋๋ ๋ฑ์ ๋ณํ๊ฐ ์๋๋ผ๋ ์ธ๋ถ ์ฝ๋๊ฐ ๋ณ๊ฒฝ๋์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,11 @@
+package oncall.domain.date;
+
+public class DayGenerator {
+ public static Day generateFirstDay(Month month, DayOfWeek firstDayOfWeek) {
+ return new Day(month, new Date(1), firstDayOfWeek);
+ }
+
+ public static Day generateDay(Day day) {
+ return day.makeNextDay();
+ }
+} | Java | ๋ ์ง๋ฅผ ์์ฑํด ์ฃผ๋ ์ญํ ์ ์ํํ๋ ์ ์ ์ ํธ ํด๋์ค์ฒ๋ผ ๋ณด์ด๋๋ฐ์.
์ ๋ "๋ ์ง ๊ฐ์ฒด ์์ฑ" ์ญ์ ๋ ์ง ๊ฐ์ฒด ์ค์ค๋ก์ ์ฑ
์์ด๋ผ๊ณ ์๊ฐํด์.
๋๋ฌธ์ `generateFirstDay()` ๋ฉ์๋๋ ๋จ์ํ `Day.of(Month, DayOfWeek)`์ ํํ๋ฅผ ๊ฐ์ง๋ ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋๋ก๋ง ๊ตฌํํด๋ ๊ด์ฐฎ์ง ์์์๊น ์๊ฐํฉ๋๋ค.
์ด๋ ๊ฒ ๊ตฌํํด ์ค๋ค๋ฉด `DayGenerator` ํด๋์ค๋ฅผ `Day` ํด๋์ค์ ๋ณํฉํด ์ค ์ ์์ ๊ฒ ๊ฐ์์. |
@@ -3,83 +3,63 @@
import homeTry.chatting.dto.request.ChattingMessageRequest;
import homeTry.chatting.dto.response.ChattingMessageResponse;
import homeTry.chatting.exception.badRequestException.InvalidTeamIdException;
-import homeTry.chatting.model.entity.Chatting;
import homeTry.chatting.repository.ChattingReposit... | Java | Chatting์ TeamMember์ ์ฐ๊ด๊ด๊ณ๋ฅผ ๋งบ๊ณ ์์ผ๋, TeamMember์ ๋ํ ์ ๋ณด๋ง์ ์๊ณ ์์ต๋๋ค.
Chatting์์ Team ๋๋ Member์ ๋ํ ์ ๋ณด๋ฅผ ์ป๊ณ ์ ํ๋ค๋ฉด,, TeamMemberService๋ฅผ ๋จ์ผ ์ง์
์ ์ผ๋ก ํ์ฉํ๋ฉด ์ด๋จ๊น์? ๐ฒ |
@@ -1,8 +1,12 @@
package homeTry.chatting.interceptor;
+import homeTry.chatting.exception.badRequestException.InactivatedMemberWithValidTokenException;
import homeTry.chatting.exception.badRequestException.InvalidChattingTokenException;
-import homeTry.common.auth.JwtAuth;
+import homeTry.chatting.exception.badRequ... | Java | StompInterceptor๋ ํ ํฐ ์ ๋ณด๋ฅผ ๋ณด๊ณ , ๋ฉค๋ฒ๊ฐ ์กด์ฌํ์ง ์์ผ๋ฉด,, Exception์ ๋ฑ๋๋ก ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
๊ทธ๋ ๋ค๋ฉด, stompInterceptor๋ ํ ํฐ์ด bearerToken์ธ์ง, ๋ค๋ฅธ ํ ํฐ์ ์ข
๋ฅ์ธ์ง? ์ ๋ํด์๋ ์๋ฌด๋ฐ ๊ด์ฌ์ฌ๊ฐ ์์ต๋๋ค. BearerToken์ด ์ ํจํ์ง? ๋ ๊ด์ฌ์ฌ๊ฐ ์์ต๋๋ค. ๋จ์ํ ํ์ฌ interceptor์ ๋์ด์จ ํ ํฐ ์ ๋ณด๋ฅผ ๋ณด๊ณ , ์ฐ๋ฆฌ ์ฌ์ฉ์๋ผ๋ฉด ์ธ์
์ ๊ทธ ๊ฐ์ ๋ฃ๋ ๊ฒ์ ๊ด์ฌ์ด ์์ต๋๋ค.
์ด๋ ๊ฒ ๊ฐ ํด๋์ค์ ๊ด์ฌ์ฌ๋ค์ ์๊ฐํ๋ฉฐ ์ ์ ํ๊ฒ ๋ถ๋ฆฌํ๊ณ , ์บก์ํ ํด๋ณด์๋ฉด ์ฌ๋ฏธ์์ ๊ฒ ๊ฐ์์ ๐ |
@@ -0,0 +1,49 @@
+package lotto.domain;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class LottoGame {
+ private static final int TICKET_PRICE = 1000;
+
+ List<LottoTicket> lottoTickets;
+ LottoMatch lottoMatch;
+
+ public LottoGame() {
+ this.lottoTicke... | Java | ์ ๊ทผ ์ ํ์๋ฅผ ๋ถ์ด๋๊ฒ ์ข์ ๊ฒ ๊ฐ๋ค์. |
@@ -0,0 +1,28 @@
+package lotto.domain;
+
+import stringcalculator.Operation;
+
+public enum LottoMatchNumber {
+ MATCH3(3, 5000) {int totalPrizeMoney(int count) {return prizeMoney * count;}},
+ MATCH4(4, 50000) {int totalPrizeMoney(int count) {return prizeMoney * count;}},
+ MATCH5(5, 1500000) {int totalPrize... | Java | enum๋ ๋น์ฆ๋์ค ๋ก์ง์ ์ผ๋ถ์ด๋ฏ๋ก view ๋ถ๋ถ์ ๊ตฌํ์ enum์ ๋๋๊ฑด ์ข์ง ์์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,28 @@
+package lotto.domain;
+
+import stringcalculator.Operation;
+
+public enum LottoMatchNumber {
+ MATCH3(3, 5000) {int totalPrizeMoney(int count) {return prizeMoney * count;}},
+ MATCH4(4, 50000) {int totalPrizeMoney(int count) {return prizeMoney * count;}},
+ MATCH5(5, 1500000) {int totalPrize... | Java | ๋ฑ์๋ณ๋ก ๋ชจ๋ ๋์ผํ ๊ตฌํ์ฒด๋ฅผ ๊ฐ์ง ๊ฒ ๊ฐ์๋ฐ์. ์ถ์ ๋ฉ์๋๋ก ์ ์๋ ํ์๊ฐ ์๋์ง ๊ณ ๋ฏผ์ด ํ์ํด๋ณด์ฌ์.
๊ทธ๋ฆฌ๊ณ ํ์ฌ ๋ก๋ ๋๋ฉ์ธ์์ enum์ด ๋ก๋์ ๋ฑ์๋ณ ๊ฐ์ ๋ฐ ๋น์ฒจ ๊ธ์ก์ ๋ํ๋ด๋ ์ญํ ์ ํ๊ณ ์์ต๋๋ค. ๊ณ ์ ๋ ์์๋ค๋ง ๊ฐ์ง๋๊ฒ ์๋๋ผ ๋ฐ์ ๊ฐ์๋งํผ ๊ณฑํด์ ๊ณ์ฐํด์ฃผ๋ ์ญํ ์ ๊ฐ์ง๋๊ฒ ์ ์ ํ ์ง๋ ๊ณ ๋ฏผํด๋ณด์๋ฉด ์ข๊ฒ ๋ค์. |
@@ -0,0 +1,49 @@
+package lotto.domain;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class LottoGame {
+ private static final int TICKET_PRICE = 1000;
+
+ List<LottoTicket> lottoTickets;
+ LottoMatch lottoMatch;
+
+ public LottoGame() {
+ this.lottoTicke... | Java | ์ค์ํ ๋ถ๋ถ์ ์๋์ง๋ง Stream.generate๋ฅผ ํตํด ๋ถ๋ณ ํํ๋ก ํํํ ์ ์์ ๊ฒ ๊ฐ๋ค์. ๊ฐ๋ณ๋ณด๋ค๋ ๋ถ๋ณ ํํ๋ก ํํํ๋๊ฒ ์ฌ์ด๋ ์ดํํธ๋ ์ ๊ณ ๊ฐ๋
์ฑ ์ธก๋ฉด์์๋ ์ข์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,49 @@
+package lotto.domain;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class LottoGame {
+ private static final int TICKET_PRICE = 1000;
+
+ List<LottoTicket> lottoTickets;
+ LottoMatch lottoMatch;
+
+ public LottoGame() {
+ this.lottoTicke... | Java | ์ผ๋ฐ์ ์ผ๋ก ๋ฉ์๋ ๋ฆฌํด ํ์
์ด๋ ํ๋ผ๋ฏธํฐ ๋ฑ์ ๋คํ์ฑ ์ธก๋ฉด์์ ์ด์ ์ด ์๊ธฐ ๋๋ฌธ์ ๊ตฌ์ฒด ํ์
(HashMap)์ ์ฌ์ฉํ์ง ์์ต๋๋ค. ์ด์ ๊ฐ ์๋๊ฒ ์๋๋ผ๋ฉด ์ธํฐํ์ด์ค์ธ Map์ ๋ฆฌํด ํ์
์ผ๋ก ์ฐ์๋๊ฒ ์ด๋จ๊น์? |
@@ -0,0 +1,49 @@
+package lotto.domain;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+public class LottoGame {
+ private static final int TICKET_PRICE = 1000;
+
+ List<LottoTicket> lottoTickets;
+ LottoMatch lottoMatch;
+
+ public LottoGame() {
+ this.lottoTicke... | Java | ์ด๋ฐ ํํ๋ก ์ฌ์ฉํ ๊ฑฐ๋ฉด ์ธ์คํด์ค ๋ณ์ ์์ด ๋ฐ๋ก ๋ฆฌํดํ๋ ํํ๋ก ์ฌ์ฉํ๋ฉด ์ด๋จ๊น์? |
@@ -0,0 +1,47 @@
+package lotto.domain;
+
+
+import java.util.*;
+
+public class LottoMatch {
+
+ List<Integer> targetNumbers;
+
+
+ public LottoMatch(String input) {
+ targetNumbers = new ArrayList<>();
+ String[] inputs = input.split(", ");
+
+ for (int i = 0; i < inputs.length; i++) {
+ ... | Java | Stream์ groupingBy๋ Function.identity๋ฅผ ํ์ฉํด๋ณด์๋ ์ข์ ๊ฒ ๊ฐ๋ค์. |
@@ -0,0 +1,47 @@
+package lotto.domain;
+
+
+import java.util.*;
+
+public class LottoMatch {
+
+ List<Integer> targetNumbers;
+
+
+ public LottoMatch(String input) {
+ targetNumbers = new ArrayList<>();
+ String[] inputs = input.split(", ");
+
+ for (int i = 0; i < inputs.length; i++) {
+ ... | Java | ์์ฑ์๋ ์ด๋ฏธ ์์ฑ์ด๋ ์ฑ
์์ ๊ฐ์ง๊ณ ์๋๋ฐ ์์ฑ์ ๋ด๋ถ์์ split์ ํตํ ํ์ฑ ๋ฐ ์ฌ๋ฌ ์ฑ
์์ด ํฌํจ๋์ด ์๋ค์.
์์ฑ์์ ๋ก์ง์ ๋ฃ๊ณ ์ถ๋ค๋ฉด ์ ์ ํฉํฐ๋ฆฌ๋ก ๋ถ๋ฆฌํ๊ณ ์ ์ ํฉํฐ๋ฆฌ์ ๋ก์ง์ ์ถ๊ฐํ ๋ค ๊ฑฐ๊ธฐ์ ์์ฑ์๋ฅผ ํธ์ถํ๊ฑฐ๋ ํ๋ ํํ๋ก ๊ตฌํํ๋๊ฑด ์ด๋จ๊น์? |
@@ -0,0 +1,65 @@
+package lotto.domain;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class LottoTicket {
+
+ private static final int PICK_NUMBERS = 6;
+
+ List<Integer> lottoNumbers;
+
+ public LottoTicket() {
+ this.lottoNumbers = new ArrayList<>();
+... | Java | ์ ์ฝ ์กฐ๊ฑด ๊ฒ์ฆ์ด ์ ํ ํฌํจ๋์ด ์์ง ์๋ค์. ๋๋ฉ์ธ์ ํน์ฑ์ ์ ๋ํ๋ด์ง ๋ชปํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
1. 1 - 45๊น์ง์ ์ซ์๋ง ์กด์ฌํด์ผ ํจ
2. 6๊ฐ์ ์ค๋ณต๋์ง ์์ ์ซ์๋ก ์ด๋ฃจ์ด์ ธ์ผ ํจ
์์ ๊ฐ์ด ๋ก๋ ๋๋ฉ์ธ์ ํน์ฑ์ด ํด๋์ค์ ๋ฐ์๋๋๋ก ์ค๊ณํด๋ณด์๋ฉด ์ข๊ฒ ์ต๋๋ค. |
@@ -0,0 +1,106 @@
+package chess.database.dao;
+
+import chess.dto.game.ChessGameLoadDto;
+import chess.dto.game.ChessGameSaveDto;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public final class DbChessGameDao implements ChessDao {
+
+ private final String url;
+ private final Str... | Java | Jdbc Connection ๊ด๋ฆฌ๋ฅผ Dao์์ ํด์ฃผ๊ณ ๊ณ์๋ค์! ๊ทธ๋ฐ๋ฐ ๊ด๋ฆฌํด์ผ ํ ํ
์ด๋ธ์ด ๋์ด๋์ ์ฌ๋ฌ Dao ๊ฐ์ฒด๊ฐ ์๊ฒจ๋๊ฒ ๋๋ฉด ์ค๋ณต๋๋ ์ฝ๋์ธ ์ธ์คํด์ค ๋ณ์๋ค์ด ๋ฐ์ํ๊ฒ ๋ ๊ฒ ๊ฐ์์.
์ ๋ ์ฒด์ค๋ฏธ์
์ ์งํํ๋ฉฐ ๋ฆฌ๋ทฐ์ด๋ถ๊ป ๋ฆฌ๋ทฐ๋ฐ์ ์ฌํญ์ธ๋ฐ DB Connection๊ณผ ๊ฐ์ resource ๊ด๋ฆฌ ์ฝ๋๋ฅผ Util ํด๋์ค ๋ฑ์ผ๋ก ๊ตฌ๋ถํด์ ๊ด๋ฆฌํด๋ณด์๋ ๊ฑด ์ด๋จ์ง ์ ์๋๋ ค๋ด
๋๋ค! |
@@ -0,0 +1,106 @@
+package chess.database.dao;
+
+import chess.dto.game.ChessGameLoadDto;
+import chess.dto.game.ChessGameSaveDto;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public final class DbChessGameDao implements ChessDao {
+
+ private final String url;
+ private final Str... | Java | Dao์์ NullPointerException์ ๋ฌด์ํ๋ ๊ฒ์ ๋ฆฌ๋ทฐ์ด๋ฅผ ์ํ ๋ฐฐ๋ ค์ผ๊น์? ใ
ใ
๊ทธ๊ฒ ์๋๋ผ๋ฉด ์ด๋ค ์๋๋ก ์์ธ๋ฅผ ๋ฌด์์ฒ๋ฆฌํด์ฃผ์ ๊ฑด์ง ๊ถ๊ธํฉ๋๋ค~ |
@@ -1,7 +1,97 @@
-# java-chess
+## ์ ์ฒด ์๋๋ฆฌ์ค
-์ฒด์ค ๋ฏธ์
์ ์ฅ์
+1. start๋ฅผ ์
๋ ฅ ๋ฐ์ผ๋ฉด ๊ฒ์์ ์์ํ๋ค.
+ - [์์ธ] ๊ฒ์์ด ์์ํ์ง ์์๋๋ฐ move๋ฅผ ์
๋ ฅํ๋ฉด ์์ธ๊ฐ ๋ฐ์ํ๋ค.
+2. move sourcePosition targetPosition์ ์
๋ ฅ ๋ฐ์ ๊ธฐ๋ฌผ์ ์์ง์ธ๋ค.
+ - [์์ธ] ๊ฒ์ ์งํ ์ค์ start๋ฅผ ์
๋ ฅํ๋ฉด ์์ธ๊ฐ ๋ฐ์ํ๋ค.
+3. status๋ฅผ ์
๋ ฅ ๋ฐ์ ๊ฐ ์ง์์ score๋ฅผ ์ถ๋ ฅํ๊ณ ์นํจ๋ฅผ ์ถ๋ ฅํ๋ค.
+4. ํน์ด ๋จผ์ ์กํ๋ ์ง์์ด ํจํ๊ณ , ์ฆ์ ๊ฒ์์ ์ข
๋ฃํ๋ค.
+5. end๋ฅผ... | Unknown | DDL ๋ช
์ ์ข์์~
์ ๋ ๋ฆฌ๋ทฐ์ด ๋ถ๊ป ๋ฆฌ๋ทฐ๋ฐ์ ์ฌํญ ์ค ํ๋๋ฅผ ๋ง์๋๋ฆฌ๋ฉด ํ์ฌ chess_game ํ
์ด๋ธ์์ ๊ด๋ฆฌ๋๋ ๋ฐ์ดํฐ๋ค์ ๋ณด๋ฉด ํ
์ด๋ธ ๋ช
์ด chess_game์ด ์๋๋ผ piece๊ฐ ๋์ด์ผ ํ์ง ์์๊น ํ๋ ๊ฒ์
๋๋ค. |
@@ -43,7 +43,7 @@ set JAVA_EXE=java.exe
if "%ERRORLEVEL%" == "0" goto execute
echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo ERROR: JAVA_HOME is not set and no 'java' gameCommand could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in yo... | Unknown | ์...? ์ด ํ์ผ์ command ๋ผ๋ ๋จ์ด๋ฅผ ์ ์ฒด ์นํํ๋ค๊ฐ ๊ฐ์ด ์์ ๋์ด ๋ฒ๋ฆฐ ๊ฒ ๊ฐ์ ๋ณด์ฌ์~ |
@@ -0,0 +1,12 @@
+package chess.database;
+
+public final class DbInfo {
+
+ public static String service_url = "jdbc:mysql://127.0.0.1:13306/chess?useSSL=false&serverTimezone=UTC";
+ public static String service_user = "root";
+ public static String service_password = "root";
+
+ public static String test_... | Java | ์ด ํด๋์ค์์ connection์ ๋ง๋ค์ด์ ๋์ ธ์ฃผ๋ ๊ฑด ์ด๋จ๊น์? |
@@ -0,0 +1,21 @@
+package chess;
+
+import chess.controller.ChessController;
+import chess.view.IOViewResolver;
+import chess.view.InputView;
+import chess.view.OutputView;
+
+import java.util.Scanner;
+
+public final class MainApp {
+
+ public static void main(String[] args) {
+ try (Scanner scanner = new Sc... | Java | ์์๊ด๋ฆฌ ์ฟ ์ธ ๐ |
@@ -0,0 +1,70 @@
+package chess.controller;
+
+import chess.domain.game.File;
+import chess.domain.game.Position;
+import chess.domain.game.Rank;
+
+import java.util.Arrays;
+import java.util.List;
+
+public enum GameCommand {
+ INIT,
+ START,
+ FIRST_MOVE,
+ MOVE,
+ STATUS,
+ END;
+
+ public stati... | Java | ์ฒ์ GameCommand ํด๋์ค๋ฅผ ๋ณด๋๋ฐ Position์ ๊ตฌํ๋ ์ฝ๋๋ค์ด ์ ์ฌ๊ธฐ์ ๋ค์ด๊ฐ ์์๊น๊ฐ ์ข ๊ถ๊ธํ์์ต๋๋ค. ์๋ง ํํฌ๊ฐ input์ผ๋ก ๋ค์ด์จ command๋ฅผ ๊ฐ์ง๊ณ position์ ๊ตฌํ๋ ๊ธฐ๋ฅ์ด๋ผ๊ณ ์๊ฐํด์ GameCommand๋ก ๋ถ๋ฆฌํ์ ๊ฒ ๊ฐ์์.
์ ๋ผ๋ฉด ํด๋น ๊ธฐ๋ฅ๋ค์ file, rank, Position Enum์์ ์ฑ
์์ ์ง๋๋ก ํ์ ๊ฒ ๊ฐ์๋ฐ ํํฌ ์๊ฒฌ์ ์ด๋ ์ ์ง ๊ถ๊ธํด์~ |
@@ -0,0 +1,113 @@
+package chess.domain.game;
+
+import chess.domain.piece.Empty;
+import chess.domain.piece.Piece;
+import chess.domain.piece.PieceType;
+import chess.domain.piece.Team;
+import chess.domain.piece.pawn.BlackPawn;
+import chess.domain.piece.pawn.WhitePawn;
+import chess.dto.mapper.ParseToDto;
+import ch... | Java | pawn์ ๋ํ ์ฒ๋ฆฌ ๋ก์ง์ ํฌํจํด์ ๊ธฐ๋ฌผ ์ด๋ ๋ก์ง์ด ์ ๋ง ๊น๋ํ๋ค์! ๐ฏ |
@@ -0,0 +1,31 @@
+//
+// SceneDelegate.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+
+class SceneDelegate: UIResponder, UIWindowSceneDelegate {
+
+ var window: UIWindow?
+
+
+ func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UISce... | Swift | ํ์์๊ฑฐ๋ ์ฌ์ฉํ์ง ์๋ ๋ฉ์๋๋ ํ๋จํ์ฌ ์ญ์ ํ๋๊ฒ๋ ์ข์ ๊ฑฐ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | ์ขํ ์์ ํ ๊ฐ๋ฅ์ฑ์ด ์๋ค๋ฉด ์์๋ก ์ ์ธํ๋ ๊ฒ๋ ์ข์๋ณด์
๋๋ค |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | ๊ฐ์ธ์ ์ผ๋ก ํ์ ๊ฐ์ฒด๋ ํ๋กํ ์ฝ๋ค์ ๋ค๋ฅธ ํ์ผ๋ก ๋ถ๋ฆฌํ๋ ๊ฒ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค
์ ๋ ๋ถ๋ฆฌํ์ ๋ ์ถํ์ ์ฝ๋ ์์ ์ ์ฐพ์๊ฐ๊ธฐ ์ฌ์์ ์ข์์ต๋๋ค |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | ํ๋ผ๋ฏธํฐ๋ฅผ ์ค๋ก ๋๋ ์ฃผ์ ๋ฐฉ์ ์ฝ๊ธฐ ํธํ๊ณ ๊น ๊ด๋ฆฌํ๊ธฐ ์์ํ๋ค์
์ ๋ ์นดํผ์นดํผ ํด๋๋ ๊น์? |
@@ -0,0 +1,32 @@
+//
+// Rectangle.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/30.
+//
+
+import Foundation
+
+class Rectangle : RectangleComponent {
+ let id:String
+ let size:RectangleSize
+ let position:RectanglePosition
+ let backGroundColor:(red:Int, green:Int, blue:Int)
+ let alpha:In... | Swift | Color ํํํ์์ผ๋ก ํ๋ฒ์ ์ฌ๋ฌ๊ฐ์ ํ๋ผ๋ฏธํฐ๋ฅผ ๋ฐ์ ์ ์๋์ง ๋ชฐ๋๋ค์
ํ ์ ๋ฐฐ์๊ฐ์ |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | ๋ชจ๋ธ ํ์ ํ์
์ ํด๋์ค๋ก ํ์
จ๋๋ฐ ์ ํํ์ ๊ธฐ์ค์ด ์๋์ง ๊ถ๊ธํด์ |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | ๋ง์ฝ ์ธ๋ถ์์ ๋ฐ๋์ ์ ๊ทผํด์ผ๋ง ํ๋ค๋ฉด private์ ๋นผ๋๊ฒ๋ ์ข์๋ณด์
๋๋ค |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | class func ๋์ static func์ ์ฐ์ ์ด์ ๋ ์ค๋ฒ๋ผ์ด๋ฉ์ด ๋ถ๊ฐ๋ฅํ๋๋ก ์๋ํ์ ๊ฑฐ ๋ง์๊น์?๐๐ป |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | [UIScreen.main ๊ณต์๋ฌธ์](https://developer.apple.com/documentation/uikit/uiscreen/1617815-main)
์ฐ์ฐํ Apple Documentation์์ ๋ฐ๊ฒฌํ๋๋ฐ, main์ Deprecated ๋์๋๋ผ๊ณ ์
์๋จ ๊ณต์๋ฌธ์ ๋ด์ฉ์์ ์ถ์ฒํ๋ ๋ค๋ฅธ๋ฐฉ๋ฒ์ ์ฌ์ฉํด๋ณด์๋ ๊ฒ๋ ์ข์๊ฑฐ๊ฐ์์ |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | ํ์ต ๊ฐ์ด๋์์ ์ฐธ๊ณ ํ๋๋ฐ,
๋ฉ์๋ ๋ค์ด๋ฐ์ ํจ์๋ก ์์ฑํ๋๊ฒ ์ข๋ค๊ณ ๋์ด์์ด ์ฐธ๊ณ ํ์๋ฉด ์ข์ ๋ณด์
๋๋ค |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | uuid ์์ด ๋ง๋๋ ๋ฐฉ์์ด ์๋์ง๋ ๋ชฐ๋๋๋ฐ, ์ ์ ํ๊ณ ๋ ๊น๋ํ ๋ฐฉ์์ด๋ค์๐๐ป |
@@ -0,0 +1,91 @@
+//
+// ViewController.swift
+// DrawingApp
+//
+// Created by ๊นํ๋ฆผ on 2023/03/28.
+//
+
+import UIKit
+import OSLog
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let rect1 = RectangleFactory.createRectangle()
+ os... | Swift | ํ๋กํ ์ฝ์ ์ ์ธ๋ ํ๋กํผํฐ๋ค์ ์ฑํํ์ ๋ private ์ ๊ทผ์ ์ด์๋ฅผ ์ฌ์ฉํ์ง ๋ชปํ๋ ๊ฑธ๋ก ์๊ณ ์์ต๋๋ค.
์ ๊ทผ์ ์ด์๊ฐ ํ์ํ ์์๋ค๋ง ํ๋กํ ์ฝ์ ์ถ๊ฐํ๋ ๊ฒ๋ ์ข์ ๋ณด์
๋๋ค. |
@@ -0,0 +1,47 @@
+import { FollowUserType, followList } from '@/types/types';
+import axios from 'axios';
+import { SetterOrUpdater } from 'recoil';
+
+const PER_PAGE = 100;
+export const getFollowingList = async (setFollowings: SetterOrUpdater<followList[]>, tokenValue: string) => {
+ try {
+ const followingData =... | TypeScript | ํ๋ก์์ด 100๋ช
์ด ๋์ผ๋ฉด ํน์ ์ด๋ป๊ฒ ๋๋์? |
@@ -0,0 +1,47 @@
+import { FollowUserType, followList } from '@/types/types';
+import axios from 'axios';
+import { SetterOrUpdater } from 'recoil';
+
+const PER_PAGE = 100;
+export const getFollowingList = async (setFollowings: SetterOrUpdater<followList[]>, tokenValue: string) => {
+ try {
+ const followingData =... | TypeScript | Github API ์์๋ [API ๋ฒ์ ๋์ ์ํด ํค๋์ API ๋ฒ์ ์ ๋ณด๋ฅผ ํฌํจ์์ผ ์์ฒญ](https://docs.github.com/en/rest/about-the-rest-api/api-versions?apiVersion=2022-11-28)ํ๋ ๊ฒ์ ๊ถ์ฅํ๊ณ ์์ด์. ์ด๋ฅผ ์ถ๊ฐํด์ฃผ๋๊ฒ ์ข์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,47 @@
+import { FollowUserType, followList } from '@/types/types';
+import axios from 'axios';
+import { SetterOrUpdater } from 'recoil';
+
+const PER_PAGE = 100;
+export const getFollowingList = async (setFollowings: SetterOrUpdater<followList[]>, tokenValue: string) => {
+ try {
+ const followingData =... | TypeScript | ์ด๋ฐ ๋ฐฉ๋ฒ๋ ์์ด์!
```suggestion
const { data } = followingData;
``` |
@@ -0,0 +1,47 @@
+import { FollowUserType, followList } from '@/types/types';
+import axios from 'axios';
+import { SetterOrUpdater } from 'recoil';
+
+const PER_PAGE = 100;
+export const getFollowingList = async (setFollowings: SetterOrUpdater<followList[]>, tokenValue: string) => {
+ try {
+ const followingData =... | TypeScript | try catch ๋ฌธ์ ์ผ๋ฐ์ ์ผ๋ก ์๋ฌ ์ํฉ์์ ์๋ฌ๋ฅผ ๋ณต๊ตฌํด ์ ์ ๋์์ ์ํค๊ฑฐ๋, ๋ก๊น
ํ๋ ์ฉ๋๋ก ์ฌ์ฉ๋ผ์. ๊ทธ๋ฐ๋ฐ ํ์ฌ์ ๊ฐ์ด ํน๋ณํ ๋ชฉ์ ์ด ์์ง ์๋ try catch ๋ฌธ์ ์คํ๋ ค ๋๋ฒ๊ทธํ ๋ ์์ฒญ ํท๊ฐ๋ฆฌ๊ฒ ๋ ์ ์์ด ๊ถ์ฅํ์ง ์์์. |
@@ -0,0 +1,47 @@
+import { FollowUserType, followList } from '@/types/types';
+import axios from 'axios';
+import { SetterOrUpdater } from 'recoil';
+
+const PER_PAGE = 100;
+export const getFollowingList = async (setFollowings: SetterOrUpdater<followList[]>, tokenValue: string) => {
+ try {
+ const followingData =... | TypeScript | ํ์ฌ ์ด๋ ๊ฒ recoil ์ setter ๋ฅผ ๋ฐ์ ์ฌ์ฉํ๋๋ก ๋์ด์๋ ์ํฉ์์๋ ์์์์ ํญ์ recoil๊ณผ ํจ๊ป ์ฌ์ฉํด์ผ ํ๋ ์์กด์ฑ์ด ์๊ฒจ์ ํจ์์ ์ฌ์ฉ ๋ฐฉ์์ด ํน์ ๋ฐฉ๋ฒ์ผ๋ก ๊ฐ์ ๋ผ์. ๊ทธ๋ฐ๋ฐ ๊ทธ๋ด ํ์๊ฐ ์์๊น์? ๋ง์ฝ recoil์ด ์๋ useState๋ฅผ ์ฌ์ฉํ๋๋ก ๋ณ๊ฒฝ๋๋ค๋ฉด ์ด๋ป๊ฒ ๋ ๊น์?
๊ทธ๋ฆฌ๊ณ ์ด ํจ์๋ ํ๋ฒ์ ๋ ๊ฐ์ง ์ผ์ ํ๊ณ ์์ด์.
1. ์๋ฒ์์ ํ๋ก์ ๋ชฉ๋ก์ ๋ถ๋ฌ์จ๋ค.
2. Follower ์ํ์ ๊ฐ์ ์ค์ ํ๋ค.
getFollowerList ํจ์๋ฅผ ์๋ฒ์์ ํ๋ก์ ๋ชฉ๋ก์ ๋ถ๋ฌ์ค๋ ์ญํ ๋ง ํ๊ฒ ํ๊ณ , ๊ฐ ์ค์ ์ ์ด ํจ์๋ฅผ ์ฌ์ฉํ๋ ์ชฝ... |
@@ -0,0 +1,35 @@
+'use client';
+
+import FollowList from '@/components/checkfollow/FollowList';
+import { useRecoilValue, useSetRecoilState } from 'recoil';
+import FollowOrNotBtn from '../../components/checkfollow/FollowOrNotBtn';
+import Profile from '../../components/checkfollow/Profile';
+import { putFollowList } ... | Unknown | ํ์ด์ง๋ฅผ ์ ์ฒด ์๋ก๊ณ ์นจํ๋ฉด ํฐ ์ฑ๋ฅ์์ ์ด์๊ฐ ์์ ๊ฒ ๊ฐ์๋ฐ, ํน์ ์ด๋ ๊ฒ ํ ์ด์ ๊ฐ ๋ฌด์์ผ๊น์? |
@@ -0,0 +1,89 @@
+'use client';
+
+import { getFollowerList, getFollowingList } from '@/apis/getFollowList';
+import { checkState, followState, followerList, followingList, inputToken, loginClick } from '@/recoil/atoms';
+import { followList } from '@/types/types';
+import { useEffect } from 'react';
+import { useRecoi... | Unknown | ์ํ์ useEffect๋ฅผ ์ฌ์ฉํ๋ฉด ์ ํํ ์ธ์ useEffect ์์ชฝ์ด ํธ์ถ๋๋์ง ์ถ์ ํ๊ธฐ ํ๋ ๋ฌธ์ ๊ฐ ์์ด์.
์ด ๊ฒฝ์ฐ์๋ [๊ณต์ ๋ฌธ์์์ ์ ์ํ๋ ๊ฒ](https://react.dev/learn/you-might-not-need-an-effect#sharing-logic-between-event-handlers) ์ฒ๋ผ ๋ก์ง์ follow ๋ฒํผ์ด ์ ํ๋๋ ๊ณณ์ผ๋ก ์ฎ๊ธฐ๋ ๊ฒ์ด ์ข์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,27 @@
+'use client';
+
+import { followState } from '@/recoil/atoms';
+import { useSetRecoilState } from 'recoil';
+
+export default function FollowOrNotBtn() {
+ const setBtnState = useSetRecoilState(followState);
+
+ const onClickFollow = () => {
+ setBtnState('follow');
+ };
+
+ const onClickNotFol... | Unknown | ์ฌ๊ธฐ์๋ FollowOrNotBtn ์ปดํฌ๋ํธ๊ฐ onChange ๋ฑ์ ํ๋กญ์ผ๋ก ์์ ์ปดํฌ๋ํธ์ ์ํ ๋ณ๊ฒฝ์ ์๋ฆฌ๊ณ , ํด๋น ์ปดํฌ๋ํธ์์ ์ฒ๋ฆฌํ๋๋ก ๋ณ๊ฒฝํ๋๊ฒ ์ข์ ๊ฒ ๊ฐ์์.
๊ด๋ จ๋ PR: https://github.com/SimSimS-ToyProject-TEAM3/SimSimS-ToyProject-TEAM3/pull/24#discussion_r1436797019 |
@@ -0,0 +1,34 @@
+export interface ProfileType {
+ login: string;
+ avatar_url: string;
+ bio: string;
+ followers: number;
+ following: number;
+}
+
+export interface followList {
+ id: number;
+ login: string;
+ avatar_url: string;
+ onClick?: () => void;
+}
+export interface FollowUserType {
+ avatar_url: ... | TypeScript | ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋๋ ํ์
์คํฌ๋ฆฝํธ์ ์ปจ๋ฒค์
์ฒ๋ผ, ํ์ค์นผ ์ผ์ด์ค๋ก ์์ฑํ๋ฉด ์ข์ ๊ฒ ๊ฐ์์.
https://basarat.gitbook.io/typescript/styleguide#interface |
@@ -0,0 +1,89 @@
+'use client';
+
+import { getFollowerList, getFollowingList } from '@/apis/getFollowList';
+import { checkState, followState, followerList, followingList, inputToken, loginClick } from '@/recoil/atoms';
+import { followList } from '@/types/types';
+import { useEffect } from 'react';
+import { useRecoi... | Unknown | ์ ๋ถ๋ถ์์ recoil selector ๋ฅผ ํ์ฉํด ๋ณผ ์๋ ์์ ๊ฒ ๊ฐ์์.
```tsx
const followerIdSelector = selector({
key: 'followerIdSelector',
({ get }) => {
const followers = get(followerList);
return followers.map(user => user.id);
}
});
``` |
@@ -0,0 +1,14 @@
+import { useRouter } from 'next/navigation';
+
+export default function ConfirmFollowButton() {
+ const router = useRouter();
+
+ const handleOnclick = () => {
+ router.push('/checkfollow');
+ };
+ return (
+ <div className="commonFlex followBackButton hover:bg-grey02" onClick={handleOnclic... | Unknown | onClick ์ผ๋ก ๋งํฌ๋ฅผ ์ฒ๋ฆฌํ๋ฉด HTML ํ๊ทธ์์ ๋งํฌ๋ฅผ ๋ณผ ์ ์๊ณ , ์ปจํธ๋กค + ํด๋ฆญ, ์ฐํด๋ฆญ ๋ฑ์ ๋์์ด ๋จนํ์ง ์๋ ์ ๊ทผ์ฑ ์ด์๊ฐ ์์ด์. ๋ฐ๋ผ์ ์ฌ์ดํธ ๋ด ํ์ด์ง ์ด๋ ๋งํฌ๋ next/link ๋ฅผ ์ฌ์ฉํด์ผ ํด์.
```tsx
<Link href="/checkfollow" className="commonFlex followBackButton hover:bg-grey02">
๋์ ๋งํ ํ์ธํ๋ฌ ๊ฐ๊ธฐ
</Link> |
@@ -0,0 +1,46 @@
+import { ProfileType, followList } from '@/types/types';
+import { atom } from 'recoil';
+import { recoilPersist } from 'recoil-persist';
+const { persistAtom } = recoilPersist();
+
+export const profileInfo = atom<ProfileType>({
+ key: 'profileInfo',
+ default: {
+ login: '',
+ avatar_url: ''... | TypeScript | ๋ฏธ์ธ ํ: ์ด๋ฆ์ suffix๋ก Atom ์ ๋ถ์ด๋ฉด ์ปดํฌ๋ํธ์์ ์ด๋ฅผ ํ์ฉํ ๋ ์ด๋ฆ ์ถฉ๋ ๋ฌธ์ ์์ ์์ ๋ก์์ง ์ ์์ด์.
```tsx
// ์ ์ธ
export const profileInfoAtom = atom<ProfileType>({
key: 'profileInfo',
default: {
login: '',
avatar_url: '',
bio: '',
followers: 0,
following: 0,
},
});
// ์ฌ์ฉํ ๋
const profileInfo = useRecoilV... |
@@ -0,0 +1,47 @@
+import { FollowUserType, followList } from '@/types/types';
+import axios from 'axios';
+import { SetterOrUpdater } from 'recoil';
+
+const PER_PAGE = 100;
+export const getFollowingList = async (setFollowings: SetterOrUpdater<followList[]>, tokenValue: string) => {
+ try {
+ const followingData =... | TypeScript | ๊ฑด์์ด๊ฐ [์ฌ๊ธฐ](https://github.com/sopt-web-advanced-study/TOY-PROJECT/pull/13/files#r1436888989)์ ๋จ๊ฒจ์ฃผ๊ธด ํ๋๋ฐ์! ์ฌ๊ธฐ์ ํ์
์ camelCase๋ก ์ง์ด์ฃผ๋ค ๋ณด๋,
`followList`์ `followingList`๋ ๊ฐ๊ฐ ํ์
, ๋ณ์๋ก ์์ ๋ค๋ฅธ ์๋ฏธ๋ก ์ฌ์ฉ๋๋๋ฐ์, ํ ๋์ ํ์
ํ๊ธฐ๊ฐ ์ด๋ ค์ ์ด์! ๊ฐ ์ฉ๋์ ๋ฐ๋ผ ์ปจ๋ฒค์
์ ๋ง๊ฒ ์ด๋ฆ์ ์ง์ด์ฃผ๋ฉด ์ข์ ๊ฒ ๊ฐ์์. |
@@ -0,0 +1,47 @@
+import { FollowUserType, followList } from '@/types/types';
+import axios from 'axios';
+import { SetterOrUpdater } from 'recoil';
+
+const PER_PAGE = 100;
+export const getFollowingList = async (setFollowings: SetterOrUpdater<followList[]>, tokenValue: string) => {
+ try {
+ const followingData =... | TypeScript | (๊ฑด์์ด๊ฐ ์จ์ค to-be์ ์ธ์์ setFollowers๋ ๋น ์ง๋๊ฑธ ์๋ํ๊ฑธ๊ฑฐ์์!)
```tsx
export const getFollowerList = async (tokenValue: string) => { ... }
``` |
@@ -0,0 +1,47 @@
+import { FollowUserType, followList } from '@/types/types';
+import axios from 'axios';
+import { SetterOrUpdater } from 'recoil';
+
+const PER_PAGE = 100;
+export const getFollowingList = async (setFollowings: SetterOrUpdater<followList[]>, tokenValue: string) => {
+ try {
+ const followingData =... | TypeScript | ๋ง์ฝ console.error๋ก ๋ง ๋จ๊ฒจ๋๊ณ ์ถ์๋๋ผ๋ ์ด๋ ๊ฒ ํ๋ฉด ํ๋์ฝ๋ฉ๋ 'error'๋ง ๋จ๊ฒ๋์ด ํท๊ฐ๋ฆด ๊ฒ ๊ฐ์์.
`error.message`๋ฅผ ์ฐ๊ฑฐ๋([mdn ์์](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Error#%EC%9D%BC%EB%B0%98%EC%A0%81%EC%9D%B8_%EC%98%A4%EB%A5%98_%EB%8D%98%EC%A7%80%EA%B8%B0)), ์๋๋ฉด ๋ณดํต [Sentry](https://docs.sentry.io/platform... |
@@ -0,0 +1,35 @@
+'use client';
+
+import FollowList from '@/components/checkfollow/FollowList';
+import { useRecoilValue, useSetRecoilState } from 'recoil';
+import FollowOrNotBtn from '../../components/checkfollow/FollowOrNotBtn';
+import Profile from '../../components/checkfollow/Profile';
+import { putFollowList } ... | Unknown | ์ ์ฒด ์๋ก๊ณ ์นจ์ ํ๋ฉด ์ฌ์ฉ์ ๊ฒฝํ ์ธก๋ฉด์์๋ ์ข์ง ์์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,89 @@
+'use client';
+
+import { getFollowerList, getFollowingList } from '@/apis/getFollowList';
+import { checkState, followState, followerList, followingList, inputToken, loginClick } from '@/recoil/atoms';
+import { followList } from '@/types/types';
+import { useEffect } from 'react';
+import { useRecoi... | Unknown | ๋ง์ฝ ์์ ์ด ์ผ์ด๋๊ฒ ๋์๋, onClickRemove๊ฐ ์ด๋ ์์ ์ ์คํ๋๋์ง์ ๋ํ ๊ณ ๋ ค๊ฐ ํญ์ ์ด๋ค์ ธ์ผ ํด์ ์ฌ์ด๋ ์ดํํธ๊ฐ ์๊ฒจ ๋ณ๊ฒฝํ๊ธฐ๋ ์์ฃผ ๊น๋ค๋ก์ ์ง๋ ๋ฌธ์ ๊ฐ ์์ด์.
>๋ก์ง์ follow ๋ฒํผ์ด ์ ํ๋๋ ๊ณณ์ผ๋ก ์ฎ๊ธฐ๋ ๊ฒ์ด ์ข์ ๊ฒ ๊ฐ์์.
์๋ ๊ฒ ํด์ผ ํด๋น ๋ก์ง์ด ์คํ๋๋ ์์ ์๋ง onClickRemove๊ฐ ์คํ๋จ์ด ๋ณด์ฅ๋๊ธฐ ๋๋ฌธ์ ์ฌ์ด๋ ์ดํํธ๋ฅผ ์ต์ํํ ์ ์์ต๋๋น |
@@ -0,0 +1,89 @@
+'use client';
+
+import { getFollowerList, getFollowingList } from '@/apis/getFollowList';
+import { checkState, followState, followerList, followingList, inputToken, loginClick } from '@/recoil/atoms';
+import { followList } from '@/types/types';
+import { useEffect } from 'react';
+import { useRecoi... | Unknown | ๋๋ฒ๊น
์ฉ์ผ๋ก ์ฌ์ฉํ ๋ค์์ ์ง์ฐ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ท ใ
ใ
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.