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 06 #11

Open
wants to merge 16 commits into
base: develop-xml
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ dependencies {
// define any required OkHttp artifacts without version
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9")
}
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tools:targetApi="31"
android:usesCleartextTraffic="true">
<activity
android:name=".LoginActivity"
android:name=".presentation.Login.LoginActivity"
android:exported="true">

<intent-filter>
Expand All @@ -26,10 +26,10 @@
</activity>

<activity
android:name=".MainActivity"
android:exported="false"></activity>
android:name=".presentation.MainActivity"
android:exported="false"/>
<activity
android:name=".SignUpActivity"
android:name=".presentation.SignUpActivity"
android:exported="false" />
</application>

Expand Down
40 changes: 0 additions & 40 deletions app/src/main/java/com/sopt/now/LoginViewModel.kt

This file was deleted.

42 changes: 0 additions & 42 deletions app/src/main/java/com/sopt/now/SignUpViewModel.kt

This file was deleted.

33 changes: 33 additions & 0 deletions app/src/main/java/com/sopt/now/data/AuthRepoImpl.kt
Copy link
Member

Choose a reason for hiding this comment

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

λ ˆν¬μ§€ν† λ¦¬κΉŒμ§€ μ“°λ‹€λ‹ˆ.. 폼미쳀닀

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.sopt.now.data

import com.sopt.now.data.api.AuthService
import com.sopt.now.data.dto.LoginDto.RequestLogInDto
import com.sopt.now.data.dto.SignUp.RequestSignUpDto
import com.sopt.now.domain.AuthRepository
import com.sopt.now.domain.model.AuthData
import retrofit2.Response

class AuthRepoImpl(
Copy link
Member

Choose a reason for hiding this comment

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

였호 λ ˆν¬μ§€ν† λ¦¬ νŒ¨ν„΄ 이번 μ„Έλ―Έλ‚˜μ—μ„œ λ°°μ› λŠ”λ° 벌써 μ μš©ν•˜μ…¨κ΅°μš₯!! 저도 μ μš©ν•΄λ΄μ•Όκ² μ–΄μš”!

private val authService: AuthService,
) : AuthRepository {
override suspend fun logIn(authData: AuthData): Result<Response<Unit>> = runCatching {
authService.logIn(
request = RequestLogInDto(
authenticationId = authData.id,
password = authData.pw
)
)
}
override suspend fun signUp(authData: AuthData): Result<Response<Unit>> = runCatching {
authService.signUp(
RequestSignUpDto(
authenticationId = authData.id,
password = authData.pw,
nickname = authData.name ?: "",
phone = authData.phone ?: ""
)
)
}


Copy link
Member

Choose a reason for hiding this comment

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

μ—¬κΈ° 쀄간격 ν•˜λ‚˜ μ€„μ—¬μ£Όμ‹œλ©΄ 쒋을거 κ°™μ•„μš”

}
Copy link
Member

Choose a reason for hiding this comment

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

와 μ§„μ§œ 폼 λ―Έμ³€λ„€μš”γ„·γ„·

Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
package com.sopt.now.api
package com.sopt.now.data.api

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.sopt.now.BuildConfig
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit

object ApiFactory {
private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL

val loggingInterceptor = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}
Comment on lines +14 to +16
Copy link
Member

Choose a reason for hiding this comment

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

loggingInterceptor λ‹¬μ•„λ³΄μ…¨μœΌλ©΄ HeaderInterceptor도 ν•΄λ³΄μ‹œλŠ”κ±° μΆ”μ²œλ“œλ¦½λ‹ˆλ‹€γ…Žγ…Ž


val client = OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
.build()

val retrofit: Retrofit by lazy {
Retrofit.Builder()
.client(client)
.baseUrl(BASE_URL)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
package com.sopt.now.api
package com.sopt.now.data.api

import com.sopt.now.dto.LoginDto.RequestLogInDto
import com.sopt.now.dto.SignUp.RequestSignUpDto
import com.sopt.now.dto.LoginDto.ResponseLogInDto
import com.sopt.now.dto.SignUp.ResponseSignUpDto
import com.sopt.now.dto.ResponseUserProfile
import com.sopt.now.data.dto.LoginDto.RequestLogInDto
import com.sopt.now.data.dto.SignUp.RequestSignUpDto
import com.sopt.now.data.dto.LoginDto.ResponseLogInDto
import com.sopt.now.data.dto.SignUp.ResponseSignUpDto
import com.sopt.now.data.dto.ResponseUserProfile
import retrofit2.Call
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST

interface AuthService {
@POST("member/join")
fun signUp(
suspend fun signUp(
@Body request: RequestSignUpDto,
): Call<ResponseSignUpDto>
): Response<Unit>

@POST("member/login")
fun logIn(
suspend fun logIn(
@Body request: RequestLogInDto,
): Call<ResponseLogInDto>
): Response<Unit>

@GET("member/info")
fun getUserInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.dto.LoginDto
package com.sopt.now.data.dto.LoginDto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.dto.LoginDto
package com.sopt.now.data.dto.LoginDto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.dto
package com.sopt.now.data.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.dto.SignUp
package com.sopt.now.data.dto.SignUp

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.dto.SignUp
package com.sopt.now.data.dto.SignUp

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/sopt/now/domain/AuthRepository.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.sopt.now.domain

import com.sopt.now.domain.model.AuthData
import retrofit2.Response

interface AuthRepository {
suspend fun logIn(authData: AuthData): Result<Response<Unit>>
suspend fun signUp(authData: AuthData): Result<Response<Unit>>
}
Copy link
Member

Choose a reason for hiding this comment

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

μ•„λ‹ˆ μ΄μ‚¬λžŒ 뭐야?

10 changes: 10 additions & 0 deletions app/src/main/java/com/sopt/now/domain/model/AuthData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sopt.now.domain.model

import android.provider.ContactsContract.CommonDataKinds.Phone

data class AuthData(
Copy link
Member

@chanubc chanubc May 25, 2024

Choose a reason for hiding this comment

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

Suggested change
data class AuthData(
data class AuthEntity(

domain μ˜μ—­μ˜ data classλŠ” 보톡 Entity둜 넀이밍 μ§€μ–΄μš”

각 μ˜μ—­λ³„ 넀이밍(보톡 μ΄λ ‡κ²Œ μ§€μ–΄μš”)

  1. ui : model
  2. domain : entity
  3. data : dto

val id: String,
val pw: String,
val name: String? = null,
val phone: String? = null
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.Friend
package com.sopt.now.presentation.Friend

import android.view.LayoutInflater
import android.view.ViewGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.Friend
package com.sopt.now.presentation.Friend

import androidx.annotation.DrawableRes

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.Friend
package com.sopt.now.presentation.Friend

import androidx.recyclerview.widget.RecyclerView
import com.sopt.now.databinding.ItemFriendBinding
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.Home
package com.sopt.now.presentation.Home

import android.os.Bundle
import android.view.LayoutInflater
Expand All @@ -8,8 +8,8 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.LinearLayoutManager
import com.sopt.now.Friend.FriendAdapter
import com.sopt.now.User.UserAdapter
import com.sopt.now.presentation.Friend.FriendAdapter
import com.sopt.now.presentation.User.UserAdapter
import com.sopt.now.databinding.FragmentHomeBinding


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.sopt.now.Home
package com.sopt.now.presentation.Home

import androidx.lifecycle.ViewModel
import com.sopt.now.Friend.FriendData
import com.sopt.now.presentation.Friend.FriendData
import com.sopt.now.R
import com.sopt.now.User.UserData
import com.sopt.now.presentation.User.UserData

class HomeViewModel : ViewModel() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.Home
package com.sopt.now.presentation.Home

import android.os.Bundle
import android.util.Log
Expand All @@ -7,9 +7,9 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import com.sopt.now.api.ServicePool
import com.sopt.now.data.api.ServicePool
import com.sopt.now.databinding.FragmentMyPageBinding
import com.sopt.now.dto.ResponseUserProfile
import com.sopt.now.data.dto.ResponseUserProfile
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
Expand All @@ -26,7 +26,7 @@ class MyPageFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
): View {
_binding = FragmentMyPageBinding.inflate(inflater, container, false)
return binding.root
}
Expand Down Expand Up @@ -60,19 +60,20 @@ class MyPageFragment : Fragment() {
tvUserId.text = "ID: ${it.data.authenticationId}"
tvUserName.text = "Name: ${it.data.nickname}"
tvPhone.text = "Phone: ${it.data.phone}"

}
}
} else {
onFailure(call, Throwable("Fail: ${response.code()}"))
}
}

override fun onFailure(call: Call<ResponseUserProfile>, t: Throwable) {
Toast.makeText(requireContext(), t.message.toString(), Toast.LENGTH_SHORT)
.show()
}

})
}
companion object{
const val userId= "userId"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.Home
package com.sopt.now.presentation.Home

import android.os.Bundle
import android.view.LayoutInflater
Expand Down
Loading