-
Notifications
You must be signed in to change notification settings - Fork 0
[feat/#28] mypage api #35
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
Changes from all commits
6904b59
8ed2e9b
22258f7
78bc09e
a805480
e7d8e27
062330f
a996816
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.hsLink.hslink.data.dto.request.common | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| // data/dto/common/JobType.kt | ||
| @Serializable | ||
| enum class JobType { | ||
| PERMANENT, // 정규직 | ||
| TEMPORARY, // 계약직 | ||
| INTERN, // 인턴 | ||
| FREELANCER // 프리랜서 | ||
| } | ||
|
Comment on lines
+1
to
+12
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. 🛠️ Refactor suggestion | 🟠 Major Consider relocating to common package and consolidating duplicate JobType. Two concerns:
Recommendation:
This will prevent future bugs from mixing the two types and improve maintainability. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // data/dto/request/mypage/UpdateProfileRequestDto.kt | ||
| package com.hsLink.hslink.data.dto.request.mypage | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class UpdateProfileRequestDto( | ||
| val studentNumber: String? = null, | ||
| val name: String? = null, | ||
| val major: String? = null, | ||
| val mentor: Boolean? = null, | ||
| val jobSeeking: Boolean? = null | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,19 @@ data class LinkResponse( | |
| @SerialName("url") val url: String, | ||
| ) | ||
|
|
||
|
|
||
| @Serializable | ||
| data class CareerDto( | ||
| val id: Long, | ||
| val companyName: String, | ||
| val position: String, | ||
| val jobType: JobType, | ||
| val employed: Boolean, | ||
| val startYm: String, | ||
| val endYm: String? | ||
| ) | ||
|
Comment on lines
+29
to
+38
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. ID type inconsistency and duplicate JobType enum. Two critical issues:
Recommendations:
Apply this diff to fix the ID type: @Serializable
data class CareerResponse(
- @SerialName("id") val id: Int,
+ @SerialName("id") val id: Long,
@SerialName("companyName") val companyName: String,
@SerialName("position") val position: String,
@SerialName("jobType") val jobType: JobType,
@SerialName("employed") val employed: Boolean,
@SerialName("startYm") val startYm: String,
@SerialName("endYm") val endYm: String?,
)
🤖 Prompt for AI Agents |
||
|
|
||
|
|
||
| typealias CareerListResponseDto = List<CareerResponse> | ||
|
|
||
| @Serializable | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.hsLink.hslink.data.dto.response.mypage | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class MyPageUserProfileDto( | ||
| val userId: Long, | ||
| val studentNumber: String, | ||
| val name: String, | ||
| val major: String, | ||
| val mentor: Boolean, | ||
| val jobSeeking: Boolean, | ||
| val academicStatus: String, | ||
| val careers: List<CareerItemDto>, | ||
| val links: List<LinkItemDto> | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.hsLink.hslink.data.dto.response.mypage | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
|
|
||
| @Serializable | ||
| data class MyPageUserSummaryDto( | ||
| val userId: Long, | ||
| val name: String, | ||
| val studentNumberPrefix: String, // 학번 앞 두 자리 (예: "21") | ||
| val major: String, | ||
| val jobSeeking: Boolean, | ||
| val academicStatus: String, // <- String으로 변경 | ||
| val employed: Boolean | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.hsLink.hslink.data.dto.response.mypage | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class ProfileUpdateResponse( | ||
| val isSuccess: Boolean, | ||
| val code: String, | ||
| val message: String | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package com.hsLink.hslink.data.repositoryimpl | ||
|
|
||
| import com.hsLink.hslink.data.dto.request.onboarding.CareerUpdateRequestDto | ||
| import com.hsLink.hslink.data.dto.response.onboarding.CareerDto | ||
| import com.hsLink.hslink.data.service.CareerService | ||
| import com.hsLink.hslink.domain.repository.CareerRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class CareerRepositoryImpl @Inject constructor( | ||
| private val careerService: CareerService | ||
| ) : CareerRepository { | ||
|
|
||
| override suspend fun getMyCareers(): Result<List<CareerDto>> { | ||
| return try { | ||
| val response = careerService.getMyCareers() | ||
| if (response.isSuccess) { | ||
| Result.success(response.result) | ||
| } else { | ||
| Result.failure(Exception(response.message)) | ||
| } | ||
| } catch (e: Exception) { | ||
| Result.failure(e) | ||
| } | ||
| } | ||
|
|
||
| override suspend fun updateCareer(careerId: Long, request: CareerUpdateRequestDto): Result<CareerDto> { | ||
| return try { | ||
| val response = careerService.updateCareer(careerId, request) | ||
| if (response.isSuccess) { | ||
| Result.success(response.result) | ||
| } else { | ||
| Result.failure(Exception(response.message)) | ||
| } | ||
| } catch (e: Exception) { | ||
| Result.failure(e) | ||
| } | ||
| } | ||
| override suspend fun getCareer(careerId: Long): Result<CareerDto> { | ||
| return try { | ||
| val response = careerService.getCareer(careerId) | ||
| if (response.isSuccess) { | ||
| Result.success(response.result) | ||
| } else { | ||
| Result.failure(Exception(response.message)) | ||
| } | ||
| } catch (e: Exception) { | ||
| Result.failure(e) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // data/repositoryimpl/mypage/MypageRepositoryImpl.kt | ||
| package com.hsLink.hslink.data.repositoryimpl.mypage | ||
|
|
||
| import com.hsLink.hslink.data.dto.request.mypage.UpdateProfileRequestDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.MyPageUserProfileDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.MyPageUserSummaryDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.UserProfileDto | ||
| import com.hsLink.hslink.data.service.mypage.MypageService | ||
| import com.hsLink.hslink.domain.repository.mypage.MypageRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class MypageRepositoryImpl @Inject constructor( | ||
| private val mypageService: MypageService | ||
| ) : MypageRepository { | ||
|
|
||
| override suspend fun getUserProfile(): Result<MyPageUserProfileDto> { | ||
| return try { | ||
| val response = mypageService.getUserProfile() | ||
| if (response.isSuccessful) { | ||
| response.body()?.let { baseResponse -> | ||
| if (baseResponse.isSuccess) { | ||
| Result.success(baseResponse.result) | ||
| } else { | ||
| Result.failure(Exception(baseResponse.message)) | ||
| } | ||
| } ?: Result.failure(Exception("응답이 비어있습니다")) | ||
| } else { | ||
| Result.failure(Exception("API 호출 실패: ${response.code()}")) | ||
| } | ||
| } catch (e: Exception) { | ||
| Result.failure(e) | ||
| } | ||
| } | ||
|
|
||
| override suspend fun updateProfile(request: UpdateProfileRequestDto): Result<Unit> { | ||
| return try { | ||
| val response = mypageService.updateProfile(request) | ||
| if (response.isSuccess) { | ||
| Result.success(Unit) | ||
| } else { | ||
| Result.failure(Exception(response.message)) | ||
| } | ||
| } catch (e: Exception) { | ||
| Result.failure(e) | ||
| } | ||
| } | ||
|
|
||
| override suspend fun getUserSummary(): Result<MyPageUserSummaryDto> { | ||
| return try { | ||
| val response = mypageService.getUserSummary() | ||
| if (response.isSuccess) { | ||
| Result.success(response.result) | ||
| } else { | ||
| Result.failure(Exception(response.message)) | ||
| } | ||
| } catch (e: Exception) { | ||
| Result.failure(e) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // data/service/CareerService.kt | ||
| package com.hsLink.hslink.data.service | ||
|
|
||
| import com.hsLink.hslink.core.network.BaseResponse | ||
| import com.hsLink.hslink.data.dto.request.onboarding.CareerUpdateRequestDto | ||
| import com.hsLink.hslink.data.dto.response.onboarding.CareerDto | ||
| import retrofit2.http.Body | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.PUT | ||
| import retrofit2.http.Path | ||
|
|
||
| interface CareerService { | ||
|
|
||
| @GET("careers/mycareers") | ||
| suspend fun getMyCareers(): BaseResponse<List<CareerDto>> | ||
|
|
||
| @GET("careers/{careerId}") | ||
| suspend fun getCareer( | ||
| @Path("careerId") careerId: Long | ||
| ): BaseResponse<CareerDto> | ||
|
|
||
| @PUT("careers/{careerId}") | ||
| suspend fun updateCareer( | ||
| @Path("careerId") careerId: Long, | ||
| @Body request: CareerUpdateRequestDto | ||
| ): BaseResponse<CareerDto> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // data/service/mypage/MypageService.kt | ||
| package com.hsLink.hslink.data.service.mypage | ||
|
|
||
| import com.hsLink.hslink.core.network.BaseResponse | ||
| import com.hsLink.hslink.data.dto.request.mypage.UpdateProfileRequestDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.MyPageUserProfileDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.MyPageUserSummaryDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.ProfileUpdateResponse | ||
| import com.hsLink.hslink.data.dto.response.mypage.UserProfileDto | ||
| import retrofit2.Response | ||
| import retrofit2.http.Body | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.PATCH | ||
|
|
||
| interface MypageService { | ||
| @GET("users/myprofile") | ||
| suspend fun getUserProfile(): Response<BaseResponse<MyPageUserProfileDto>> | ||
|
|
||
| @PATCH("users/myprofile") | ||
| suspend fun updateProfile( | ||
| @Body request: UpdateProfileRequestDto | ||
| ): ProfileUpdateResponse | ||
|
|
||
| @GET("users/summary") | ||
| suspend fun getUserSummary(): BaseResponse<MyPageUserSummaryDto> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.hsLink.hslink.domain.repository | ||
|
|
||
| import com.hsLink.hslink.data.dto.request.onboarding.CareerUpdateRequestDto | ||
| import com.hsLink.hslink.data.dto.response.onboarding.CareerDto | ||
|
|
||
| interface CareerRepository { | ||
| suspend fun getCareer(careerId: Long): Result<CareerDto> | ||
| suspend fun getMyCareers(): Result<List<CareerDto>> | ||
| suspend fun updateCareer(careerId: Long, request: CareerUpdateRequestDto): Result<CareerDto> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // domain/repository/mypage/MypageRepository.kt | ||
| package com.hsLink.hslink.domain.repository.mypage | ||
|
|
||
| import com.hsLink.hslink.data.dto.request.mypage.UpdateProfileRequestDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.MyPageUserProfileDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.MyPageUserSummaryDto | ||
| import com.hsLink.hslink.data.dto.response.mypage.UserProfileDto | ||
|
|
||
| interface MypageRepository { | ||
| suspend fun getUserProfile(): Result<MyPageUserProfileDto> | ||
|
|
||
| suspend fun updateProfile(request: UpdateProfileRequestDto): Result<Unit> | ||
|
|
||
| suspend fun getUserSummary(): Result<MyPageUserSummaryDto> | ||
|
|
||
| } |
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.
Incorrect file path in comment.
The comment states
data/dto/common/JobType.kt, but the actual package iscom.hsLink.hslink.data.dto.request.common(line 1).Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents