Skip to content
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

Feat/week xml 07 #19

Open
wants to merge 33 commits into
base: develop-xml
Choose a base branch
from
Open

Feat/week xml 07 #19

wants to merge 33 commits into from

Conversation

cacaocoffee
Copy link
Member

๐Ÿ›  Related issue

โœ๏ธ Work Description

  • ๋ ˆํฌ์ง€ํ† ๋ฆฌ ํŒจํ„ด์ ์šฉ
  • usecase๋ถ„๋ฆฌ

๐Ÿ“ธ Screenshot

4.mp4

๐Ÿ˜… Uncompleted Tasks

๐Ÿ“ข To Reviewers

usecase ๋ถ„๋ฆฌ ์ด๋ ‡๊ฒŒํ•˜๋Š”๊ฒŒ ๋งž๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.
invoke๋กœ ๋ณ„๋„ ํ•จ์ˆ˜ ์„ ์–ธ ์—†์ดํ•˜๋Š”๊ฒŒ ์ข‹์„์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.
7์ฃผ์ฐจ ๋™์•ˆ ๋ถ€์กฑํ•œ ์ €์—๊ฒŒ ๋ฆฌ๋ทฐ ๋งŽ์ด ๋‹ฌ์•„์ฃผ์…”์„œ ๋‹ค๋“ค ๊ฐ์‚ฌํ•ด์š”

โœ… Check List

  • Code/Git ์ปจ๋ฒค์…˜์€ ์ง€์ผฐ๋‚˜์š”?
  • PR์˜ฌ๋ฆฌ๊ธฐ ์ „์— ๊ฒ€ํ† ํ–ˆ๋‚˜์š”?
  • ์ฝ”๋“œ๋ฆฌ๋ทฐ ๋ฐ˜์˜ํ–ˆ๋‚˜์š”?

@cacaocoffee cacaocoffee requested a review from a team June 7, 2024 03:45
@cacaocoffee cacaocoffee self-assigned this Jun 7, 2024
@cacaocoffee cacaocoffee requested review from OliviaYJH, kez-lab, chanubc and hyoeunjoo and removed request for a team June 7, 2024 03:45
@cacaocoffee cacaocoffee changed the base branch from main-xml to develop-xml June 7, 2024 03:51
Copy link

@librarywon librarywon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•ˆ๋…•ํ•˜์„ธ์š” ๋ช…์„๋‹˜ ๋งˆ์ง€๋ง‰ ์ฃผ์ฐจ ์ฝ”๋“œ๋ฆฌ๋ทฐ๋ฅผ ๋งก๊ฒŒ๋œ ๋ช…์˜ˆ OB ์„œ์žฌ์›์ž…๋‹ˆ๋‹ค!
์ €๋ฒˆ์— ๋ฆฌ๋ทฐ ํ•  ๋•Œ์— ๋น„ํ•ด ํญํŒ”์ ์œผ๋กœ ์„ฑ์žฅํ•˜์‹  ๋ชจ์Šต์„ ๋ณธ ๊ฒƒ ๊ฐ™์•„์„œ ์ •๋ง ์กด๊ฒฝ์„ ํ‘œํ•ฉ๋‹ˆ๋‹ค.
34๊ธฐ YB๋ถ„๋“ค์€ ์ •๋ง ๋‹ค๋“ค ์‹ค๋ ฅ์ด ์ถœ์ค‘ํ•˜์‹  ๊ฒƒ ๊ฐ™๊ตฐ์š”, ์•ˆ๋“œ๋กœ์ด๋“œ ์•ฑ ์•„ํ‚คํ…์ฒ˜์™€ ์„ธ์„ธํ•œ ์ฝ”ํ‹€๋ฆฐ ๋ฌธ๋ฒ•์˜ ๊ฐœ๋…์„ ์ฑ„์šฐ์‹œ๋ฉด ๋” ๊ดด๋ฌผ๊ฐ™์€ ๊ฐœ๋ฐœ์ž๊ฐ€ ๋˜์‹ค ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
์„ธ๋ฏธ๋‚˜ ์™„์ฃผํ•˜์‹œ๋Š๋ผ ์ •๋ง ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค. ํ–‰๋ณต ์•ฑ์žผ ํ•˜์‹œ๊ธธ ๐Ÿ‘

Comment on lines 5 to 8
import androidx.lifecycle.viewModelScope
import com.sopt.now.data.model.User
import com.sopt.now.util.StringNetworkError.FAIL_ERROR
import com.sopt.now.util.StringNetworkError.LOGIN
import com.sopt.now.util.StringNetworkError.SERVER_ERROR
import com.sopt.now.domain.entity.request.AuthRequestModel
import com.sopt.now.domain.usecase.LogInUseCase

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ง€๋‚œ ๋ฆฌ๋ทฐ์—์„œ๋„ ๋ง์”€๋“œ๋ ธ๋˜ ๋ฌธ์ œ์ธ๋ฐ
์ง€๊ธˆ ์•ˆ๋“œ๋กœ์ด๋“œ ์•ฑ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์ ์šฉ์ค‘์ด์‹œ๋ผ๋ฉด ui -> domain -> data ํ˜•์‹์œผ๋กœ ์ฐธ์กฐ๊ฐ€ ๋˜์–ด์•ผํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ data์˜ model๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ ์‚ฌ์šฉ์ค‘์ด๋‹ˆ ui๊ฐ€ domain๊ณผ data๋ฅผ ๋ชจ๋‘ ์ฐธ์กฐํ•˜๋Š” ๋ชจ์–‘์ƒˆ์ด์ฃ 
์–ด๋–ป๊ฒŒ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ• ์ง€ ๊ณ ๋ฏผํ•ด๋ณด์‹œ๋Š” ๊ฒƒ๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2024-06-09 แ„‹แ…ฉแ„’แ…ฎ 7 52 25

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ˆ๋ฌด ์ž˜๋ชป์“ฐ๊ณ ์žˆ์—ˆ๋„ค์š”..
๋ง์”€ํ•ด์ฃผ์‹  ์ฃผ์ œ์™€ ์•„ํ‚คํ…์ฒ˜ ์—ฌ๋Ÿฌ ๊ด€๋ จ๋œ ์ž๋ฃŒ ์ฐพ์•„๋ณด๊ณ  ๊ณต๋ถ€ํ•œ๋‹ค๊ณ  ๋‹ต๋ณ€์„ ๋„ˆ๋ฌด ๋Šฆ๊ฒŒ ๋‹ฌ์•˜๋„ค์š”

์ œ๋Œ€๋กœ ํ•œ์ง€๋Š” ๋ชจ๋ฅด์ง€๋งŒ clean ์•„ํ‚คํ…์ฒ˜์— ๋Œ€ํ•ด์„œ ์ฐพ์•„ ๊ณต๋ถ€ํ•˜๊ณ  ์ ์šฉ์„ ํ•˜๋ ค ๋…ธ๋ ฅ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.

์•ฑ์žผ์— ์ œ๋Œ€๋กœ ๋“ค์–ด๊ฐ€์ „์— ๊ตฌ๊ธ€๊ถŒ์žฅ์•„ํ‚คํ…์ฒ˜๋„ ์ œ๋Œ€๋กœ ํ™•์ธํ•ด๋ณด๊ณ  ๊ฐ€๋ ค๊ตฌ์š” ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฉ‹์ง„ ์„ฑ์žฅ ๊ธฐ๋Œ€ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!

Comment on lines 13 to 14
private val _loginState = MutableLiveData<UiState<User>>()
val loginState = _loginState

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์‚ฌ์†Œํ•˜์ง€๋งŒ ๋ณ€์ˆ˜์˜ ํƒ€์ž…์„ ๋ช…์‹œ์ ์œผ๋กœ ์„ ์–ธํ•ด์ฃผ๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ํƒ€์ž… ๋ช…์‹œํ•˜๋Š” ๊ฒƒ ์ž˜ ์ง€์ผœ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค! ์‚ฌ์‹ค ๋ช…์‹œํ•˜๋Š” ๊ฒŒ ์ข‹์€ ๊ฑด ์ค„ ๋ชฐ๋ž์–ด์š”

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ปดํ“จํ„ฐ๊ด€์ ์—์„œ ์ถ”๋ก ํ•˜๋Š” ๊ฒƒ๋ณด๋‹ค ๋ช…์‹œ๋˜์–ด์žˆ๋Š”๊ฑธ ๊ฐ€์ ธ๋‹ค ์“ฐ๋Š”๊ฒŒ ์ข‹๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ž…๋‹ˆ๋‹ค.

Comment on lines 86 to 92
private fun getLoginRequest() =
AuthRequestModel(
authenticationId = binding.etLoginId.text.toString(),
password = binding.etLoginPassword.text.toString()
password = binding.etLoginPassword.text.toString(),
nickname = "",
phone = ""
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ์„ ์‚ฌ์šฉํ•˜๋ฉด ์ด ๊ท€์ฐฎ์€ ๊ณผ์ •์„ ํšŒํ”ผํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค!

Comment on lines 9 to 20
class LoginViewModelFactory : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(LoginViewModel::class.java)) {
val repository =
AuthRepositoryImpl(ServicePool.authService)
val logInUseCase = LogInUseCase(repository)
return LoginViewModel(logInUseCase) as T
} else {
throw IllegalArgumentException("Failed to create ViewModel: ${modelClass.name}")
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ViewModelFactory๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋ฉด ๋ทฐ๋ชจ๋ธ๋งˆ๋‹ค ๋ทฐ๋ชจ๋ธํŽ™ํ† ๋ฆฌ๊ฐ€ ์ƒ์„ฑ๋˜๋Š” ๋ถˆํŽธํ•จ์ด ์ƒ๊ธฐ๋Š” ๊ฒƒ์„ ๋Š๋ผ์…จ์„ ๊ฒ๋‹ˆ๋‹ค.
ํ”„๋กœ์ ํŠธ์— ์ ์šฉํ• ์ง€๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ Hilt๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ํ•˜๋ฉด์„œ ์ž๋™ DI๊ฐ€ ์–ด๋–ค ์ด์ ์„ ๊ฐ€์ ธ์˜ค๋Š”์ง€ ์•Œ์•„๋ณด์‹œ๋ฉด ์ •๋ง ๋„์›€์ด ๋งŽ์ด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋งž์Šต๋‹ˆ๋‹ค.. ์ €๋„ ๊ทธ๋ ‡๊ฒŒ ํ–ˆ๋”๋‹ˆ ๋ฒˆ๊ฑฐ๋กญ๋”๋ผ๊ตฌ์š” ์ €๋„ Hilt ๋‹ค์Œ์— ๊ผญ ์ ์šฉํ•ด๋ด์•ผ๊ฒ ์Šต๋‹ˆ๋‹ค!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์šฐ์„  viewmodel ํŒฉํ† ๋ฆฌ ํ•˜๋‚˜๋กœ ์ž‘์—…์„ ํ–ˆ์Šต๋‹ˆ๋‹ค. hilt์— ๋Œ€ํ•ด์„  ๊ณต๋ถ€ํ•˜๊ณ  ์ ์šฉํ•ด๋ณด๋Š” ๋‹จ๊ณ„์— ์žˆ์–ด์š”.
ํ”ผ์™€์‚ด์ด ๋˜๋Š” ์กฐ์–ธ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค..

Comment on lines 36 to 39
viewModelScope.launch {
runCatching {
infoService.getUserInfo(userid)
}.onSuccess { response ->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๊ธฐ๋Š” repository ํŒจํ„ด์ด ์ ์šฉ๋˜์–ด ์žˆ์ง€ ์•Š์€๊ฑด๊ฐ€์š”?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ๋‹น์‹œ์— login๊ณผ signup์„ ํ•˜๋ฉด์„œ ์ œ๊ฐ€ ๊ณต๋ถ€ํ•œ๊ฑฐ์— ๋Œ€ํ•œ ํ™•์‹ ์ด ์—†์—ˆ์–ด์š”...
๋ญ”๊ฐ€ ์ด๋ ‡๊ฒŒ ์งœ๋Š” ๊ฒƒ์ด ๋งž๋Š”๊ฑด๊ฐ€ ๊ณ ๋ฏผ์ด ๋“ค๋ฉด์„œ ํ™•์‹คํžˆ ํ•˜๊ณ  ์ ์šฉ์„ ํ•˜๊ธฐ๋กœ ํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค!
์ง€๊ธˆ์€ ์ถ”๊ฐ€ํ•ด์„œ ๋„ฃ์–ด๋‘์—ˆ์–ด์š”!

Comment on lines 7 to 25
data class AuthRequestModel(
val authenticationId: String,
val password: String,
val nickname: String,
val phone: String,
) {
fun toRequestSignup(): RequestSignUpDto =
RequestSignUpDto(authenticationId, password, nickname, phone)

fun toRequestLogin(): RequestLoginDto = RequestLoginDto(authenticationId, password)
fun toUserWithUserId(userid: String): User =
User(
id = authenticationId,
password = password,
nickname = nickname,
phoneNumber = phone,
userId = userid
)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AuthRequestModel๋ฅผ ์“ฐ์‹œ๊ฒŒ๋œ ์ด์œ ๊ฐ€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data ์˜์—ญ์—์„œ ui ์— ์‚ฌ์šฉํ•˜๊ธฐ์— ์ค‘๊ฐ„๋‹ค๋ฆฌ๋กœ ์ƒ๊ฐํ•˜๊ณ  ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.
์ € ๋‹น์‹œ์— ์˜์กด๊ด€๊ณ„๊ฐ€ ํ—ท๊ฐˆ๋ ค ๋„ˆ๋ฌด ์ž˜๋ชป์งœ๊ณ  ๋„ฃ์—ˆ๋„ค์š”.. ์žฌ์›๋‹˜ ๋ฆฌ๋ทฐ ๋•๋ถ„์— ์™œ ์‚ฌ์šฉํ•˜๋Š”๊ฐ€์— ๋Œ€ํ•œ ๋ณธ์งˆ์ ์ธ ๊ณ ๋ฏผ์„ ํ•™ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค ๊ฐ์‚ฌํ•ด์š”

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฐธ์‹ ํ•œ ์ ‘๊ทผ์ธ ๊ฒƒ ๊ฐ™์•„์š” ์ด๋Ÿฐ ๋ณธ์ธ๋งŒ์˜ ์ ‘๊ทผ๋„ ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค

import retrofit2.Response

interface AuthRepository {
suspend fun logIn(authData: AuthRequestModel): Result<Response<BaseResponse<Unit>>>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

login์€ ํ†ต์ƒ์ ์œผ๋กœ ํ•œ๋‹จ์–ด๋กœ ์ธ์‹ํ•ฉ๋‹ˆ๋‹ค!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค ๋ญ”๊ฐ€.. ๊ฐ‘์ž๊ธฐ ํ—ท๊ฐˆ๋ ธ์–ด์š”..

Comment on lines 50 to 53
companion object {
const val MESSAGE = "message"
const val LOCATION = "location"
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private๋ฅผ ๋”ฐ๋กœ ๋ถ™์ด์‹œ์ง€ ์•Š์œผ์…จ๋Š”๋ฐ ๋‹ค๋ฅธ ๊ณณ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ ์ผ๊นŒ์š”?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—†์Šต๋‹ˆ๋‹ค private ๋ถ™์ด๋Š”๊ฑธ ๊นŒ๋จน์—ˆ๋„ค์š” ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

Copy link

@hyoeunjoo hyoeunjoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฝ”๋“œ๋ฆฌ๋ทฐ ํ•ญ์ƒ ๋งŽ์ด ๋ฐ›๊ธฐ๋งŒ ํ•˜๊ณ  ์–‘์งˆ์˜ ์ฝ”๋ฆฌ๋ฅผ ๋ชป ๋‹ฌ์•„๋“œ๋ฆฐ ๊ฒƒ ๊ฐ™์•„์„œ ์†์ƒํ•ด์š”ใ… ใ… 
(๋‹ค์Œ ๊ธฐ์ˆ˜์— ์ œ๊ฐ€ ๋” ๋ฐœ์ „ํ•ด์„œ ๊ณ„์† ๋‹ฌ์•„๋“œ๋ฆฌ๊ณ ์‹ถ๋„ค์š” ใ…Ž)
์ด๋ฒˆ ๊ณผ์ œ๋„ ์ˆ˜๊ณ  ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค!!

Comment on lines 9 to 20
class LoginViewModelFactory : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(LoginViewModel::class.java)) {
val repository =
AuthRepositoryImpl(ServicePool.authService)
val logInUseCase = LogInUseCase(repository)
return LoginViewModel(logInUseCase) as T
} else {
throw IllegalArgumentException("Failed to create ViewModel: ${modelClass.name}")
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋งž์Šต๋‹ˆ๋‹ค.. ์ €๋„ ๊ทธ๋ ‡๊ฒŒ ํ–ˆ๋”๋‹ˆ ๋ฒˆ๊ฑฐ๋กญ๋”๋ผ๊ตฌ์š” ์ €๋„ Hilt ๋‹ค์Œ์— ๊ผญ ์ ์šฉํ•ด๋ด์•ผ๊ฒ ์Šต๋‹ˆ๋‹ค!!

Comment on lines 12 to 29

class LogInUseCase(private val authRepository: AuthRepository) {
suspend fun execute(request: AuthRequestModel): UiState<User> {
return withContext(Dispatchers.IO) {
try {
val result = authRepository.logIn(request)
result.fold(
onSuccess = { response ->
if (response.isSuccessful) {
UiState.Success(
User(
request.authenticationId,
request.password,
"",
"",
userId = response.headers()[LOCATION].toString()
)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„.. UseCase ๋ถ„๋ฆฌ.. ์žŠ๊ณ  ์žˆ์—ˆ๋Š”๋ฐ!!!
๋ฉ‹์ ธ์š”.. ๊ฐ€๋…์„ฑ์ด ํ›จ ์ข‹๋„ค์š”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋‹ˆ์˜ˆ์š” ใ… ใ…œ ๋ถ„๋ฆฌ๋Š”ํ–ˆ๋Š”๋ฐ ๋„ˆ๋ฌด ์ž˜๋ชปํ•ด์„œ.. ๋ฐ”๋€ ์ฝ”๋“œ์ฒ˜๋Ÿผ ํ•ด์•ผํ•˜๋Š”๊ฑธ๋กœ ์•Œ๊ณ ์žˆ์–ด์š”

Comment on lines 18 to 20
viewModelScope.launch {
_loginState.value = logInUseCase.execute(request)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์†์ด ๋ง‰ ์‹œ์›ํ•ด์ง€๋„ค์š”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๋Ÿฌ๋ฉด ์•ˆ๋œ๋Œ€์š” ใ… 

Copy link
Member

@OliviaYJH OliviaYJH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค!


class LogInUseCase(private val authRepository: AuthRepository) {
suspend fun execute(request: AuthRequestModel): UiState<User> {
return withContext(Dispatchers.IO) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withContext๋กœ๋„ ์ฝ”๋ฃจํ‹ด์„ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๊ตฐ์š”! ์•Œ์•„๊ฐ€์š”!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ๊ทธ๋Ÿฐ๋ฐ usecase์—์„œ ์ด๋ ‡๊ฒŒ ์“ฐ๋ฉด์•ˆ๋ผ์š”! domain ์˜์—ญ์— ์„œ๋ฒ„ํ†ต์‹ ์ด๋ž‘ ์—ฌ๋Ÿฌ ๊ณผ์ •์ด ๋“ค์–ด๊ฐ€๊ฒŒ ๋˜์–ด์„œ ์ž˜ ๋ชป ์ง  ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค!

Copy link

@chanubc chanubc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ•œ ํ•™๊ธฐ ๋™์•ˆ ๊ณ ์ƒ ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค!!
๋„ˆ๋ฌด๋‚˜ ์—ด์‹ฌํžˆ ์ž˜ํ•ด์ฃผ์–ด์„œ ๊ณ ๋งˆ์›Œ์š”ใ… ใ… ใ… ใ… 

์ž์„ธํ•œ ์‚ฌํ•ญ์€ ๋”ฐ๋กœ ๊ฐœ์ธํ†ก ๋“œ๋ฆด๊ฒŒ์š”!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ผ๋‹จ ์ด ๋กœ์ง์€ data์˜์—ญ์— ์žˆ์–ด์•ผ ํ•˜๋Š” ๋กœ์ง์ž…๋‹ˆ๋‹ค!
repositoryํŒจํ„ด์— ์˜ํ•˜๋ฉด data์˜์—ญ์—์„œ ์„œ๋ฒ„ ํ†ต์‹ ๊ณผ ๊ฐ™์€ ๋กœ์ง์„ ๋‹ด๋‹น ํ•˜๊ฒŒ ๋˜๋Š”๋ฐ
domain์˜ ์ด๋Ÿฌํ•œ ์„œ๋ฒ„ํ†ต์‹  ๋กœ์ง์„ ๋‹ด๋‹นํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ repository ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์š”์ฒญํ•˜๋Š” ์—ญํ• ๋งŒ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์‹ค์ œ ๊ตฌํ˜„์€ data์—์„œ ํ•˜๊ฒŒ๋˜๊ณ  ์ด๋ฅผ ์˜์กด์„ฑ ์—ญ์ „์ด๋ผ๊ณ  ๋ถ€๋ฆ…๋‹ˆ๋‹ค.

domain์˜ usecase๋Š” ์ด๋Ÿฌํ•œ interface๋ฅผ ์ฐธ์กฐํ•˜์—ฌ ํŠน์ • ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ์บก์Šํ™” ํ•ฉ๋‹ˆ๋‹ค.

์ง€๊ธˆ data ๋ ˆ์ด์–ด์˜ ๋ถ„๋ฆฌ๊ฐ€ ๋ชฉ์ ์ธ์ง€ ํ˜น์€ ํด๋ฆฐ์•„ํ‚คํ…์ณ์‹์˜ ๊ตฌ์กฐ๊ฐ€ ๋ชฉ์ ์ธ์ง€ ํ™•์‹คํ•˜๊ฒŒ ์ •ํ•˜๊ณ  ๋‹ค์‹œ ๋ฆฌํŒฉํ† ๋ง ํ•ด๋ณด๋ฉด ์ข‹์„๊ฒƒ ๊ฐ™์•„์š”!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ •๋ง ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค
ํด๋ฆฐ์•„ํ‚คํ…์ฒ˜๋ฅผ ์ ์šฉํ•ด๋ณด์ž! ๋ผ๊ณ  ํ•˜๊ธดํ–ˆ๋Š”๋ฐ ๋ง‰์ƒ ํ•˜๋ฉด์„œ ์ด์ƒํ•œ๊ฑฐ ๊ฐ™๋”๋ผ๊ตฌ์š”...
์ œ๊ฐ€ ํ•˜๋Š” ๋ฐฉ๋ฉด์ด ๋งž๋‚˜ ์‹ถ๊ธฐ๋„ ํ–ˆ์—ˆ๋Š”๋ฐ ๋•๋ถ„์— ์˜๋ฌธ์ ์„ ๋งŽ์ด ํ•ด๊ฒฐํ•˜๊ณ  ์ž‘์—…ํ•  ์ˆ˜ ์žˆ์—ˆ์–ด์š”.
์ง€๊ธˆ ์ˆ˜์ •ํ•œ ๋ฐฉ์•ˆ์ด ์ •๋‹ต์ด ์•„๋‹ ์ˆ˜๋Š” ์žˆ๋”๋ผ๋„ ๋•๋ถ„์— ๋งŽ์€ ๊ฑธ ์•Œ๊ฒŒ ๋˜์—ˆ์–ด์š” ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.
์ดํ›„์— ์ž์„ธํ•œ ์„ค๋ช… ๋•๋ถ„์— ํ˜„์žฌ ๊ณต๋ถ€ํ•˜๊ณ  ์ ์šฉ์„ ํ•ด๋ดค์–ด์š” datasource ๋กœ ๋ถ„๋ฆฌํ•˜๊ณ  hilt ์ ์šฉ๋„ ๋…ธ๋ ฅํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค..

Comment on lines 7 to 25
data class AuthRequestModel(
val authenticationId: String,
val password: String,
val nickname: String,
val phone: String,
) {
fun toRequestSignup(): RequestSignUpDto =
RequestSignUpDto(authenticationId, password, nickname, phone)

fun toRequestLogin(): RequestLoginDto = RequestLoginDto(authenticationId, password)
fun toUserWithUserId(userid: String): User =
User(
id = authenticationId,
password = password,
nickname = nickname,
phoneNumber = phone,
userId = userid
)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain์—์„œ dto๋ฅผ ์ฐธ์กฐํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ data์—์„œ dto๋ฅผ ์ฐธ์กฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์•ˆ๊ทธ๋ž˜๋„ ์ฝ”๋“œ ์งœ๋ฉด์„œ ๋ญ”๊ฐ€ ์ž˜๋ชป๋˜์—ˆ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ๊ณ ๋ฏผ๋งŽ์ด ํ–ˆ์—ˆ๋Š”๋ฐ ๋•๋ถ„์— ๊ธธ์„ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ์–ด์š”

Copy link
Member Author

@cacaocoffee cacaocoffee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ˆ๋ฌด ๋‚˜๋„ ๋Šฆ์€ ๋‹ต๋ณ€ ๋“œ๋ ค ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋“ค ๋ถ€์กฑํ•œ ์ €์—๊ฒŒ๋„ comment์™€ ๋„์›€ ์ฃผ์…”์„œ ๊ณ ๋งˆ์›Œ์š” ์†ํŠธ ํ™œ๋™ํ•˜๋Š” ๋™์•ˆ ์—ฌ๋Ÿฌ๋ถ„์˜ ์ฝ”๋“œ๋ฆฌ๋ทฐ๊ฐ€ ๋„ˆ๋ฌด๋‚˜๋„ ํฐ ๋„์›€์ด ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์‹œ ํ•œ๋ฒˆ ๋„ˆ๋ฌด ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ํฐ ๋„์›€ ๋ฐ›์•˜์–ด์š”.

Comment on lines 50 to 53
companion object {
const val MESSAGE = "message"
const val LOCATION = "location"
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—†์Šต๋‹ˆ๋‹ค private ๋ถ™์ด๋Š”๊ฑธ ๊นŒ๋จน์—ˆ๋„ค์š” ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.


class LogInUseCase(private val authRepository: AuthRepository) {
suspend fun execute(request: AuthRequestModel): UiState<User> {
return withContext(Dispatchers.IO) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ๊ทธ๋Ÿฐ๋ฐ usecase์—์„œ ์ด๋ ‡๊ฒŒ ์“ฐ๋ฉด์•ˆ๋ผ์š”! domain ์˜์—ญ์— ์„œ๋ฒ„ํ†ต์‹ ์ด๋ž‘ ์—ฌ๋Ÿฌ ๊ณผ์ •์ด ๋“ค์–ด๊ฐ€๊ฒŒ ๋˜์–ด์„œ ์ž˜ ๋ชป ์ง  ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค!

Comment on lines 12 to 29

class LogInUseCase(private val authRepository: AuthRepository) {
suspend fun execute(request: AuthRequestModel): UiState<User> {
return withContext(Dispatchers.IO) {
try {
val result = authRepository.logIn(request)
result.fold(
onSuccess = { response ->
if (response.isSuccessful) {
UiState.Success(
User(
request.authenticationId,
request.password,
"",
"",
userId = response.headers()[LOCATION].toString()
)
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๋‹ˆ์˜ˆ์š” ใ… ใ…œ ๋ถ„๋ฆฌ๋Š”ํ–ˆ๋Š”๋ฐ ๋„ˆ๋ฌด ์ž˜๋ชปํ•ด์„œ.. ๋ฐ”๋€ ์ฝ”๋“œ์ฒ˜๋Ÿผ ํ•ด์•ผํ•˜๋Š”๊ฑธ๋กœ ์•Œ๊ณ ์žˆ์–ด์š”

Comment on lines 7 to 25
data class AuthRequestModel(
val authenticationId: String,
val password: String,
val nickname: String,
val phone: String,
) {
fun toRequestSignup(): RequestSignUpDto =
RequestSignUpDto(authenticationId, password, nickname, phone)

fun toRequestLogin(): RequestLoginDto = RequestLoginDto(authenticationId, password)
fun toUserWithUserId(userid: String): User =
User(
id = authenticationId,
password = password,
nickname = nickname,
phoneNumber = phone,
userId = userid
)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data ์˜์—ญ์—์„œ ui ์— ์‚ฌ์šฉํ•˜๊ธฐ์— ์ค‘๊ฐ„๋‹ค๋ฆฌ๋กœ ์ƒ๊ฐํ•˜๊ณ  ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.
์ € ๋‹น์‹œ์— ์˜์กด๊ด€๊ณ„๊ฐ€ ํ—ท๊ฐˆ๋ ค ๋„ˆ๋ฌด ์ž˜๋ชป์งœ๊ณ  ๋„ฃ์—ˆ๋„ค์š”.. ์žฌ์›๋‹˜ ๋ฆฌ๋ทฐ ๋•๋ถ„์— ์™œ ์‚ฌ์šฉํ•˜๋Š”๊ฐ€์— ๋Œ€ํ•œ ๋ณธ์งˆ์ ์ธ ๊ณ ๋ฏผ์„ ํ•™ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค ๊ฐ์‚ฌํ•ด์š”

Comment on lines 7 to 25
data class AuthRequestModel(
val authenticationId: String,
val password: String,
val nickname: String,
val phone: String,
) {
fun toRequestSignup(): RequestSignUpDto =
RequestSignUpDto(authenticationId, password, nickname, phone)

fun toRequestLogin(): RequestLoginDto = RequestLoginDto(authenticationId, password)
fun toUserWithUserId(userid: String): User =
User(
id = authenticationId,
password = password,
nickname = nickname,
phoneNumber = phone,
userId = userid
)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์•ˆ๊ทธ๋ž˜๋„ ์ฝ”๋“œ ์งœ๋ฉด์„œ ๋ญ”๊ฐ€ ์ž˜๋ชป๋˜์—ˆ๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ๊ณ ๋ฏผ๋งŽ์ด ํ–ˆ์—ˆ๋Š”๋ฐ ๋•๋ถ„์— ๊ธธ์„ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ์–ด์š”

Comment on lines 13 to 14
private val _loginState = MutableLiveData<UiState<User>>()
val loginState = _loginState
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ํƒ€์ž… ๋ช…์‹œํ•˜๋Š” ๊ฒƒ ์ž˜ ์ง€์ผœ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค! ์‚ฌ์‹ค ๋ช…์‹œํ•˜๋Š” ๊ฒŒ ์ข‹์€ ๊ฑด ์ค„ ๋ชฐ๋ž์–ด์š”

Comment on lines 18 to 20
viewModelScope.launch {
_loginState.value = logInUseCase.execute(request)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๋Ÿฌ๋ฉด ์•ˆ๋œ๋Œ€์š” ใ… 

Comment on lines 9 to 20
class LoginViewModelFactory : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(LoginViewModel::class.java)) {
val repository =
AuthRepositoryImpl(ServicePool.authService)
val logInUseCase = LogInUseCase(repository)
return LoginViewModel(logInUseCase) as T
} else {
throw IllegalArgumentException("Failed to create ViewModel: ${modelClass.name}")
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์šฐ์„  viewmodel ํŒฉํ† ๋ฆฌ ํ•˜๋‚˜๋กœ ์ž‘์—…์„ ํ–ˆ์Šต๋‹ˆ๋‹ค. hilt์— ๋Œ€ํ•ด์„  ๊ณต๋ถ€ํ•˜๊ณ  ์ ์šฉํ•ด๋ณด๋Š” ๋‹จ๊ณ„์— ์žˆ์–ด์š”.
ํ”ผ์™€์‚ด์ด ๋˜๋Š” ์กฐ์–ธ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค..

Comment on lines 36 to 39
viewModelScope.launch {
runCatching {
infoService.getUserInfo(userid)
}.onSuccess { response ->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ๋‹น์‹œ์— login๊ณผ signup์„ ํ•˜๋ฉด์„œ ์ œ๊ฐ€ ๊ณต๋ถ€ํ•œ๊ฑฐ์— ๋Œ€ํ•œ ํ™•์‹ ์ด ์—†์—ˆ์–ด์š”...
๋ญ”๊ฐ€ ์ด๋ ‡๊ฒŒ ์งœ๋Š” ๊ฒƒ์ด ๋งž๋Š”๊ฑด๊ฐ€ ๊ณ ๋ฏผ์ด ๋“ค๋ฉด์„œ ํ™•์‹คํžˆ ํ•˜๊ณ  ์ ์šฉ์„ ํ•˜๊ธฐ๋กœ ํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค!
์ง€๊ธˆ์€ ์ถ”๊ฐ€ํ•ด์„œ ๋„ฃ์–ด๋‘์—ˆ์–ด์š”!

Comment on lines 5 to 8
import androidx.lifecycle.viewModelScope
import com.sopt.now.data.model.User
import com.sopt.now.util.StringNetworkError.FAIL_ERROR
import com.sopt.now.util.StringNetworkError.LOGIN
import com.sopt.now.util.StringNetworkError.SERVER_ERROR
import com.sopt.now.domain.entity.request.AuthRequestModel
import com.sopt.now.domain.usecase.LogInUseCase
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ˆ๋ฌด ์ž˜๋ชป์“ฐ๊ณ ์žˆ์—ˆ๋„ค์š”..
๋ง์”€ํ•ด์ฃผ์‹  ์ฃผ์ œ์™€ ์•„ํ‚คํ…์ฒ˜ ์—ฌ๋Ÿฌ ๊ด€๋ จ๋œ ์ž๋ฃŒ ์ฐพ์•„๋ณด๊ณ  ๊ณต๋ถ€ํ•œ๋‹ค๊ณ  ๋‹ต๋ณ€์„ ๋„ˆ๋ฌด ๋Šฆ๊ฒŒ ๋‹ฌ์•˜๋„ค์š”

์ œ๋Œ€๋กœ ํ•œ์ง€๋Š” ๋ชจ๋ฅด์ง€๋งŒ clean ์•„ํ‚คํ…์ฒ˜์— ๋Œ€ํ•ด์„œ ์ฐพ์•„ ๊ณต๋ถ€ํ•˜๊ณ  ์ ์šฉ์„ ํ•˜๋ ค ๋…ธ๋ ฅ์„ ํ–ˆ์Šต๋‹ˆ๋‹ค.

์•ฑ์žผ์— ์ œ๋Œ€๋กœ ๋“ค์–ด๊ฐ€์ „์— ๊ตฌ๊ธ€๊ถŒ์žฅ์•„ํ‚คํ…์ฒ˜๋„ ์ œ๋Œ€๋กœ ํ™•์ธํ•ด๋ณด๊ณ  ๊ฐ€๋ ค๊ตฌ์š” ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants