Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
12 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.example.findu.data.dataremote.datasource

import com.example.findu.data.dataremote.model.base.NullableBaseResponse
import com.example.findu.data.dataremote.model.response.my.MyInterestResponseDto

interface InterestRemoteDataSource {
suspend fun getInterestProtectingAnimals(id: Long) : NullableBaseResponse<Int>
suspend fun getInterestReportAnimals(id: Long) : NullableBaseResponse<Int>

suspend fun deleteInterestProtectingAnimals(reportId: Long) : NullableBaseResponse<Unit>
suspend fun deleteInterestReportAnimals(reportId: Long) : NullableBaseResponse<Unit>
suspend fun getInterestAnimals(lastId: Long): NullableBaseResponse<MyInterestResponseDto>
suspend fun registerInterestAnimal(reportId: Long): NullableBaseResponse<Unit>
suspend fun deleteInterestAnimal(reportId: Long) : NullableBaseResponse<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@ package com.example.findu.data.dataremote.datasource

import com.example.findu.data.dataremote.model.base.BaseResponse
import com.example.findu.data.dataremote.model.base.NullableBaseResponse
import com.example.findu.data.dataremote.model.request.PatchNicknameRequestDto
import com.example.findu.data.dataremote.model.response.my.MyInterestResponseDto
import com.example.findu.data.dataremote.model.response.my.MyNickNameResponseDto
import com.example.findu.data.dataremote.model.response.my.MyReportHistoryResponseDto
import com.example.findu.data.dataremote.model.response.my.MyViewedAnimalsResponseDto
import okhttp3.MultipartBody
import okhttp3.RequestBody

interface MyRemoteDataSource {
suspend fun getInterestAnimals(
lastReportId: Long,
lastProtectId: Long
lastId: Long,
): BaseResponse<MyInterestResponseDto>

suspend fun getReportHistory(
lastReportId: Long
lastId: Long
): BaseResponse<MyReportHistoryResponseDto>

suspend fun getViewedAnimals(
lastReportId: Long,
lastProtectId: Long
lastId: Long,
): BaseResponse<MyViewedAnimalsResponseDto>

suspend fun deleteUser(): NullableBaseResponse<Unit>

suspend fun patchNickname(newNickname: String): NullableBaseResponse<Unit>
suspend fun patchNickname(request: PatchNicknameRequestDto): NullableBaseResponse<Unit>

suspend fun getNickname(): BaseResponse<MyNickNameResponseDto>

suspend fun patchProfileImageFile(file: MultipartBody.Part): NullableBaseResponse<Unit>

suspend fun patchProfileImageDefault(defaultProfileImageName: RequestBody): NullableBaseResponse<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ package com.example.findu.data.dataremote.datasourceimpl

import com.example.findu.data.dataremote.datasource.InterestRemoteDataSource
import com.example.findu.data.dataremote.model.base.NullableBaseResponse
import com.example.findu.data.dataremote.model.request.MyInterestRequestDto
import com.example.findu.data.dataremote.model.response.my.MyInterestResponseDto
import com.example.findu.data.dataremote.service.InterestService
import javax.inject.Inject

class InterestRemoteDataSourceImpl @Inject constructor(
private val interestService: InterestService
private val interestService: InterestService,
) : InterestRemoteDataSource {
override suspend fun getInterestProtectingAnimals(id: Long) =
interestService.getInterestProtectingAnimals(id)
override suspend fun getInterestAnimals(lastId: Long) =
interestService.getInterestAnimals(lastId)

override suspend fun getInterestReportAnimals(id: Long) =
interestService.getInterestReportAnimals(id)
override suspend fun registerInterestAnimal(reportId: Long) =
interestService.registerInterestAnimal(MyInterestRequestDto(reportId))

override suspend fun deleteInterestAnimal(reportId: Long): NullableBaseResponse<Unit> =
interestService.deleteInterestAnimal(reportId)

override suspend fun deleteInterestProtectingAnimals(reportId: Long): NullableBaseResponse<Unit> =
interestService.deleteInterestProtectingAnimals(reportId)

override suspend fun deleteInterestReportAnimals(reportId: Long): NullableBaseResponse<Unit> =
interestService.deleteInterestReportAnimals(reportId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,47 @@ package com.example.findu.data.dataremote.datasourceimpl
import com.example.findu.data.dataremote.datasource.MyRemoteDataSource
import com.example.findu.data.dataremote.model.base.BaseResponse
import com.example.findu.data.dataremote.model.base.NullableBaseResponse
import com.example.findu.data.dataremote.model.request.PatchNicknameRequestDto
import com.example.findu.data.dataremote.model.response.my.MyInterestResponseDto
import com.example.findu.data.dataremote.model.response.my.MyNickNameResponseDto
import com.example.findu.data.dataremote.model.response.my.MyReportHistoryResponseDto
import com.example.findu.data.dataremote.model.response.my.MyViewedAnimalsResponseDto
import com.example.findu.data.dataremote.service.MyService
import com.example.findu.data.dataremote.util.handleBaseResponse
import okhttp3.MultipartBody
import okhttp3.RequestBody
import javax.inject.Inject

class MyRemoteDataSourceImpl @Inject constructor(
private val myService: MyService
private val myService: MyService,
) : MyRemoteDataSource {
override suspend fun getInterestAnimals(
lastReportId: Long,
lastProtectId: Long
lastId: Long,
): BaseResponse<MyInterestResponseDto> =
myService.getInterestAnimals(lastReportId, lastProtectId)
myService.getInterestAnimals(lastId)

override suspend fun getReportHistory(lastReportId: Long): BaseResponse<MyReportHistoryResponseDto> =
myService.getReportHistory(lastReportId)
override suspend fun getReportHistory(lastId: Long): BaseResponse<MyReportHistoryResponseDto> =
myService.getReportHistory(lastId)

override suspend fun getViewedAnimals(
lastReportId: Long,
lastProtectId: Long
lastId: Long,
): BaseResponse<MyViewedAnimalsResponseDto> =
myService.getViewedAnimals(lastReportId, lastProtectId)
myService.getViewedAnimals(lastId)

override suspend fun deleteUser(): NullableBaseResponse<Unit> =
myService.deleteUser()

override suspend fun patchNickname(newNickname: String): NullableBaseResponse<Unit> =
myService.patchNickname(newNickname)
override suspend fun patchNickname(request: PatchNicknameRequestDto): NullableBaseResponse<Unit> =
myService.patchNickname(request)

override suspend fun getNickname(): BaseResponse<MyNickNameResponseDto> =
myService.getNickname()

override suspend fun patchProfileImageFile(file: MultipartBody.Part): NullableBaseResponse<Unit> =
myService.patchProfileImageFile(file)


override suspend fun patchProfileImageDefault(defaultProfileImageName: RequestBody): NullableBaseResponse<Unit> =
myService.patchProfileImageDefault(defaultProfileImageName)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.findu.data.dataremote.model.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class MyInterestRequestDto(
@SerialName("reportId")
val reportId : Long
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.findu.data.dataremote.model.request

import kotlinx.serialization.Serializable

@Serializable
data class PatchNicknameRequestDto(
val newNickname: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,24 @@ data class MyInterestResponseDto(
val interestAnimals: List<InterestAnimalDto>,
@SerialName("isLast")
val isLast: Boolean,
@SerialName("lastInterestProtectId")
val lastInterestProtectId: Long,
@SerialName("lastInterestReportId")
val lastInterestReportId: Long
@SerialName("lastId")
val lastId: Long,
) {
@Serializable
data class InterestAnimalDto(
@SerialName("animalId")
val animalId: Long,
@SerialName("date")
val date: String,
@SerialName("interest")
val interest: Boolean,
@SerialName("location")
val location: String,
@SerialName("tag")
val tag: String,
@SerialName("reportId")
val reportId: Long,
@SerialName("thumbnailImageUrl")
val thumbnailImageUrl: String,
@SerialName("title")
val title: String
)
val title: String,
@SerialName("tag")
val tag: String,
@SerialName("date")
val date: String,
@SerialName("address")
val address: String,


)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class MyNickNameResponseDto(
@SerialName("nickname")
val nickname: String
val nickname: String,
@SerialName("profileImage")
val profileImage : String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,30 @@ data class MyReportHistoryResponseDto(
@SerialName("isLast")
val isLast: Boolean,
@SerialName("lastReportId")
val lastReportId: Long,
val lastId: Long,
@SerialName("reports")
val reports: List<Report>
) {
@Serializable
data class Report(
@SerialName("date")
val date: String,
@SerialName("location")
val location: String,
@SerialName("reportId")
val reportId: Long,
@SerialName("tag")
val tag: String,
@SerialName("thumbnailImageUrl")
val thumbnailImageUrl: String,
@SerialName("title")
val title: String
val title: String,
@SerialName("tag")
val tag: String,
@SerialName("date")
val date: String,
@SerialName("location")
val location: String,
@SerialName("interest")
val interest : Boolean,





)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@ import kotlinx.serialization.Serializable
data class MyViewedAnimalsResponseDto(
@SerialName("isLast")
val isLast: Boolean,
@SerialName("lastViewedProtectId")
val lastViewedProtectId: Long,
@SerialName("lastViewedReportId")
val lastViewedReportId: Long,
@SerialName("viewedAnimals")
val viewedAnimals: List<ViewedAnimal>
@SerialName("lastId")
val lastId: Long,
@SerialName("cards")
val cards: List<Card>
) {
@Serializable
data class ViewedAnimal(
@SerialName("cardId")
val cardId: Long,
data class Card(
@SerialName("reportId")
val reportId: Long,
@SerialName("thumbnailImageUrl")
val thumbnailImageUrl: String,
@SerialName("title")
val title: String,
@SerialName("tag")
val tag: String,
@SerialName("date")
val date: String,
@SerialName("interest")
val interest: Boolean,
@SerialName("location")
val location: String,
@SerialName("tag")
val tag: String,
@SerialName("thumbnailImageUrl")
val thumbnailImageUrl: String,
@SerialName("title")
val title: String
@SerialName("interest")
val interest: Boolean,

)
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package com.example.findu.data.dataremote.service

import com.example.findu.data.dataremote.model.base.NullableBaseResponse
import com.example.findu.data.dataremote.model.request.MyInterestRequestDto
import com.example.findu.data.dataremote.model.response.my.MyInterestResponseDto
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface InterestService {
@POST("/api/v1/users/interest-animals/protecting-animals")
suspend fun getInterestProtectingAnimals(
@Body id : Long
) : NullableBaseResponse<Int>

@POST("/api/v1/users/interest-animals/report-animals")
suspend fun getInterestReportAnimals(
@Body id : Long
) : NullableBaseResponse<Int>
@GET("/api/v2/users/me/interest-animals")
suspend fun getInterestAnimals(
@Query("lastId") lastId: Long
): NullableBaseResponse<MyInterestResponseDto>

@DELETE("/api/v1/users/interest-animals/protecting-animals/{protecting_report_id}")
suspend fun deleteInterestProtectingAnimals(
@Path("protecting_report_id") reportId : Long
@POST("/api/v2/users/me/interest-animals")
suspend fun registerInterestAnimal(
@Body request: MyInterestRequestDto
) : NullableBaseResponse<Unit>

@DELETE("/api/v1/users/interest-animals/report-animals/{report_id}")
suspend fun deleteInterestReportAnimals(
@Path("report_id") reportId : Long
@DELETE("/api/v2/users/me/interest-animals")
suspend fun deleteInterestAnimal(
@Query("reportId") reportId : Long
) : NullableBaseResponse<Unit>

}
Loading