jsdw_ios/QuickLocation/Service/ItineraryService.swift

89 lines
3.0 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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
}
}
/// 查询圈子行程列表
static func groupScheduleList(groupKey: String) -> Observable<groupScheduleListResponse> {
let api = ItineraryAPI.query(follow: false,
own: false,
history: false,
group_key: groupKey,
page: -1).multiTarget
return APIProvider.request(token: api)
.map(groupScheduleListResponse.self)
.asObservable()
}
/// 查询行程关注人
/// - 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()
}
}