Skip to content

Commit

Permalink
服务器到期了 将demo数据迁移到本地json
Browse files Browse the repository at this point in the history
  • Loading branch information
manondidi committed Jul 1, 2020
1 parent a0d36ce commit 733b3ca
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 717 deletions.
7 changes: 6 additions & 1 deletion Example/swiftArch/data/MockService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ class MockService{
return self.rxLoadJsonFromFile(fileName: "getUser.json" )
}

func rxGetGames()->Observable<NormalPageModel<GameModel>>{
return self.rxLoadJsonFromFile(fileName: "game.json" )
}

// 获取Feeds
func rxGetFeeds()->Observable<Result<Array<Feed>>> {
return self.rxLoadJsonFromFile(fileName: "feeds.json" )
}


func rxGetFeedArticles()->Observable<Result<Array<FeedArtileModel>>> {
return self.rxLoadJsonFromFile(fileName: "feed.json" )
}

func loadJsonFromFile<T:HandyJSON>(fileName:String) -> T {

Expand Down
31 changes: 18 additions & 13 deletions Example/swiftArch/data/SocialAppService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,32 @@ class SocialAppService {


func rxGetGame(pageNum: Int, pageSize: Int) -> Observable<NormalPageModel<GameModel>> {
return mockService.rxGetGames()

return httpClient.rxRequest(url: "archServer/games", method: .get, params: ["pageNum": "\(pageNum)", "pageSize": "\(pageSize)"])
.map { result -> NormalPageModel<GameModel> in
return try self.getData(result: result)!
}
// return httpClient.rxRequest(url: "archServer/games", method: .get, params: ["pageNum": "\(pageNum)", "pageSize": "\(pageSize)"])
// .map { result -> NormalPageModel<GameModel> in
// return try self.getData(result: result)!
// }

}



func rxGetFeedArticle(direction: String, pageSize: Int, offsetId: String?) -> Observable<Array<FeedArtileModel>> {

var dic = Dictionary<String, String>()
dic["pageSize"] = "\(pageSize)"
dic["direction"] = direction
dic["offsetId"] = offsetId

return httpClient.rxRequest(url: "archServer/feeds", method: .get, params: dic)
.map({ (result) -> Array<FeedArtileModel> in
return try self.getData(result: result)!
})
return mockService.rxGetFeedArticles()
.map({ (result) -> Array<FeedArtileModel> in
return try self.getData(result: result)!
})
// var dic = Dictionary<String, String>()
// dic["pageSize"] = "\(pageSize)"
// dic["direction"] = direction
// dic["offsetId"] = offsetId
//
// return httpClient.rxRequest(url: "archServer/feeds", method: .get, params: dic)
// .map({ (result) -> Array<FeedArtileModel> in
// return try self.getData(result: result)!
// })
}


Expand Down
7 changes: 5 additions & 2 deletions Example/swiftArch/data/jsonFile/feed.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[{
{
"status": 0,
"msg": "ok.",
"data": [{
"id": 170957,
"type": "create-article",
"payload": {
Expand Down Expand Up @@ -4156,4 +4159,4 @@
"followStatus": "unfollowed",
"isFireflyUser": true
}
}]
}]}
Loading

0 comments on commit 733b3ca

Please sign in to comment.