Skip to content

Commit

Permalink
학사일정, 공지사항 즐겨찾기 페이지 구현 (#30)
Browse files Browse the repository at this point in the history
* 🔨agp 버전 업그레이드

* 🔨 북마크 최근 학사일정 조회 데이터 클래스, DTO 구현

* 🔨 북마크 전체, 최근 학사일정 조회 repository 구현

* 🔨 북마크 전체, 최근 학사일정 조회 UseCase 구현

* 🔨 북마크 전체, 최근 학사일정 조회 Api 구현

* 🗑️ 즐겨찾기 페이지 키워드 관련 부분 삭제, 프래그먼트 이름 변경

* 🔨️ KeywordManageFragment import 변경

* 🔨️ 바텀 내비게이션 마이 페이지 아이콘 -> 즐겨찾기 아이콘 변경

* 🔨️ 파일 이름 변경, 북마크 관련 부분 이동

* 🔨️ 파일 이름 변경

* 🔨️ 파일 이름 변경

* 🔨️최근 북마크 학사일정 조회 기능 구현

* 🔨️즐겨찾기한 학사일정, 공지사항 구현

* 🔨 홈 화면 학사일정 날짜 범위 수정

* 🔨 알림 페이지 DTO 수정, 빈 화면 출력 문구

* 🔨 토스트 메시지 수정
  • Loading branch information
GyeongminKimGyeongminKim authored Sep 21, 2024
1 parent 912d244 commit 4e1aad6
Show file tree
Hide file tree
Showing 45 changed files with 1,202 additions and 813 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.neverland.data.datasource
import com.neverland.data.remote.model.BaseResponse
import com.neverland.data.remote.model.notice.BookmarkNoticeDTO
import com.neverland.data.remote.model.notice.RecentBookmarkNoticeDTO
import com.neverland.data.remote.model.univ.AcademicScheduleResDTO
import com.neverland.data.remote.model.univ.RecentBookmarkScheduleResDTO
import retrofit2.Response

interface BookmarkDataSource {
Expand All @@ -11,10 +13,18 @@ interface BookmarkDataSource {
ssaId: String
): Response<BaseResponse<BookmarkNoticeDTO>>

suspend fun getScheduleBookmark(
ssaId: String
): Response<BaseResponse<List<AcademicScheduleResDTO>>>

suspend fun getRecentNoticeBookmark(
ssaId: String
): Response<BaseResponse<List<RecentBookmarkNoticeDTO>>>

suspend fun getRecentScheduleBookmark(
ssaId: String
): Response<BaseResponse<List<RecentBookmarkScheduleResDTO>>>

suspend fun postNoticeBookmark(
category: String,
noticeId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.neverland.data.datasource.BookmarkDataSource
import com.neverland.data.remote.model.BaseResponse
import com.neverland.data.remote.model.notice.BookmarkNoticeDTO
import com.neverland.data.remote.model.notice.RecentBookmarkNoticeDTO
import com.neverland.data.remote.model.univ.AcademicScheduleResDTO
import com.neverland.data.remote.model.univ.RecentBookmarkScheduleResDTO
import com.neverland.data.remote.service.BookmarkService
import retrofit2.Response
import javax.inject.Inject
Expand All @@ -15,10 +17,18 @@ class BookmarkDataSourceImpl @Inject constructor(
return service.getNoticeBookmark(ssaId)
}

override suspend fun getScheduleBookmark(ssaId: String): Response<BaseResponse<List<AcademicScheduleResDTO>>> {
return service.getScheduleBookmark(ssaId)
}

override suspend fun getRecentNoticeBookmark(ssaId: String): Response<BaseResponse<List<RecentBookmarkNoticeDTO>>> {
return service.getRecentNoticeBookmark(ssaId)
}

override suspend fun getRecentScheduleBookmark(ssaId: String): Response<BaseResponse<List<RecentBookmarkScheduleResDTO>>> {
return service.getRecentScheduleBookmark(ssaId)
}

override suspend fun postNoticeBookmark(
category: String,
noticeId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ data class AlarmDTO(
val id: Int,
@SerializedName("marked")
val marked: Boolean,
@SerializedName("noticeType_english")
@SerializedName("noticeTypeEnglish")
val noticeTypeEnglish: String,
@SerializedName("noticeType_korean")
@SerializedName("noticeTypeKorean")
val noticeTypeKorean: String,
@SerializedName("pubDate")
val pubDate: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.neverland.data.remote.model.univ

import com.google.gson.annotations.SerializedName

data class RecentBookmarkScheduleResDTO(
@SerializedName("endDate") val endDate: String,
@SerializedName("id") val id: Int,
@SerializedName("startDate") val startDate: String,
@SerializedName("title") val title: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.neverland.data.remote.service
import com.neverland.data.remote.model.BaseResponse
import com.neverland.data.remote.model.notice.BookmarkNoticeDTO
import com.neverland.data.remote.model.notice.RecentBookmarkNoticeDTO
import com.neverland.data.remote.model.univ.AcademicScheduleResDTO
import com.neverland.data.remote.model.univ.RecentBookmarkScheduleResDTO
import retrofit2.Response
import retrofit2.http.DELETE
import retrofit2.http.GET
Expand All @@ -11,16 +13,28 @@ import retrofit2.http.Query

interface BookmarkService {

@GET("/api/bookmark")
@GET("/api/bookmark/notice")
suspend fun getNoticeBookmark(
@Query("ssaid") ssaId: String
): Response<BaseResponse<BookmarkNoticeDTO>>

@GET("/api/bookmark/recent")
@GET("/api/bookmark/schedule")
suspend fun getScheduleBookmark(
@Query("ssaid") ssaId: String
): Response<BaseResponse<List<AcademicScheduleResDTO>>>

// 공지사항 최근 즐겨찾기 3개 내역 조회
@GET("/api/bookmark/recent-notice")
suspend fun getRecentNoticeBookmark(
@Query("ssaid") ssaId: String
): Response<BaseResponse<List<RecentBookmarkNoticeDTO>>>

// 학사일정 최근 즐겨찾기 3개 내역 조회
@GET("/api/bookmark/recent-schedule")
suspend fun getRecentScheduleBookmark(
@Query("ssaid") ssaId: String
): Response<BaseResponse<List<RecentBookmarkScheduleResDTO>>>

@POST("/api/bookmark")
suspend fun postNoticeBookmark(
@Query("category") category: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.neverland.data.utils.handleResponse
import com.neverland.domain.model.notice.BookmarkNotice
import com.neverland.domain.model.notice.NoticeItem
import com.neverland.domain.model.notice.RecentBookmarkNotice
import com.neverland.domain.model.univ.AcademicSchedule
import com.neverland.domain.model.univ.RecentBookmarkSchedule
import com.neverland.domain.repository.BookmarkRepository
import javax.inject.Inject

Expand Down Expand Up @@ -147,6 +149,24 @@ class BookmarkRepositoryImpl @Inject constructor(
)
}

override suspend fun getScheduleBookmark(ssaId: String): Result<List<AcademicSchedule>> {
return handleResponse(
dataNullSafe = false,
call = { dataSource.getScheduleBookmark(ssaId) },
onSuccess = { data ->
data?.takeIf { it.isNotEmpty() }?.map {
AcademicSchedule(
id = it.id,
title = it.title,
startDate = it.startDate,
endDate = it.endDate,
marked = it.marked
)
} ?: emptyList()
}
)
}

override suspend fun getRecentNoticeBookmark(ssaId: String): Result<List<RecentBookmarkNotice>> {
return handleResponse(
dataNullSafe = false,
Expand All @@ -164,6 +184,22 @@ class BookmarkRepositoryImpl @Inject constructor(
)
}

override suspend fun getRecentScheduleBookmark(ssaId: String): Result<List<RecentBookmarkSchedule>> {
return handleResponse(
dataNullSafe = false,
call = { dataSource.getRecentScheduleBookmark(ssaId) },
onSuccess = { data ->
data?.takeIf { it.isNotEmpty() }?.map {
RecentBookmarkSchedule(
id = it.id,
title = it.title,
startDate = it.startDate,
endDate = it.endDate
)
} ?: emptyList()
}
)
}

override suspend fun postNoticeBookmark(
category: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ data class AcademicSchedule(
val title: String,
val startDate: String,
val endDate: String,
val marked: Boolean
var marked: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.neverland.domain.model.univ

data class BookmarkScheduleGroup(
val year: Int, // 연도 추가
val month: String,
val schedules: List<AcademicSchedule>
)

fun groupSchedulesByYearAndMonth(schedules: List<AcademicSchedule>): List<BookmarkScheduleGroup> {
return schedules.groupBy { schedule ->
// 날짜에서 연도와 월 추출 (예: "2024-09-10" -> "2024년", "9월")
val dateParts = schedule.startDate.split("-")
val year = dateParts[0].toInt()
val month = dateParts[1]
Pair(year, month)
}.map { (yearMonthPair, schedules) ->
BookmarkScheduleGroup(yearMonthPair.first, yearMonthPair.second, schedules)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.neverland.domain.model.univ

data class RecentBookmarkSchedule(
val id: Int,
val title: String,
val startDate: String,
val endDate: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ package com.neverland.domain.repository

import com.neverland.domain.model.notice.BookmarkNotice
import com.neverland.domain.model.notice.RecentBookmarkNotice
import com.neverland.domain.model.univ.AcademicSchedule
import com.neverland.domain.model.univ.RecentBookmarkSchedule

interface BookmarkRepository {

suspend fun getNoticeBookmark(ssaId: String): Result<BookmarkNotice>

suspend fun getScheduleBookmark(ssaId: String): Result<List<AcademicSchedule>>

suspend fun getRecentNoticeBookmark(ssaId: String): Result<List<RecentBookmarkNotice>>

suspend fun getRecentScheduleBookmark(ssaId: String): Result<List<RecentBookmarkSchedule>>

suspend fun postNoticeBookmark(
category: String,
noticeId: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.neverland.domain.usecase.bookmark

import com.neverland.domain.model.univ.AcademicSchedule
import com.neverland.domain.repository.BookmarkRepository
import javax.inject.Inject

class GetBookmarkScheduleUseCase @Inject constructor(
private val repository: BookmarkRepository
) {
suspend operator fun invoke(ssaId: String): Result<List<AcademicSchedule>> {
return repository.getScheduleBookmark(ssaId)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.neverland.domain.usecase.bookmark

import com.neverland.domain.model.univ.RecentBookmarkSchedule
import com.neverland.domain.repository.BookmarkRepository
import javax.inject.Inject

class GetRecentBookmarkScheduleUseCase @Inject constructor(
private val repository: BookmarkRepository
) {
suspend operator fun invoke(ssaId: String): Result<List<RecentBookmarkSchedule>> {
return repository.getRecentScheduleBookmark(ssaId)
}
}
2 changes: 1 addition & 1 deletion ThinkerBell/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
activityKtx = "1.9.1"
agp = "8.4.0"
agp = "8.4.2"
datastorePreferences = "1.1.1"
flowLayout = "1.3.3"
fragmentKtx = "1.8.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.neverland.thinkerbell.utils.UiState
import com.neverland.thinkerbell.view.HomeActivity
import com.neverland.thinkerbell.view.alarm.adapter.AlarmVPAdapter
import com.neverland.thinkerbell.view.home.HomeFragment
import com.neverland.thinkerbell.view.myPage.KeywordManageFragment
import com.neverland.thinkerbell.view.setting.KeywordManageFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ class AlarmNoticeFragment : BaseFragment<FragmentAlarmNoticeBinding>() {
// Show loading state if needed
}
is UiState.Success -> {
LoggerUtil.d(state.data.size.toString())
noticeAdapter.submitList(state.data)
if (state.data.isNotEmpty()) {
noticeAdapter.submitList(state.data)
}
else {
binding.tvEmptyAlarm.visibility = View.VISIBLE
}
}
is UiState.Error -> {
// Handle error state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class CalendarScheduleAdapter : RecyclerView.Adapter<CalendarScheduleAdapter.Sch
inner class ScheduleViewHolder(private val binding: ItemCalendarScheduleBinding) : RecyclerView.ViewHolder(binding.root) {

fun bind(item: AcademicSchedule){
binding.tvScheduleDate.text = item.startDate
val date = if (item.startDate == item.endDate) item.startDate.removeRange(0,5).replace("-",".")
else "${item.startDate.removeRange(0,5).replace("-",".")} ~ ${item.endDate.removeRange(0,5).replace("-",".")}"
binding.tvScheduleDate.text = date
binding.tvScheduleTitle.text = item.title

binding.btnFavorite.isChecked = item.marked
Expand Down

This file was deleted.

Loading

0 comments on commit 4e1aad6

Please sign in to comment.