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

드랍유도 컨텐츠 수정 작업 #299

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions StreetDrop/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PODS:
- GoogleUserMessagingPlatform (>= 1.1)
- GoogleUserMessagingPlatform (2.1.0)
- NMapsGeometry (1.0.1)
- NMapsMap (3.16.2):
- NMapsMap (3.18.0):
- NMapsGeometry

DEPENDENCIES:
Expand All @@ -21,7 +21,7 @@ SPEC CHECKSUMS:
Google-Mobile-Ads-SDK: 7a466427864972f5229f1f89d004b998a28ddcae
GoogleUserMessagingPlatform: dce302b8f1b84d6e945812ee7a15c3f65a102cbf
NMapsGeometry: 53c573ead66466681cf123f99f698dc8071a4b83
NMapsMap: aaa64717249b06ae82c3a3addb3a01f0e33100ab
NMapsMap: 36dc18a1f5f315121b33fccd2398c7a702bf0fc8

PODFILE CHECKSUM: c1edcf3d49503875acf5f6e7bfd364191c925046

Expand Down
76 changes: 64 additions & 12 deletions StreetDrop/StreetDrop.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ protocol MyInfoStorage {
func saveLauchedBefore(_ launchedBefore: Bool)
func fetchLastSeenNoticeId() -> Int?
func saveLastSeenNoticeId(_ noticeId: Int)
func fetchLastLaunchDate() -> Date?
func saveLastLaunchDate(_ lastLaunchDate: Date)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protocol RecentMusicQueriesStorage {
query: RecentMusicQueryDTO,
completion: @escaping (Result<RecentMusicQueryDTO, Error>) -> Void
)
func deleteRecentQuery(query: RecentMusicQueryDTO) async
}

protocol RecommendMusicQueriesStorage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ extension UserDefaultsMyInfoStorage: MyInfoStorage {
func saveLastSeenNoticeId(_ noticeId: Int) {
userDefaults.set(noticeId, forKey: UserDefaultKey.lastSeenNoticeId)
}

func fetchLastLaunchDate() -> Date? {
userDefaults.object(forKey: UserDefaultKey.lastLaunchDate) as? Date
}

func saveLastLaunchDate(_ lastLaunchDate: Date) {
userDefaults.set(lastLaunchDate, forKey: UserDefaultKey.lastLaunchDate)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ extension UserDefaultsRecentMusicQueriesStorage: RecentMusicQueriesStorage {
completion(.success(query))
}
}

func deleteRecentQuery(query: RecentMusicQueryDTO) async {
var queries = self.fetchRecentMusicQueries().list
self.cleanUpQueries(for: query, in: &queries)
self.persist(recentMusicQueries: queries)
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ final class DefaultMyInfoRepository: MyInfoRepository {
return Double(dto.distance)
}
}

func checkFirstLaunchToday() -> Bool {
let lastLaunchDate = myInfoStorage.fetchLastLaunchDate()
myInfoStorage.saveLastLaunchDate(Date())

if let lastLaunchDate {
return !Calendar.current.isDateInToday(lastLaunchDate)
} else {
return true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ protocol MyInfoRepository {
func fetchMyMusicAppFromStorage() -> String?
func checkLaunchedBefore() -> Bool
func fetchUserCircleRadius() -> Single<Double>
func checkFirstLaunchToday() -> Bool
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// RecommendMusicRepository.swift
// StreetDrop
//
// Created by jihye kim on 07/08/2024.
//

import Foundation

import RxSwift

protocol RecommendMusicRepository {
func fetchPromptOfTheDay() -> Single<String?>
func fetchRecommendSectionList() -> Single<[RecommendSectionDTO]>
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ protocol SearchingMusicRepository {
func fetchRecommendMusicQueries() -> Single<RecommendMusic>
func fetchRecentMusicQueries() -> Single<[String]>
func fetchVillageName(latitude: Double, longitude: Double) -> Single<String>
func deleteRecentMusicQueries(keyword: String) async
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// DefaultRecommendMusicRepository.swift
// StreetDrop
//
// Created by jihye kim on 07/08/2024.
//

import Foundation

import Moya
import RxSwift

final class DefaultRecommendMusicRepository: RecommendMusicRepository {
private let networkManager: NetworkManager

init(
networkManager: NetworkManager = NetworkManager(
provider: MoyaProvider<MultiTarget>()
)
) {
self.networkManager = networkManager
}

func fetchRecommendSectionList() -> Single<[RecommendSectionDTO]> {
return networkManager.request(
target: .init(NetworkService.getRecommendList),
responseType: RecommendSectionResponse.self
)
.map { $0.data }
}

func fetchPromptOfTheDay() -> Single<String?> {
return networkManager.request(
target: .init(NetworkService.getPromptOfTheDay),
responseType: PromptOfTheDayResponse.self
)
.map { $0.sentence }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ final class DefaultSearchingMusicRepository: SearchingMusicRepository {
responseType: String.self
)
}

func deleteRecentMusicQueries(keyword: String) async {
await self.recentMusicQueriesPersistentStorage.deleteRecentQuery(
query: RecentMusicQueryDTO(query: keyword)
)
}
}
2 changes: 1 addition & 1 deletion StreetDrop/StreetDrop/Domain/Entity/Music.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

struct Music {
struct Music: Hashable {
let albumName: String
let artistName: String
let songName: String
Expand Down
103 changes: 103 additions & 0 deletions StreetDrop/StreetDrop/Domain/Entity/RecommendSection.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// RecommendSection.swift
// StreetDrop
//
// Created by jihye kim on 26/10/2024.
//

struct RecommendSectionResponse: Decodable {
let data: [RecommendSectionDTO]
}

struct PromptOfTheDayResponse: Decodable {
let sentence: String?
}

struct RecommendSectionDTO: Decodable {
// Header
let title: String
let description: String?

// Content
let type: ContentType
let content: Content

enum ContentType: String, Decodable {
case basic
case keyword

init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let rawValue = try container.decode(String.self)
self = ContentType(rawValue: rawValue.lowercased()) ?? .basic
}
}

struct Content: Decodable {
let basic: [MusicContent]?
let keyword: [KeywordContent]?
}

struct MusicContent: Decodable {
let albumName: String
let artistName: String
let songName: String
let durationTime: String
let albumImage: String
let albumThumbnailImage: String
let genre: [String]
}

struct KeywordContent: Decodable {
let artistName: String
let albumImage: String
let albumThumbnailImage: String
}
}

// MARK: Conversion

extension RecommendSectionDTO {
typealias HeaderInfo = RecommendMusicSectionModel.Header
typealias Item = RecommendMusicSectionModel.Item

var sectionModel: RecommendMusicSectionModel? {
switch type {
case .basic:
guard let basic = content.basic else { return nil }
let musicList = basic.map { basicContent in
Music(
albumName: basicContent.albumName,
artistName: basicContent.artistName,
songName: basicContent.songName,
durationTime: basicContent.durationTime,
albumImage: basicContent.albumImage,
albumThumbnailImage: basicContent.albumThumbnailImage,
genre: basicContent.genre
)
}
return .init(
type: .basic(.init(title: title, info: description), musicList),
items: musicList.map { Item.basic($0) }
)
case .keyword:
guard let keyword = content.keyword else { return nil }
return .init(
type: .keyword(.init(title: title, info: description)),
items: keyword.map { keywordContent in
Item.keyword(
.init(
text: keywordContent.artistName,
image: keywordContent.albumThumbnailImage
)
)
}
)
}
}
}

struct SearchKeywordEntity: Hashable {
let text: String
let image: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ final class DefaultMyInfoUseCase: MyInfoUseCase {
func checkLaunchedBefore() -> Bool {
return myInfoRepository.checkLaunchedBefore()
}

func checkFirstLaunchToday() -> Bool {
return myInfoRepository.checkFirstLaunchToday()
}
}
1 change: 1 addition & 0 deletions StreetDrop/StreetDrop/Domain/UseCase/MyInfoUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ protocol MyInfoUseCase {
func fetchMyInfo() -> Single<MyInfo>
func saveMyInfo(_ myInfo: MyInfo) -> Single<Void>
func checkLaunchedBefore() -> Bool
func checkFirstLaunchToday() -> Bool
}
31 changes: 31 additions & 0 deletions StreetDrop/StreetDrop/Domain/UseCase/RecommendMusicUsecase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// RecommendMusicUsecase.swift
// StreetDrop
//
// Created by jihye kim on 07/08/2024.
//

import Foundation

import RxSwift

protocol RecommendMusicUsecase {
func getPromptOfTheDay() -> Single<String?>
func getRecommendSections() -> Single<[RecommendSectionDTO]>
}

final class DefaultRecommendMusicUsecase: RecommendMusicUsecase {
private let recommendMusicRepository: RecommendMusicRepository

init(recommendMusicRepository: RecommendMusicRepository = DefaultRecommendMusicRepository()) {
self.recommendMusicRepository = recommendMusicRepository
}

func getPromptOfTheDay() -> Single<String?> {
recommendMusicRepository.fetchPromptOfTheDay()
}

func getRecommendSections() -> Single<[RecommendSectionDTO]> {
recommendMusicRepository.fetchRecommendSectionList()
}
}
5 changes: 5 additions & 0 deletions StreetDrop/StreetDrop/Domain/UseCase/SearchMusicUsecase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ protocol SearchMusicUsecase {
func getRecentSearches() -> Single<[String]>
func getVillageName(latitude: Double, longitude: Double) -> Single<String>
func fetchRecommendSearch() -> Single<RecommendMusic>
func deleteRecentSearch(keyword: String) async
}

final class DefaultSearchingMusicUsecase: SearchMusicUsecase {
Expand Down Expand Up @@ -44,4 +45,8 @@ final class DefaultSearchingMusicUsecase: SearchMusicUsecase {
func fetchRecommendSearch() -> Single<RecommendMusic> {
return self.searchingMusicRepository.fetchRecommendMusicQueries()
}

func deleteRecentSearch(keyword: String) async {
await self.searchingMusicRepository.deleteRecentMusicQueries(keyword: keyword)
}
}
13 changes: 11 additions & 2 deletions StreetDrop/StreetDrop/Network/NetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ enum NetworkService {
case getNoticeList
case getNoticeDetail(id: Int)
case checkNewNotice(lastNoticeId: Int?)
case getRecommendList
case getPromptOfTheDay
}

extension NetworkService: TargetType {
Expand Down Expand Up @@ -119,6 +121,10 @@ extension NetworkService: TargetType {
return "/notices/\(id)"
case .checkNewNotice:
return "/notices/new"
case .getRecommendList:
return "/v2/search-term/recommend"
case .getPromptOfTheDay:
return "/post-recommend/random-sentence"
}
}

Expand All @@ -142,7 +148,9 @@ extension NetworkService: TargetType {
.getPopUpInfomation,
.getNoticeList,
.getNoticeDetail,
.checkNewNotice:
.checkNewNotice,
.getRecommendList,
.getPromptOfTheDay:
return .get
case .dropMusic,
.postLikeUp,
Expand All @@ -162,7 +170,8 @@ extension NetworkService: TargetType {
var task: Moya.Task {
switch self {
case .getMyInfo, .myDropList, .myLikeList, .myLevel, .myLevelProgress, .levelPolicy, .recommendMusic, .userCircleRadius, .getPopUpInfomation,
.getNoticeList, .getNoticeDetail:
.getNoticeList, .getNoticeDetail, .getRecommendList,
.getPromptOfTheDay:
return .requestPlain
case .searchMusic(let keyword):
return .requestParameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ private extension EditCommentViewController {
//MARK: - UI

func configureUI() {
self.cancelButton.setTitle(Constant.empty, for: .normal)
self.dropButton.setTitle(Constant.editButtonDisabledTitle, for: .disabled)
self.dropButton.setTitle(Constant.editButtonNormalTitle, for: .normal)
self.backButton.setTitle(Constant.empty, for: .normal)
self.locationLabel.isHidden = true
self.cancelButton.setTitle(Constant.empty, for: .normal)

self.topView.addSubview(titleLabel)
titleLabel.snp.makeConstraints {
Expand Down
Loading