Skip to content

Commit

Permalink
Merge pull request #58 from ttoklip/faet/#2_마이페이지_구현
Browse files Browse the repository at this point in the history
Faet/#2 마이페이지 구현
  • Loading branch information
hangunhee39 authored Feb 19, 2024
2 parents fdad9ba + c6c19eb commit 42186de
Show file tree
Hide file tree
Showing 26 changed files with 418 additions and 132 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/com/umc/ttoklip/data/api/MyAccountRestrictApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.umc.ttoklip.data.api

import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.mypage.RestrictedResponse
import retrofit2.Response
import retrofit2.http.GET

interface MyAccountRestrictApi {
@GET("/api/v1/my-page/restricted")
suspend fun getRestrictedReason(): Response<ResponseBody<RestrictedResponse>>
}
17 changes: 17 additions & 0 deletions app/src/main/java/com/umc/ttoklip/data/api/MyBlockUserApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.umc.ttoklip.data.api

import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.mypage.MyBlockUserResponse
import retrofit2.Response
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Path

interface MyBlockUserApi {
@GET("/api/v1/my-page/blocked")
suspend fun getMyBlockedUser(): Response<ResponseBody<MyBlockUserResponse>>

@DELETE("/api/v1/my-page/unblock/{targetId}")
suspend fun deleteBlockUser(@Path("targetId") userId: Long): Response<ResponseBody<Unit>>

}
24 changes: 24 additions & 0 deletions app/src/main/java/com/umc/ttoklip/data/api/MyPostApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.umc.ttoklip.data.api

import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.mypage.MyCommunitiesResponse
import com.umc.ttoklip.data.model.mypage.MyHoneyTipsResponse
import com.umc.ttoklip.data.model.mypage.MyQuestionResponse
import com.umc.ttoklip.data.model.mypage.MyTogetherResponse
import retrofit2.Response
import retrofit2.http.GET

interface MyPostApi {
@GET("/api/v1/my-page/question")
suspend fun getMyQuestions(): Response<ResponseBody<MyQuestionResponse>>

@GET("/api/v1/my-page/participate-deals")
suspend fun getMyTogethers(): Response<ResponseBody<MyTogetherResponse>>

@GET("/api/v1/my-page/honeytip")
suspend fun getMyHoneyTips(): Response<ResponseBody<MyHoneyTipsResponse>>

@GET("/api/v1/my-page/community")
suspend fun getMyCommunications(): Response<ResponseBody<MyCommunitiesResponse>>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.umc.ttoklip.data.model.mypage

data class BlockedUser(
val reason: String,
val userId: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.umc.ttoklip.data.model.mypage

data class Community(
val content: String,
val questionId: Long,
val title: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.umc.ttoklip.data.model.mypage

data class CommunityX(
val communityId: Long,
val content: String,
val title: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.umc.ttoklip.data.model.mypage

data class HoneyTip(
val content: String,
val honeyTipId: Long,
val title: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.umc.ttoklip.data.model.mypage

data class MyBlockUserResponse(
val blockedUsers: List<BlockedUser>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.umc.ttoklip.data.model.mypage

data class MyCommunitiesResponse(
val communities: List<CommunityX>,
val isFirst: Boolean,
val isLast: Boolean,
val totalElements: Int,
val totalPage: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.umc.ttoklip.data.model.mypage

data class MyHoneyTipsResponse(
val honeyTips: List<HoneyTip>,
val isFirst: Boolean,
val isLast: Boolean,
val totalElements: Int,
val totalPage: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.umc.ttoklip.data.model.mypage

data class MyQuestionResponse(
val communities: List<Community>,
val isFirst: Boolean,
val isLast: Boolean,
val totalElements: Int,
val totalPage: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.umc.ttoklip.data.model.mypage

data class MyTogetherResponse(
val participatedDeals: List<ParticipatedDeal>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.umc.ttoklip.data.model.mypage

data class ParticipatedDeal(
val comments: Int,
val dealId: Long,
val description: String,
val participantsCount: Long,
val participationTime: String,
val price: Long,
val seller: String,
val status: String,
val title: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.umc.ttoklip.data.model.mypage

data class RestrictedResponse(
val duration: String,
val reason: String,
val type: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.umc.ttoklip.data.repository.mypage

import com.umc.ttoklip.data.model.mypage.RestrictedResponse
import com.umc.ttoklip.module.NetworkResult

interface MyAccountRestrictRepository {
suspend fun getRestrictedReason(): NetworkResult<RestrictedResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.umc.ttoklip.data.repository.mypage

import com.umc.ttoklip.data.api.MyAccountRestrictApi
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.mypage.RestrictedResponse
import com.umc.ttoklip.module.NetworkResult
import com.umc.ttoklip.module.handleApi
import javax.inject.Inject

class MyAccountRestrictRepositoryImpl @Inject constructor(private val api: MyAccountRestrictApi) :
MyAccountRestrictRepository {
override suspend fun getRestrictedReason(): NetworkResult<RestrictedResponse> {
return handleApi({ api.getRestrictedReason() }) { response: ResponseBody<RestrictedResponse> -> response.result }
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.umc.ttoklip.data.repository.mypage

import com.umc.ttoklip.data.model.mypage.MyBlockUserResponse
import com.umc.ttoklip.module.NetworkResult

interface MyBlockUserRepository {
suspend fun getBlockedUser(): NetworkResult<MyBlockUserResponse>
suspend fun deleteBlockUser(userId: Long): NetworkResult<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.umc.ttoklip.data.repository.mypage

import com.umc.ttoklip.data.api.MyBlockUserApi
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.mypage.MyBlockUserResponse
import com.umc.ttoklip.module.NetworkResult
import com.umc.ttoklip.module.handleApi
import javax.inject.Inject

class MyBlockUserRepositoryImpl @Inject constructor(private val api: MyBlockUserApi) :
MyBlockUserRepository {
override suspend fun getBlockedUser(): NetworkResult<MyBlockUserResponse> {
return handleApi({ api.getMyBlockedUser() }) { response: ResponseBody<MyBlockUserResponse> -> response.result }
}

override suspend fun deleteBlockUser(userId: Long): NetworkResult<Unit> {
return handleApi({ api.deleteBlockUser(userId) }) { response: ResponseBody<Unit> -> response.result }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.umc.ttoklip.data.repository.mypage

import com.umc.ttoklip.data.model.mypage.MyCommunitiesResponse
import com.umc.ttoklip.data.model.mypage.MyHoneyTipsResponse
import com.umc.ttoklip.data.model.mypage.MyQuestionResponse
import com.umc.ttoklip.data.model.mypage.MyTogetherResponse
import com.umc.ttoklip.module.NetworkResult

interface MyPostRepository {
suspend fun getBMyQuestions(): NetworkResult<MyQuestionResponse>
suspend fun getMyTogethers(): NetworkResult<MyTogetherResponse>
suspend fun getMyHoneyTips(): NetworkResult<MyHoneyTipsResponse>
suspend fun getMyCommunications(): NetworkResult<MyCommunitiesResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.umc.ttoklip.data.repository.mypage

import com.umc.ttoklip.data.api.MyPostApi
import com.umc.ttoklip.data.model.ResponseBody
import com.umc.ttoklip.data.model.mypage.MyCommunitiesResponse
import com.umc.ttoklip.data.model.mypage.MyHoneyTipsResponse
import com.umc.ttoklip.data.model.mypage.MyQuestionResponse
import com.umc.ttoklip.data.model.mypage.MyTogetherResponse
import com.umc.ttoklip.module.NetworkResult
import com.umc.ttoklip.module.handleApi
import javax.inject.Inject

class MyPostRepositoryImpl @Inject constructor(private val api: MyPostApi) : MyPostRepository {
override suspend fun getBMyQuestions(): NetworkResult<MyQuestionResponse> {
return handleApi({ api.getMyQuestions() }) { response: ResponseBody<MyQuestionResponse> -> response.result }
}

override suspend fun getMyTogethers(): NetworkResult<MyTogetherResponse> {
return handleApi({ api.getMyTogethers() }) { response: ResponseBody<MyTogetherResponse> -> response.result }
}

override suspend fun getMyHoneyTips(): NetworkResult<MyHoneyTipsResponse> {
return handleApi({ api.getMyHoneyTips() }) { response: ResponseBody<MyHoneyTipsResponse> -> response.result }
}

override suspend fun getMyCommunications(): NetworkResult<MyCommunitiesResponse> {
return handleApi({ api.getMyCommunications() }) { response: ResponseBody<MyCommunitiesResponse> -> response.result }
}
}
23 changes: 22 additions & 1 deletion app/src/main/java/com/umc/ttoklip/di/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import com.umc.ttoklip.R
import com.umc.ttoklip.TtoklipApplication
import com.umc.ttoklip.data.api.HoneyTipApi
import com.umc.ttoklip.data.api.LoginApi
import com.umc.ttoklip.data.api.MyAccountRestrictApi
import com.umc.ttoklip.data.api.MyBlockUserApi
import com.umc.ttoklip.data.api.MyPostApi
import com.umc.ttoklip.data.api.NewsApi
import com.umc.ttoklip.data.api.ReadCommsApi
import com.umc.ttoklip.data.api.ReadTogetherApi
Expand Down Expand Up @@ -107,7 +110,7 @@ object NetworkModule {

@Provides
@Singleton
fun provideLoginApi(retrofit: Retrofit): LoginApi{
fun provideLoginApi(retrofit: Retrofit): LoginApi {
return retrofit.buildService()
}

Expand All @@ -117,6 +120,24 @@ object NetworkModule {
return retrofit.buildService()
}

@Provides
@Singleton
fun providesAccountRestrictApi(retrofit: Retrofit): MyAccountRestrictApi {
return retrofit.buildService()
}

@Provides
@Singleton
fun providesMyPostApi(retrofit: Retrofit): MyPostApi {
return retrofit.buildService()
}

@Provides
@Singleton
fun providesMyBlockUserApi(retrofit: Retrofit): MyBlockUserApi {
return retrofit.buildService()
}

@Provides
@Singleton
fun provideReadCommsApi(retrofit: Retrofit): ReadCommsApi {
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/com/umc/ttoklip/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.umc.ttoklip.di

import com.umc.ttoklip.data.api.MyAccountRestrictApi
import com.umc.ttoklip.data.api.MyBlockUserApi
import com.umc.ttoklip.data.api.MyPostApi
import com.umc.ttoklip.data.api.NewsApi
import com.umc.ttoklip.data.api.Search2Api
import com.umc.ttoklip.data.api.SearchApi
import com.umc.ttoklip.data.repository.mypage.MyAccountRestrictRepository
import com.umc.ttoklip.data.repository.mypage.MyAccountRestrictRepositoryImpl
import com.umc.ttoklip.data.repository.mypage.MyBlockUserRepository
import com.umc.ttoklip.data.repository.mypage.MyBlockUserRepositoryImpl
import com.umc.ttoklip.data.repository.mypage.MyPostRepository
import com.umc.ttoklip.data.repository.mypage.MyPostRepositoryImpl
import com.umc.ttoklip.data.api.ReadCommsApi
import com.umc.ttoklip.data.api.ReadTogetherApi
import com.umc.ttoklip.data.api.WriteCommsApi
Expand Down Expand Up @@ -70,4 +79,18 @@ object RepositoryModule {
Search2RepositoryImpl(api)


@Provides
@Singleton
fun providesMyAccountRestrictRepository(api: MyAccountRestrictApi): MyAccountRestrictRepository =
MyAccountRestrictRepositoryImpl(api)

@Provides
@Singleton
fun providesMyPostRepository(api: MyPostApi): MyPostRepository =
MyPostRepositoryImpl(api)

@Provides
@Singleton
fun providesMyBlockUserRepository(api: MyBlockUserApi): MyBlockUserRepository =
MyBlockUserRepositoryImpl(api)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.umc.ttoklip.presentation.mypage

import android.content.Intent
import android.util.Log
import com.umc.ttoklip.R
import com.umc.ttoklip.TtoklipApplication
import com.umc.ttoklip.databinding.FragmentMyPageBinding
import com.umc.ttoklip.presentation.alarm.AlarmActivity
import com.umc.ttoklip.presentation.base.BaseFragment
import com.umc.ttoklip.presentation.login.LoginActivity
import com.umc.ttoklip.presentation.mypage.dialog.LogoutDialog
import dagger.hilt.android.AndroidEntryPoint

Expand Down Expand Up @@ -54,7 +57,13 @@ class MyPageFragment : BaseFragment<FragmentMyPageBinding>(R.layout.fragment_my_
}

binding.logoutFrame.setOnClickListener {
val dialog = LogoutDialog()
val dialog = LogoutDialog {
TtoklipApplication.prefs.setString("jwt", "")
Log.d("token", TtoklipApplication.prefs.getString("jwt", ""))
val intent = Intent(requireContext(), LoginActivity::class.java)
startActivity(intent)
requireActivity().finish()
}
dialog.show(parentFragmentManager, dialog.tag)
}

Expand Down
Loading

0 comments on commit 42186de

Please sign in to comment.