Skip to content

Commit

Permalink
Merge pull request #158 from tukcomCD2024/feat/#157-ios-statistics
Browse files Browse the repository at this point in the history
Feat/#157 ios statistics
  • Loading branch information
realhsb authored Jun 20, 2024
2 parents 0c05871 + 1110c4a commit 4acbcab
Show file tree
Hide file tree
Showing 19 changed files with 376 additions and 216 deletions.
8 changes: 8 additions & 0 deletions iOS/RollTheDice/RollTheDice.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
6CC4DDCE2B5574690080E7E8 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6CC4DDCD2B5574690080E7E8 /* Preview Assets.xcassets */; };
6CC6737A2C217C4B009FB30E /* ScoopAPILogin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CC673792C217C4B009FB30E /* ScoopAPILogin.swift */; };
6CC6737C2C21BA5B009FB30E /* Auth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CC6737B2C21BA5B009FB30E /* Auth.swift */; };
6CC6737E2C233443009FB30E /* StatisticsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CC6737D2C233443009FB30E /* StatisticsService.swift */; };
6CC673802C233A65009FB30E /* ScoopAPIStatistics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CC6737F2C233A65009FB30E /* ScoopAPIStatistics.swift */; };
6CDB29C92BA97C550081037B /* Pretendard-Black.otf in Resources */ = {isa = PBXBuildFile; fileRef = 6CDB29C02BA97C550081037B /* Pretendard-Black.otf */; };
6CDB29CA2BA97C550081037B /* Pretendard-ExtraBold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 6CDB29C12BA97C550081037B /* Pretendard-ExtraBold.otf */; };
6CDB29CB2BA97C550081037B /* Pretendard-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 6CDB29C22BA97C550081037B /* Pretendard-Regular.otf */; };
Expand Down Expand Up @@ -162,6 +164,8 @@
6CC4DDCD2B5574690080E7E8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
6CC673792C217C4B009FB30E /* ScoopAPILogin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScoopAPILogin.swift; sourceTree = "<group>"; };
6CC6737B2C21BA5B009FB30E /* Auth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Auth.swift; sourceTree = "<group>"; };
6CC6737D2C233443009FB30E /* StatisticsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatisticsService.swift; sourceTree = "<group>"; };
6CC6737F2C233A65009FB30E /* ScoopAPIStatistics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScoopAPIStatistics.swift; sourceTree = "<group>"; };
6CDB29BF2BA9735C0081037B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
6CDB29C02BA97C550081037B /* Pretendard-Black.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-Black.otf"; sourceTree = "<group>"; };
6CDB29C12BA97C550081037B /* Pretendard-ExtraBold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pretendard-ExtraBold.otf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -635,6 +639,7 @@
6CF130B12BAB74BA00A437B6 /* NewsService.swift */,
6C5B0C8B2C1C32C000A0D5F4 /* BookmarksService.swift */,
357699432C09C7B900AD2DA4 /* LoginService.swift */,
6CC6737D2C233443009FB30E /* StatisticsService.swift */,
);
path = Service;
sourceTree = "<group>";
Expand Down Expand Up @@ -664,6 +669,7 @@
6CF130C62BAB7B9800A437B6 /* ScoopAPINews.swift */,
6C5B0C892C1C308A00A0D5F4 /* ScoopAPIBookmarks.swift */,
6CC673792C217C4B009FB30E /* ScoopAPILogin.swift */,
6CC6737F2C233A65009FB30E /* ScoopAPIStatistics.swift */,
);
path = ScoopAPI;
sourceTree = "<group>";
Expand Down Expand Up @@ -820,6 +826,7 @@
6CDB29FB2BAA07B10081037B /* GPTChatViewModel.swift in Sources */,
6C32379F2B7C376D00B699AB /* Bookmarks.swift in Sources */,
6C454A7E2B9DAA3F006FD9D0 /* SignUpFinishView.swift in Sources */,
6CC673802C233A65009FB30E /* ScoopAPIStatistics.swift in Sources */,
6C7704A12B722CEB001B17CB /* ProfileView.swift in Sources */,
6C4F7BAB2BDE50C600ED01DA /* DailyReportModel.swift in Sources */,
6C3237B72B7C434600B699AB /* ChatType.swift in Sources */,
Expand All @@ -832,6 +839,7 @@
6C41B8DA2BE104A800274FA4 /* RecentNewsCardView.swift in Sources */,
3509091A2C1C1248007D76A1 /* TokenManager.swift in Sources */,
6CF130C72BAB7B9800A437B6 /* ScoopAPINews.swift in Sources */,
6CC6737E2C233443009FB30E /* StatisticsService.swift in Sources */,
6C7651402BF37F3400196536 /* Log.swift in Sources */,
6CE1031A2BD57A2500498AA4 /* DebateSummaryView.swift in Sources */,
6CE1030C2BD56A4000498AA4 /* TypeReportView.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion iOS/RollTheDice/RollTheDice/RollTheDiceApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct RollTheDiceApp: App {
.environmentObject(signUpViewModel)
case .completedSignUp:
NavigationStack(path: $pathModel.paths) {
MainTabView(newsListViewModel: newsListViewModel)
MainTabView(newsListViewModel: newsListViewModel, bookmarksListViewModel: bookmarkListViewModel)
.navigationDestination(for: PathType.self, destination: { pathType in

// 각 뷰마다 .navigationBarBackButtonHidden() 설정하기!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ScoopAPIStatistics.swift
// RollTheDice
//
// Created by Subeen on 6/20/24.
//

import Foundation

public enum ScoopAPIStatistics {
// public static let statistics = String("/statistics")
public static let statisticsPerDates = String("/statistics/per-dates")
public static let statisticsCategories = String("/statistics/categories")

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum BookmarksService {
case bookmarksIsChecked(newsId: Int, accessToken: String) ///뉴스 북마크 여부 조회
case saveBookmarks(newsId: Int, accessToken: String) ///북마크 저장
case deleteBookmarks(newsId: Int, accessToken: String) ///북마크 삭제
case allBookmarks(page: Int, size: Int, accessToken: String) ///북마크 전체 조회/
case allBookmarks(page: Int, size: Int, accessToken: String) ///북마크 전체 조회
}

extension BookmarksService: BaseTargetType {
Expand Down Expand Up @@ -49,12 +49,14 @@ extension BookmarksService: BaseTargetType {

var task: Moya.Task {
switch self {
case .bookmarksIsChecked(let newsId, _),
.saveBookmarks(let newsId, _),
.deleteBookmarks(let newsId, _):
case .bookmarksIsChecked(_, _),
.deleteBookmarks(_, _):
let parameters : [String : Any] = [:]
return .requestParameters(parameters: parameters, encoding: URLEncoding.default)

case .saveBookmarks(_, _):
return .requestPlain

case .allBookmarks(let page, let size, _):
let parameters : [String : Any] = [
"page" : page,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// StatisticsService.swift
// RollTheDice
//
// Created by Subeen on 6/20/24.
//

import Foundation
import Moya

enum StatisticsService {
case recentSevenPerDate(accessToken: String) /// 최근 일주일 날짜별 뉴스 조회수 조회
case statisticsCategory(accessToken: String) /// 카테고리별 조회수 조회
}

extension StatisticsService: BaseTargetType {
var baseURL: URL {
return URL(string: ScoopAPI.baseURL)!
}

var path: String {
switch self {
case .recentSevenPerDate(let accessToken):
return ScoopAPIStatistics.statisticsPerDates

case .statisticsCategory(let accessToken):
return ScoopAPIStatistics.statisticsCategories
}
}

var method: Moya.Method {
switch self {
case .recentSevenPerDate,
.statisticsCategory:
return .get

}
}

var task: Moya.Task {
switch self {
case .recentSevenPerDate(_),
.statisticsCategory(_):

let parameters : [String : Any] = [ : ]
return .requestPlain
}
}

var headers: [String : String]? {
let accessToken: String

switch self {
case .recentSevenPerDate(let accessTokenValue),
.statisticsCategory(let accessTokenValue):
accessToken = accessTokenValue
return [
"Authorization": "Bearer \(accessToken)",
"X-Content-Type_Options" : "nosniff"
]
}
}
}
14 changes: 7 additions & 7 deletions iOS/RollTheDice/RollTheDice/Source/Model/Report/NewsType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import Foundation
import SwiftUI

enum NewsType {
case politics // 정치
case economy // 경제
case society // 사회
case living // 생활/문화
case world // 세계
case science // IT/과학
enum NewsType: String, Codable {
case politics = "정치" // 정치
case economy = "경제" // 경제
case society = "사회" // 사회
case living = "생활/문화" // 생활/문화
case world = "세계" // 세계
case science = "IT/과학" // IT/과학

var desciption: String {
switch self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

import SwiftUI

//let id = UUID().uuidString
//let newsId: Int
//let title, thumbnailURL, postDate: String
//let isBookmarked: Bool

struct BookmarkView: View {
@State var bookmark: Bookmarks
var body: some View {
Expand Down Expand Up @@ -73,9 +68,3 @@ struct BookmarkView: View {
}
}
}

//#Preview {
// BookmarkView(bookmark: .init(newsId: 0, title: "NHN, 작년 영업익 555억원...전년비 42% ↑", thumbnailURL: <#T##String#>, postDate: <#T##String#>, isBookmarked: <#T##Bool#>))
//
// BookmarkView(bookmark: .init(title: "NHN, 작년 영업익 555억원...전년비 42% ↑", date: "2023년2월13일", image: "https://cdnimage.dailian.co.kr/news/202402/news_1707866329_1327972_m_1.png", content: "2NHN은 연결기준 지난해 영업이익이 555억원으로 전년 대비 42.2% 증가했다고 14일 밝혔다.같은 기간 매출은 7.3% 증가한 2조2696억원으로 연간 최대치를 기록했다. 작년 4분기 매출은 5983억원으로 전년 동기 대비 6.7% 올랐다. 반면 영업손실은 78억원으로 적자전환했다. 커머스 부문의 장기 미회수채권 대손상각비 인식과 기술 부문의 기 인식 매출 차감 등 일회성 요인이 영향을 미쳤다.", isBookmarked: false))
//}
Loading

0 comments on commit 4acbcab

Please sign in to comment.