Skip to content

Commit

Permalink
Merge pull request #118 from INFRAcp/eunjin
Browse files Browse the repository at this point in the history
[feat] #117 MyInfoModify & ViewUser Api
  • Loading branch information
sodock00 authored Mar 27, 2022
2 parents 3e4326f + 3978144 commit 7b6800b
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 188 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.infraandroid.category.model

data class ResponseViewUserProfileData(
val isSuccess: Boolean,
val code: Int,
val message: String,
val result: ArrayList<Result>?,
){
data class Result(
val user_id: String,
val user_prPhoto: String,
val user_nickname: String,
val user_prAbility: ArrayList<String>,
val user_grade: Int,
val user_prKeyword: ArrayList<String>,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.infraandroid.myinfo.myinfomodify.model

import retrofit2.Call
import retrofit2.http.Header
import retrofit2.http.PATCH
import retrofit2.http.Path

interface MyInfoService {
@PATCH("/user/profile/info/{id}")
fun viewMyInfo(
@Header("X-ACCESS-TOKEN") jwt: String,
@Path("id") userId : String
): Call<ResponseViewMyInfoData>

@PATCH("/user/profile/info/{id}")
fun ModifyMyInfo(
@Header("X-ACCESS-TOKEN") jwt: String,
@Path("id") userId : String
): Call<RequestModifyMyInfoData>


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.infraandroid.myinfo.myinfomodify.model

data class RequestModifyMyInfoData(
val isSuccess: Boolean,
val code: Int,
val message: String,
val result: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.infraandroid.myinfo.myinfomodify.model

data class ResponseViewMyInfoData(
val isSuccess: Boolean,
val code: Int,
val message: String,
val result: ArrayList<ResponseViewMyInfoData.Result>?,
){
data class Result(
val user_nickname: String,
val user_prPhoto: String,
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.example.infraandroid.myinfo.myinfomodify.view
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -17,6 +18,12 @@ import androidx.fragment.app.Fragment
import androidx.navigation.findNavController
import com.example.infraandroid.R
import com.example.infraandroid.databinding.FragmentMyInfoModifyBinding
import com.example.infraandroid.myinfo.myinfomodify.model.RequestModifyMyInfoData
import com.example.infraandroid.myinfo.myinfomodify.model.ResponseViewMyInfoData
import com.example.infraandroid.util.ServiceCreator
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

//내 정보 > 내 정보 .kt
class MyInfoModifyFragment : Fragment() {
Expand Down Expand Up @@ -45,6 +52,49 @@ class MyInfoModifyFragment : Fragment() {
val modifyCompletedButton = mBinding?.modifyCompletedButton as TextView
val doNotUseThisNicknameTextView = mBinding?.doNotUseThisNicknameTextView as TextView

//내 정보 보기 서버 연결
val viewcall: Call<ResponseViewMyInfoData> = ServiceCreator.myinfoService
.viewMyInfo("jwt","userId")
/*.viewMyInfo(InfraApplication.prefs.getString("jwt","null"),InfraApplication.prefs.getString("userId","null"))*/
viewcall.enqueue(object : Callback<ResponseViewMyInfoData> {
override fun onResponse(
call: Call<ResponseViewMyInfoData>,
response: Response<ResponseViewMyInfoData>
) {
val body = response.body()
if(response.isSuccessful){
when(response.body()?.code){
}
}

}

override fun onFailure(call: Call<ResponseViewMyInfoData>, t: Throwable) {
Log.d("TAG","Failed : $t")
}

} )

//내 정보 수정 서버 연결
val modifycall: Call<RequestModifyMyInfoData> = ServiceCreator.myinfoService
.ModifyMyInfo("jwt","userId")
modifycall.enqueue(object : Callback<RequestModifyMyInfoData> {
override fun onResponse(
call: Call<RequestModifyMyInfoData>,
response: Response<RequestModifyMyInfoData>
) {
if(response.isSuccessful){
when(response.body()?.code){
}
}
}

override fun onFailure(call: Call<RequestModifyMyInfoData>, t: Throwable) {
Log.d("TAG","Failed : $t")
}

})

//프로필 사진 추가 바텀싵
val bottomSheetDialogFragment = MyInfoPhotoMoreMenuBottomSheetFragment()
myInfoModifyUserProfileLayout.setOnClickListener {
Expand Down Expand Up @@ -101,8 +151,8 @@ class MyInfoModifyFragment : Fragment() {
inputNicknameEditText.setBackgroundResource(R.drawable.double_check_id_background)
mBinding?.canUseIconImageView?.isVisible = false
}
}
}
}


override fun onDestroyView() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package com.example.infraandroid.myinfo.myintroductionpage.view

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.fragment.app.Fragment
import com.example.infraandroid.databinding.MyInfoInformationBinding
import com.example.infraandroid.id.model.RequestLoginData
import com.example.infraandroid.id.viewmodel.SignUpViewModel
import com.example.infraandroid.myinfo.myintroductionpage.model.ResponseProfileViewData
import com.example.infraandroid.util.ServiceCreator
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

//내 정보 > 소개페이지 .kt
class MyIntroductionPageFragment: Fragment() {
Expand Down Expand Up @@ -59,45 +67,46 @@ class MyIntroductionPageFragment: Fragment() {
activity?.supportFragmentManager?.let { it1 -> bottomSheetDialogFragment.show(it1, bottomSheetDialogFragment.tag) }
}

// val requestLoginData = RequestLoginData(
// userId = inputId
// )

//소개 페이지 내용 조회 서버 연결
// val call: Call<ResponseProfileViewData> = ServiceCreator.profileViewService
// .getProfile("1")
//
// call.enqueue(
// object: Callback<ResponseProfileViewData> {
// override fun onResponse(
// call: Call<ResponseProfileViewData>,
// response: Response<ResponseProfileViewData>
// ) {
// if(response.isSuccessful){
// when (response.body()?.code) {
// 1000 -> {
// Toast.makeText(requireActivity(),"요청에 성공하셨습니다.", Toast.LENGTH_SHORT).show()
// //Log.d(SignUpViewModel.TAG, "요청에 성공하셨습니다.")
//
// //inforNameTextView.text =
// }
// 3101 -> {
// Toast.makeText(requireActivity(),"해당하는 아이디가 없습니다.", Toast.LENGTH_SHORT).show()
// }
// 4000 -> {
// Toast.makeText(requireActivity(),"데이터베이스 연결에 실패하였습니다.", Toast.LENGTH_SHORT).show()
// }
//
// }
// }
// else{
// Log.d(SignUpViewModel.TAG, "onResponse: 연결 실패..")
// }
// }
//
//
// override fun onFailure(call: Call<ResponseProfileViewData>, t: Throwable) {
// TODO("Not yet implemented")
// }
//
// })
val call: Call<ResponseProfileViewData> = ServiceCreator.profileViewService
.getProfile("android123")

call.enqueue(
object: Callback<ResponseProfileViewData> {
override fun onResponse(
call: Call<ResponseProfileViewData>,
response: Response<ResponseProfileViewData>
) {
if(response.isSuccessful){
when (response.body()?.code) {
1000 -> {
Toast.makeText(requireActivity(),"요청에 성공하셨습니다.", Toast.LENGTH_SHORT).show()

}
3101 -> {
Toast.makeText(requireActivity(),"해당하는 아이디가 없습니다.", Toast.LENGTH_SHORT).show()
}
4000 -> {
Toast.makeText(requireActivity(),"데이터베이스 연결에 실패하였습니다.", Toast.LENGTH_SHORT).show()
}

}
}
else{
Log.d(SignUpViewModel.TAG, "onResponse: 연결 실패..")
}
}


override fun onFailure(call: Call<ResponseProfileViewData>, t: Throwable) {
Log.d(SignUpViewModel.TAG, "onResponse: 연결 실패..")
}

})
}

override fun onDestroyView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.example.infraandroid.id.model.LoginService
import com.example.infraandroid.id.model.SMSService
import com.example.infraandroid.id.model.SignUpService
import com.example.infraandroid.id.model.UserDoubleCheckService
import com.example.infraandroid.myinfo.myinfomodify.model.MyInfoService
import com.example.infraandroid.myinfo.myideamanage.model.MyProjectService
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
Expand Down Expand Up @@ -34,6 +35,9 @@ object ServiceCreator {
val sendSMSService : SMSService = retrofit.create(SMSService::class.java)
val profileViewService : ProfileViewService = retrofit.create(ProfileViewService::class.java)
val createProjectService : CreateProjectService = retrofit.create(CreateProjectService::class.java)
val applyProjectService : ApplyProjectService = retrofit.create(ApplyProjectService::class.java)
val lookUpAllProjectService : LookUpAllProjectService = retrofit.create(LookUpAllProjectService::class.java)
val myinfoService : MyInfoService = retrofit.create(MyInfoService::class.java)
val projectService : ProjectService = retrofit.create(ProjectService::class.java)
val myProjectService : MyProjectService = retrofit.create(MyProjectService::class.java)
}
Loading

0 comments on commit 7b6800b

Please sign in to comment.