Skip to content
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

Refactor/#719 데이터 모델 리팩토링 #860

Merged
merged 34 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d957578
refactor: Activity 목록 조회 반환 타입을 List<ActivityResponse>로 변경
tmdgh1592 Nov 21, 2023
7f5e14a
refactor: OpenProfileUrl 업데이트 API 제거
tmdgh1592 Nov 21, 2023
d237a11
refactor: 사용자의 Activity 목록 조회 반환 타입을 List<ActivityResponse>로 변경
tmdgh1592 Nov 21, 2023
b772169
refactor: 사용자의 Activity 삭제 반환 타입을 List<ActivityResponse>로 변경
tmdgh1592 Nov 21, 2023
4da33a4
refactor: 사용자 조회 Response에서 openProfileUrl을 제거하고 활동 목록을 조회하도록 변경
tmdgh1592 Nov 21, 2023
0cc3007
refactor: MemberActivitiesResponse mapper 제거
tmdgh1592 Nov 21, 2023
fe1f538
refactor: Member mapper에 활동 목록 변환 로직 추가
tmdgh1592 Nov 21, 2023
ea06897
refactor: ActivityType을 String에서 enum으로 받도록 변경
tmdgh1592 Nov 21, 2023
60e0eea
refactor: ActivityType의 FIELD를 INTEREST_FIELD로 변경
tmdgh1592 Nov 21, 2023
c5caef0
refactor: MemberOpenProfileUrlUpdateRequest 제거
tmdgh1592 Nov 21, 2023
6165f82
refactor: 라인 포맷팅
tmdgh1592 Nov 21, 2023
05538a4
refactor: 사용자 활동 추가의 반환 타입을 List<ActivityResponse>로 변경
tmdgh1592 Nov 21, 2023
54a239c
refactor: 사용하지 않는 클래스 제거
tmdgh1592 Nov 21, 2023
3055904
refactor: MemberActivitiesUpdateRequest를 MemberActivitiesAddRequest로 변경
tmdgh1592 Nov 21, 2023
a847215
refactor(event): Conference, Competition, EventDetail을 Event로 통합
ki960213 Nov 21, 2023
f53d236
refactor(scrappedEvent): ScrappedEvent를 Event로 통합
ki960213 Nov 21, 2023
941d9a2
refactor(recruitment): Recruitment 리팩터링
ki960213 Nov 21, 2023
5f11ee4
refactor : MessageRoom, Message 모델 리팩토링
chws0508 Nov 22, 2023
c7351a1
refactor : Message Repository 리팩토링
chws0508 Nov 22, 2023
27875dd
refactor : MessageRoom 화면 리팩토링
chws0508 Nov 22, 2023
4bd0de9
refactor : Message 리팩토링
chws0508 Nov 22, 2023
182c80b
refactor : FeedList 리팩토링
chws0508 Nov 22, 2023
05adcd7
refactor : FeedDetail 리팩토링
chws0508 Nov 22, 2023
bfddccf
refactor : FeedWriting 리팩토링
chws0508 Nov 22, 2023
752518e
refactor : BaseUrl 주소 변경 및 버젼 변경
chws0508 Nov 28, 2023
1669163
Merge remote-tracking branch 'origin/android-main' into Refactor/#719…
ki960213 Nov 29, 2023
325b56e
refactor(Comment): Comment 데이터 모델 리팩터링
ki960213 Nov 29, 2023
72dca65
refactor(MyPost): RecruitmentRepository에서 특정 회원이 작성한 함께해요 글을 조회할 수 있도…
ki960213 Oct 31, 2023
5845f15
refactor(MyPost): MyPost를 사용하지 않도록 리팩터링
ki960213 Nov 30, 2023
556f67f
refactor(MyPost): MyPost 데이터 모델 및 그와 관련된 Repository 제거
ki960213 Nov 30, 2023
5637a95
refactor(MyPost): UI 레이어에서 MyPost를 MyRecruitment로 변경
ki960213 Nov 30, 2023
771a40c
refactor(RecruitmentNotification, RecruitmentStatus): RecruitmentNoti…
ki960213 Nov 30, 2023
af0bcb5
refactor(DefaultRecruitmentRepository): DefaultRecruitmentRepository에…
ki960213 Nov 30, 2023
c6ef825
style: ktlint 적용
ki960213 Nov 30, 2023
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
2 changes: 1 addition & 1 deletion android/2023-emmsale/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".presentation.ui.myPostList.MyPostActivity" />
<activity android:name=".presentation.ui.myRecruitmentList.MyRecruitmentActivity" />
<activity android:name=".presentation.ui.notificationTagConfig.NotificationTagConfigActivity" />
<activity android:name=".presentation.ui.myCommentList.MyCommentsActivity" />
<activity android:name=".presentation.ui.blockMemberList.MemberBlockActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.emmsale.data.mapper
import com.emmsale.data.apiModel.response.CommentFamilyApiModel
import com.emmsale.data.apiModel.response.CommentResponse
import com.emmsale.data.model.Comment
import com.emmsale.data.model.Feed
import com.emmsale.data.model.Member
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

Expand All @@ -11,16 +13,20 @@ fun List<CommentFamilyApiModel>.toData(): List<Comment> = map(CommentFamilyApiMo

fun CommentFamilyApiModel.toData() = Comment(
id = parentComment.commentId,
feedId = parentComment.feedId,
feedTitle = parentComment.feedTitle,
authorId = parentComment.memberId,
authorName = parentComment.memberName,
authorImageUrl = parentComment.memberImageUrl,
parentId = parentComment.parentId,
feed = Feed(
id = parentComment.feedId,
title = parentComment.feedTitle,
),
writer = Member(
id = parentComment.memberId,
name = parentComment.memberName,
profileImageUrl = parentComment.memberImageUrl,
),
parentCommentId = parentComment.parentId,
content = parentComment.content,
createdAt = LocalDateTime.parse(parentComment.createdAt, dateTimeFormatter),
updatedAt = LocalDateTime.parse(parentComment.updatedAt, dateTimeFormatter),
deleted = parentComment.deleted,
isDeleted = parentComment.deleted,
childComments = childComments.toData(),
)

Expand All @@ -29,16 +35,20 @@ fun List<CommentResponse>.toData(): List<Comment> = map(CommentResponse::toData)

fun CommentResponse.toData() = Comment(
id = commentId,
feedId = feedId,
feedTitle = feedTitle,
authorId = memberId,
authorName = memberName,
authorImageUrl = memberImageUrl,
parentId = parentId,
feed = Feed(
id = feedId,
title = feedTitle,
),
writer = Member(
id = memberId,
name = memberName,
profileImageUrl = memberImageUrl,
),
parentCommentId = parentId,
content = content,
createdAt = LocalDateTime.parse(createdAt, dateTimeFormatter),
updatedAt = LocalDateTime.parse(updatedAt, dateTimeFormatter),
deleted = deleted,
isDeleted = deleted,
childComments = listOf(),
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.emmsale.data.mapper

import com.emmsale.data.apiModel.response.MyPostResponse
import com.emmsale.data.model.MyPost
import com.emmsale.data.model.Event
import com.emmsale.data.model.Member
import com.emmsale.data.model.Recruitment
import java.time.LocalDate
import java.time.format.DateTimeFormatter

fun List<MyPostResponse>.toData(): List<MyPost> = map { it.toData() }
fun MyPostResponse.toData(): MyPost {
return MyPost(
postId = postId,
eventId = eventId,
eventName = eventName,
content = content,
updatedAt = updatedAt.toLocalDate(),
)
}
fun List<MyPostResponse>.toData(): List<Recruitment> = map { it.toData() }
fun MyPostResponse.toData() = Recruitment(
id = postId,
writer = Member(),
event = Event(id = eventId, name = eventName),
content = content,
updatedDate = updatedAt.toLocalDate(),
)

private fun String.toLocalDate(): LocalDate {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import com.emmsale.data.apiModel.response.CommentTypeNotificationResponse
import com.emmsale.data.apiModel.response.EventTypeNotificationResponse
import com.emmsale.data.apiModel.response.NotificationResponse
import com.emmsale.data.apiModel.response.NotificationResponse.NotificationType
import com.emmsale.data.apiModel.response.RecruitmentNotificationResponse
import com.emmsale.data.model.RecruitmentNotification
import com.emmsale.data.model.updatedNotification.ChildCommentNotification
import com.emmsale.data.model.updatedNotification.InterestEventNotification
import com.emmsale.data.model.updatedNotification.UpdatedNotification
Expand Down Expand Up @@ -55,18 +53,3 @@ private fun String.toLocalDateTime(): LocalDateTime {
val formatter = DateTimeFormatter.ofPattern("yyyy:MM:dd:HH:mm:ss")
return LocalDateTime.parse(this, formatter)
}

fun RecruitmentNotificationResponse.toData(): RecruitmentNotification = RecruitmentNotification(
id = id,
senderUid = senderUid,
receiverUid = receiverUid,
message = message,
eventId = eventId,
status = status.toRecruitmentStatus(),
isRead = isRead,
notificationDate = createdAt.toLocalDateTime(),
)

@JvmName("RecruitmentNotificationResponse")
fun List<RecruitmentNotificationResponse>.toData(): List<RecruitmentNotification> =
map { it.toData() }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import java.time.LocalDateTime

data class Comment(
val id: Long,
val feedId: Long,
val feedTitle: String,
val authorId: Long,
val authorName: String,
val authorImageUrl: String,
val parentId: Long?,
val content: String,
val createdAt: LocalDateTime,
val updatedAt: LocalDateTime,
val deleted: Boolean,
val childComments: List<Comment>,
val feed: Feed = Feed(),
val writer: Member = Member(),
val parentCommentId: Long? = null,
val content: String = "",
val createdAt: LocalDateTime = LocalDateTime.MAX,
val updatedAt: LocalDateTime = LocalDateTime.MAX,
val isDeleted: Boolean = false,
val childComments: List<Comment> = emptyList(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package com.emmsale.data.model
import java.time.LocalDateTime

data class Feed(
val id: Long,
val eventId: Long,
val title: String,
val content: String,
val writer: Member,
val imageUrls: List<String>,
val commentCount: Int,
val createdAt: LocalDateTime,
val updatedAt: LocalDateTime,
val id: Long = -1,
val eventId: Long = -1,
val title: String = "",
val content: String = "",
val writer: Member = Member(),
val imageUrls: List<String> = emptyList(),
val commentCount: Int = 0,
val createdAt: LocalDateTime = LocalDateTime.MAX,
val updatedAt: LocalDateTime = LocalDateTime.MAX,
) {
val titleImageUrl = imageUrls.firstOrNull()
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ data class Recruitment(
val id: Long,
val writer: Member,
val event: Event,
val content: String?,
val content: String,
val updatedDate: LocalDate,
)

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ package com.emmsale.data.repository.concretes
import com.emmsale.data.apiModel.request.NotificationListDeleteRequest
import com.emmsale.data.apiModel.request.RecruitmentNotificationReportCreateRequest
import com.emmsale.data.apiModel.response.NotificationResponse
import com.emmsale.data.apiModel.response.RecruitmentNotificationResponse
import com.emmsale.data.common.retrofit.callAdapter.ApiResponse
import com.emmsale.data.mapper.toData
import com.emmsale.data.mapper.toRequestModel
import com.emmsale.data.model.RecruitmentNotification
import com.emmsale.data.model.RecruitmentStatus
import com.emmsale.data.model.updatedNotification.UpdatedNotification
import com.emmsale.data.repository.interfaces.NotificationRepository
import com.emmsale.data.service.NotificationService
Expand All @@ -21,23 +17,6 @@ class DefaultNotificationRepository @Inject constructor(
@IoDispatcher private val dispatcher: CoroutineDispatcher,
private val notificationService: NotificationService,
) : NotificationRepository {
override suspend fun getRecruitmentNotifications(
memberId: Long,
): ApiResponse<List<RecruitmentNotification>> = withContext(dispatcher) {
notificationService
.getRecruitmentNotifications(memberId)
.map(List<RecruitmentNotificationResponse>::toData)
}

override suspend fun updateRecruitmentStatus(
notificationId: Long,
recruitmentStatus: RecruitmentStatus,
): ApiResponse<Unit> = withContext(dispatcher) {
notificationService.updateRecruitmentStatus(
notificationId = notificationId,
newStatus = recruitmentStatus.toRequestModel(),
)
}

override suspend fun updateNotificationReadStatus(
notificationId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class DefaultRecruitmentRepository @Inject constructor(
.getRecruitment(eventId, recruitmentId)
.map(RecruitmentResponse::toData)

override suspend fun getMemberRecruitments(
memberId: Long,
): ApiResponse<List<Recruitment>> = recruitmentService
.getMemberRecruitments(memberId)
.map { it.toData() }

override suspend fun postRecruitment(
eventId: Long,
content: String,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
package com.emmsale.data.repository.interfaces

import com.emmsale.data.common.retrofit.callAdapter.ApiResponse
import com.emmsale.data.model.RecruitmentNotification
import com.emmsale.data.model.RecruitmentStatus
import com.emmsale.data.model.updatedNotification.UpdatedNotification

interface NotificationRepository {

suspend fun getRecruitmentNotifications(memberId: Long): ApiResponse<List<RecruitmentNotification>>

suspend fun updateRecruitmentStatus(
notificationId: Long,
recruitmentStatus: RecruitmentStatus,
): ApiResponse<Unit>

suspend fun updateNotificationReadStatus(notificationId: Long): ApiResponse<Unit>

suspend fun getUpdatedNotifications(memberId: Long): ApiResponse<List<UpdatedNotification>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ interface RecruitmentRepository {
eventId: Long,
): ApiResponse<List<Recruitment>>

suspend fun getMemberRecruitments(memberId: Long): ApiResponse<List<Recruitment>>

suspend fun getEventRecruitment(
eventId: Long,
recruitmentId: Long,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.emmsale.data.service
import com.emmsale.data.apiModel.request.RecruitmentCreateRequest
import com.emmsale.data.apiModel.request.RecruitmentDeleteRequest
import com.emmsale.data.apiModel.request.RecruitmentReportCreateRequest
import com.emmsale.data.apiModel.response.MyPostResponse
import com.emmsale.data.apiModel.response.RecruitmentReportResponse
import com.emmsale.data.apiModel.response.RecruitmentResponse
import com.emmsale.data.common.retrofit.callAdapter.ApiResponse
Expand All @@ -27,6 +28,11 @@ interface RecruitmentService {
@Path("recruitment-post-id") recruitmentId: Long,
): ApiResponse<RecruitmentResponse>

@GET("/events/recruitment-posts")
suspend fun getMemberRecruitments(
@Query("member-id") memberId: Long,
): ApiResponse<List<MyPostResponse>>

@POST("/events/{eventId}/recruitment-posts")
suspend fun postRecruitment(
@Path("eventId") eventId: Long,
Expand Down
Loading
Loading