-
Notifications
You must be signed in to change notification settings - Fork 25
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
[둘리] 2, 3단계 자동 DI 미션 제출합니다 #28
Changes from 1 commit
168589f
87d3c2a
657518e
1bdceaf
5e94a5e
7ab7e4e
04ac319
c75db5c
f483bbb
d2744a7
c6393e6
8b64b40
ffa5c7b
2254b53
8d57300
e2b9366
62465b1
559b93f
f6c41a8
c0ee682
38725ee
55308d0
a80f744
15b4fe6
37d31ed
7f5c22d
368e9c9
83f960e
6f0dcf2
d66108d
5abddb2
b9ebfdf
0b4f3a1
2498638
9eecad2
8a46ecd
8fca93c
a636e8c
7184501
7443924
353d48b
bbb76a5
a89cc44
acaa5ef
e6ee91f
1f27660
d53b175
885ab4d
fa81116
77bc755
ad360bb
55bc13c
cc6cc2e
6c59beb
a7baa40
47600c6
a91d38b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package woowacourse.shopping.data | ||
|
||
import woowacourse.shopping.di.annotation.InMemory | ||
import woowacourse.shopping.model.CartProduct | ||
import woowacourse.shopping.model.Product | ||
|
||
// TODO: Step2 - CartProductDao를 참조하도록 변경 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 필요없는 주석이 InMemory 에도 따라왔네요! |
||
@InMemory | ||
class InMemoryCartRepository : CartRepository { | ||
private val products = mutableListOf<CartProduct>() | ||
override suspend fun addCartProduct(product: Product) { | ||
products.add( | ||
CartProduct( | ||
products.size.toLong(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. size 가 장바구니에 담긴 아이템 id 의 고유함을 보장할 수 있을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 갖고 있는 products 중에 최대 id + 1, products가 빈 리스트라면 DEFAULT_ID를 넣도록 계산법을 수정했습니다! |
||
product.name, | ||
product.price, | ||
product.imageUrl, | ||
System.currentTimeMillis(), | ||
), | ||
) | ||
} | ||
|
||
override suspend fun getAllCartProducts(): List<CartProduct> { | ||
return products.toList() | ||
} | ||
|
||
override suspend fun deleteCartProduct(id: Long) { | ||
products.removeIf { it.id == id } | ||
} | ||
} |
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.
필요없는 주석은 제거해주세요!