-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
๐ 3๋จ๊ณ - ์ฆ๊ฒจ์ฐพ๊ธฐ ๊ธฐ๋ฅ ๊ตฌํ #352
base: epicarts
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์๋ ํ์ธ์ ์ํธ๋!
3๋จ๊ณ ๋ฏธ์ ์ ์ํด์ฃผ์ จ๋ค์! ๐
๋ช๊ฐ์ง ์ฝ๋ฉํธ ๋จ๊ฒผ์ผ๋ ํ์ธํด์ฃผ์๊ณ ๋ค์ ๋ฆฌ๋ทฐ ์์ฒญ ์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค ๐
๋๊น์ง ๋ฆฌ๋ทฐ ์์ฒญ ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค! ๐
.orElseThrow(IllegalArgumentException::new); | ||
|
||
Member member = memberService.findByEmail(loginMember.getEmail()); | ||
member.removeFavorite(favorite); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
member.removeFavorite(favorite); ํด์ฃผ์
จ๋๋ฐ์! ํ์ธํด๋ณด๋ favorites ์์ ์ต์
์ด orphanRemoval = true ๋ก ๋์ด ์๋๊ฑธ ๋ดค์ต๋๋ค! ๊ณ ์๊ฐ์ฒด๊ฐ ๋ favorite ๋ ๊ฐ์ด delete ๋ ๊ฒ์ผ๋ก ์์ ๋๋๋ฐ์!
55 line ์ favoriteRepository.delete(favorite); ๋ถ๋ถ์ด ํ์ํ ๊น์? ๐ง
import static nextstep.member.domain.exception.FavoriteException.SAME_SOURCE_AND_TARGET; | ||
|
||
@Entity | ||
public class Favorite { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํ์ฌ member ์ ๋ํ ์ ๋ณด๋ Favorite ์์ ์ ์ ์๋ค๊ณ ๋ณด๋๋ฐ์!
JPA ์์ ์ธ๋ํค๊ฐ ์์ด๋ OneToMany ์ ManyToOne ๊ด๊ณ๊ฐ ๋งบ์ด์ง ์ ์๋์ง ๊ถ๊ธํฉ๋๋ค!
์ง์ ์ฐธ์กฐ๋ ๊ฐ์ ์ฐธ์กฐ๋ฅผ ํ์ง ์์๋ ๋ ๊น์? ๐ง
ํ
์คํธ์์ ๋์ค๋ ์ฟผ๋ฆฌ๋ฅผ ํ์ธํด๋ณธ ๊ฒฐ๊ณผ
update
favorite
set
member_id=?
where
id=?
๋ก ์
๋ฐ์ดํธ ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ฆฌ๊ณ ์๋๋ฐ์. favorite ์๋ memberId ๊ฐ ์์์๋ ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ฆฌ๊ณ ์์ต๋๋ค!
ํ๋ฒ ํ์ธํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค ๐
} | ||
|
||
public Favorite addFavorite(Station source, Station target) { | ||
Favorite favorite = new Favorite(source, target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
member domain ์์ Favorite ์์ฑ ์ญํ ์ ๊ฐ์ง๊ณ ์๋๊ฒ ๋ง์๊น์? ์ด๋ป๊ฒ ์๊ฐํ์๋์? ๐
@@ -0,0 +1,10 @@ | |||
package nextstep.member.domain.exception; | |||
|
|||
public class FavoriteException extends IllegalArgumentException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom ์์ธ ๐
*/ | ||
@DisplayName("์ ํจํ์ง ์์ ๋ก๊ทธ์ธ ์ ๋ณด๋ก ์ญ์ ํ ์ ์๋ค") | ||
@Test | ||
void ์ ํจํ์ง_์์_ํ ํฐ์ผ๋ก_๋ก๊ทธ์ธ_์ญ์ _์์ฒญ() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ธ ํ ์คํธ ๐
์๋ ํ์ธ์! ๊ธฐ๊ฐ์ด ๋๋ฌ๋๋ฐ๋ ๋ถ๊ตฌํ๊ณ ๋ฆฌ๋ทฐํด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค :)
ATDD๊ฐ์์ ๋ง์ง๋ง ๋ฆฌ๋ทฐ ์์ฒญ์ด๋ค์..!
์๊ฐ ๋์ค๋ ์ฒ์ฒํ ํด์ฃผ์๋ฉด ๊ฐ์ฌ๋๋ฆฌ๊ฒ ์ต๋๋ค. ๐