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,4 +1,4 @@
package com.kuit.afternote.data
package com.kuit.afternote.data.dto.response

import com.kuit.afternote.data.service.ApiException
import kotlinx.serialization.SerialName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.kuit.afternote.data.repositoryimpl

import com.kuit.afternote.data.requireData
import com.kuit.afternote.data.dto.response.requireData
import com.kuit.afternote.domain.repository.MemorialThumbnailUploadRepository
import com.kuit.afternote.feature.user.data.api.ImageApiService
import com.kuit.afternote.feature.user.data.dto.PresignedUrlRequestDto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.kuit.afternote.data.repositoryimpl
import android.content.Context
import android.net.Uri
import androidx.core.net.toUri
import com.kuit.afternote.data.requireData
import com.kuit.afternote.data.dto.response.requireData
import com.kuit.afternote.domain.repository.MemorialVideoUploadRepository
import com.kuit.afternote.feature.user.data.api.ImageApiService
import com.kuit.afternote.feature.user.data.dto.PresignedUrlRequestDto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.kuit.afternote.data.repositoryimpl

import android.content.Context
import android.net.Uri
import com.kuit.afternote.data.requireData
import com.kuit.afternote.data.dto.response.requireData
import com.kuit.afternote.domain.repository.PhotoUploadRepository
import com.kuit.afternote.feature.user.data.api.ImageApiService
import com.kuit.afternote.feature.user.data.dto.PresignedUrlRequestDto
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kuit.afternote.data.service

import com.kuit.afternote.feature.afternote.data.service.AfternoteApiService
import com.kuit.afternote.feature.afternote.data.service.MusicApiService
import com.kuit.afternote.feature.dailyrecord.data.api.DailyRecordApiService
import dagger.Module
import dagger.Provides
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.kuit.afternote.data.di
package com.kuit.afternote.di

import com.kuit.afternote.data.repositoryimpl.PhotoUploadRepositoryImpl
import com.kuit.afternote.domain.repository.PhotoUploadRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.kuit.afternote.feature.admin.data.api

import com.kuit.afternote.data.BaseResponse
import com.kuit.afternote.data.dto.response.BaseResponse
import com.kuit.afternote.feature.admin.data.dto.AdminVerificationResponseDto
import com.kuit.afternote.feature.admin.data.dto.ApproveVerificationRequestDto
import com.kuit.afternote.feature.admin.data.dto.RejectVerificationRequestDto
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.kuit.afternote.feature.admin.data.repository.impl

import com.kuit.afternote.data.requireData
import com.kuit.afternote.data.dto.response.requireData
import com.kuit.afternote.feature.admin.data.api.AdminApiService
import com.kuit.afternote.feature.admin.data.dto.AdminVerificationResponseDto
import com.kuit.afternote.feature.admin.data.dto.ApproveVerificationRequestDto
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.kuit.afternote.data.dto
package com.kuit.afternote.feature.afternote.data.dto

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.kuit.afternote.data.dto.response
package com.kuit.afternote.feature.afternote.data.dto.response

import com.kuit.afternote.data.dto.MusicTrack
import com.kuit.afternote.feature.afternote.data.dto.MusicTrack
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,28 @@ package com.kuit.afternote.feature.afternote.data.mapper

import com.kuit.afternote.feature.afternote.data.dto.AfternoteCredentials
import com.kuit.afternote.feature.afternote.data.dto.AfternoteMemorialVideo
import com.kuit.afternote.feature.afternote.data.dto.AfternotePlaylist
import com.kuit.afternote.feature.afternote.data.dto.AfternoteReceiverRef
import com.kuit.afternote.feature.afternote.data.dto.AfternoteSong
import com.kuit.afternote.feature.afternote.data.dto.request.AfternoteUpdateRequest
import com.kuit.afternote.feature.afternote.domain.model.AfternoteUpdateRequestInput
import com.kuit.afternote.feature.afternote.domain.model.CredentialsInput
import com.kuit.afternote.feature.afternote.domain.model.ReceiverRefInput
import com.kuit.afternote.feature.afternote.domain.model.playlist.AfternotePlaylistInput
import com.kuit.afternote.feature.afternote.domain.model.UpdateRequestInput
import com.kuit.afternote.feature.afternote.domain.model.playlist.MemorialVideoInput
import com.kuit.afternote.feature.afternote.domain.model.playlist.SongInput

fun AfternotePlaylistInput.toDto() =
AfternotePlaylist(
profilePhoto = profilePhoto,
atmosphere = atmosphere,
memorialPhotoUrl = memorialPhotoUrl,
songs = songs.map { it.toDto() },
memorialVideo = memorialVideo?.toDto(),
)

fun MemorialVideoInput.toDto() =
AfternoteMemorialVideo(
videoUrl = videoUrl,
thumbnailUrl = thumbnailUrl,
)

fun SongInput.toDto() =
AfternoteSong(
id = id,
title = title,
artist = artist,
coverUrl = coverUrl,
)

fun AfternoteUpdateRequestInput.toDto() =
fun UpdateRequestInput.toDto() =
AfternoteUpdateRequest(
category = category,
title = title,
processMethod = processMethod,
actions = actions,
leaveMessage = leaveMessage,
credentials = credentials?.toDto(),
receivers = receivers?.map { it.toDto() },
receivers = receivers?.toDto(),
playlist = playlist?.toDto(),
)

Expand All @@ -54,7 +33,12 @@ fun CredentialsInput.toDto() =
password = password,
)

fun ReceiverRefInput.toDto() =
private fun ReceiverRefInput.toDto() =
AfternoteReceiverRef(
receiverId = receiverId,
)

private fun List<ReceiverRefInput>?.toDto() =
this?.map {
it.toDto()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,114 +2,37 @@ package com.kuit.afternote.feature.afternote.data.mapper

import com.kuit.afternote.domain.model.AfternoteServiceType
import com.kuit.afternote.feature.afternote.data.dto.AfternoteListItem
import com.kuit.afternote.feature.afternote.data.dto.response.AfternoteDetailResponse
import com.kuit.afternote.feature.afternote.data.dto.response.AfternoteListResponse
import com.kuit.afternote.feature.afternote.domain.model.AfternoteDetail
import com.kuit.afternote.feature.afternote.domain.model.AfternoteDetailCredentials
import com.kuit.afternote.feature.afternote.domain.model.AfternoteDetailProcessing
import com.kuit.afternote.feature.afternote.domain.model.AfternoteDetailReceiver
import com.kuit.afternote.feature.afternote.domain.model.AfternoteDetailTimestamps
import com.kuit.afternote.feature.afternote.domain.model.AfternoteItem
import com.kuit.afternote.feature.afternote.domain.model.PagedAfternotes
import com.kuit.afternote.feature.afternote.domain.model.playlist.AfternoteDetailSong
import com.kuit.afternote.feature.afternote.domain.model.playlist.AfternotePlaylistDetail
import com.kuit.afternote.feature.afternote.domain.model.playlist.PlaylistDetailMemorialMedia
import com.kuit.afternote.feature.afternote.domain.model.Item

/**
* Maps server DTOs to domain models at the boundary only.
*/
object AfternoteMapper {
// -- List mapping --

fun toDomain(dto: AfternoteListItem): AfternoteItem =
AfternoteItem(
id = dto.afternoteId.toString(),
serviceName = dto.title,
date = formatDateFromServer(dto.createdAt),
type = categoryToServiceType(dto.category),
)

fun toDomainList(dtos: List<AfternoteListItem>): List<AfternoteItem> = dtos.map { toDomain(it) }

// -- Detail mapping --

fun toDetailDomain(dto: AfternoteDetailResponse): AfternoteDetail =
AfternoteDetail(
id = dto.afternoteId,
category = dto.category,
title = dto.title,
timestamps =
AfternoteDetailTimestamps(
createdAt = formatDateFromServer(dto.createdAt),
updatedAt = formatDateFromServer(dto.createdAt),
),
type = categoryToServiceType(dto.category),
credentials =
AfternoteDetailCredentials(
id = dto.credentials?.id,
password = dto.credentials?.password,
),
receivers =
dto.receivers?.map { r ->
AfternoteDetailReceiver(
receiverId = r.receiverId,
name = r.name ?: "",
relation = r.relation ?: "",
phone = r.phone ?: "",
)
} ?: emptyList(),
processing =
AfternoteDetailProcessing(
method = dto.processMethod,
actions = dto.actions ?: emptyList(),
leaveMessage = dto.leaveMessage,
),
playlist =
dto.playlist?.let { p ->
AfternotePlaylistDetail(
profilePhoto = p.profilePhoto,
atmosphere = p.atmosphere,
songs =
p.songs.map { s ->
AfternoteDetailSong(
id = s.id,
title = s.title,
artist = s.artist,
coverUrl = s.coverUrl,
)
},
playlistDetailMemorialMedia =
PlaylistDetailMemorialMedia(
photoUrl = p.memorialPhotoUrl ?: p.profilePhoto,
videoUrl = p.memorialVideo?.videoUrl,
thumbnailUrl = p.memorialVideo?.thumbnailUrl,
),
)
},
)

fun toPagedNotes(data: AfternoteListResponse) =
PagedAfternotes(
items = toDomainList(data.content),
hasNext = data.hasNext,
)

// -- Internal helpers --

private fun formatDateFromServer(createdAt: String): String =
try {
// Server returns "2025-11-26T14:30:00" -> display "2025.11.26"
val datePart = createdAt.substringBefore('T')
datePart.replace('-', '.')
} catch (_: Exception) {
createdAt
}

internal fun categoryToServiceType(category: String): AfternoteServiceType =
when (category.uppercase()) {
"SOCIAL" -> AfternoteServiceType.SOCIAL_NETWORK
"GALLERY" -> AfternoteServiceType.GALLERY_AND_FILES
"MUSIC", "PLAYLIST" -> AfternoteServiceType.MEMORIAL
else -> AfternoteServiceType.SOCIAL_NETWORK
}
}
fun AfternoteListItem.toDomain() =
Item(
id = afternoteId.toString(),
serviceName = title,
date = formatDateFromServer(createdAt),
type = categoryToServiceType(category),
)

fun List<AfternoteListItem>.toDomainList() = map { it.toDomain() }

// -- Internal helpers --

internal fun formatDateFromServer(serverDateTime: String): String =
try {
// Server returns "2025-11-26T14:30:00" -> display "2025.11.26"
val datePart = serverDateTime.substringBefore('T')
datePart.replace('-', '.')
} catch (_: Exception) {
serverDateTime
}

internal fun categoryToServiceType(category: String): AfternoteServiceType =
when (category.uppercase()) {
"SOCIAL" -> AfternoteServiceType.SOCIAL_NETWORK
"GALLERY" -> AfternoteServiceType.GALLERY_AND_FILES
"MUSIC", "PLAYLIST" -> AfternoteServiceType.MEMORIAL
else -> AfternoteServiceType.SOCIAL_NETWORK
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.kuit.afternote.feature.afternote.data.mapper

import com.kuit.afternote.feature.afternote.data.dto.AfternotePlaylist
import com.kuit.afternote.feature.afternote.data.dto.AfternoteSong
import com.kuit.afternote.feature.afternote.domain.model.playlist.PlaylistInput
import com.kuit.afternote.feature.afternote.domain.model.playlist.SongInput

fun PlaylistInput.toDto() =
AfternotePlaylist(
profilePhoto = profilePhoto,
atmosphere = atmosphere,
memorialPhotoUrl = memorialPhotoUrl,
songs = songs.toDto(),
memorialVideo = memorialVideo?.toDto(),
)

private fun SongInput.toDto() =
AfternoteSong(
id = id,
title = title,
artist = artist,
coverUrl = coverUrl,
)

private fun List<SongInput>.toDto() =
map {
it.toDto()
}
Loading
Loading