77 lines
2.5 KiB
Swift
77 lines
2.5 KiB
Swift
//
|
||
// ItineraryService.swift
|
||
// QuickLocation
|
||
//
|
||
// Created by 八条 on 2026/6/23.
|
||
//
|
||
|
||
import RxSwift
|
||
import Moya
|
||
|
||
struct ItineraryService {
|
||
static let disposeBag = DisposeBag()
|
||
|
||
/// 查询行程列表
|
||
/// - Parameters:
|
||
/// - follow: 只查看关注的行程
|
||
/// - own: 只查看自己创建的行程
|
||
/// - history: true查看历史行程,默认查看今天之后的行程
|
||
/// - group_key: 过滤圈子查询
|
||
static func query(follow: Bool=false,
|
||
own: Bool=false,
|
||
history: Bool=false,
|
||
group_key: String="") -> ListService<ScheduleListResponse> {
|
||
ListService(newPaging: true) {
|
||
ItineraryAPI.query(follow: follow,
|
||
own: own,
|
||
history: history,
|
||
group_key: group_key,
|
||
page: $0).multiTarget
|
||
}
|
||
}
|
||
|
||
/// 查询行程关注人
|
||
/// - Parameters:
|
||
/// - id: 行程ID
|
||
static func queryFollowList(id: String) -> Observable<ViewedListResponse> {
|
||
let api = ItineraryAPI.queryFollowList(id: id).multiTarget
|
||
return APIProvider.request(token: api)
|
||
.map(ViewedListResponse.self)
|
||
.asObservable()
|
||
}
|
||
|
||
/// 设置行程
|
||
/// - Parameters:
|
||
/// - id: 更新时传入
|
||
/// - group_keys: 只查看关注的行程
|
||
/// - timestamp: 行程日期
|
||
/// - points: 行程点
|
||
static func set(id: String="", group_keys: [String], timestamp: Int64, points: [[String: Any]]) -> Observable<ResponseModel> {
|
||
let api = ItineraryAPI.set(id: id, group_keys: group_keys, timestamp: timestamp, points: points).multiTarget
|
||
return APIProvider.request(token: api)
|
||
.map(ResponseModel.self)
|
||
.asObservable()
|
||
}
|
||
|
||
/// 删除
|
||
/// - Parameters:
|
||
/// - id: 行程ID
|
||
static func delete(id: String) -> Observable<ResponseModel> {
|
||
let api = ItineraryAPI.delete(id: id).multiTarget
|
||
return APIProvider.request(token: api)
|
||
.map(ResponseModel.self)
|
||
.asObservable()
|
||
}
|
||
|
||
/// 关注行程
|
||
/// - Parameters:
|
||
/// - id: 行程ID
|
||
/// - op: 1关注 2取消关注
|
||
static func follow(id: String, op: Int) -> Observable<ResponseModel> {
|
||
let api = ItineraryAPI.follow(id: id, op: op).multiTarget
|
||
return APIProvider.request(token: api)
|
||
.map(ResponseModel.self)
|
||
.asObservable()
|
||
}
|
||
}
|