//
|
// EnterpriseViewModel.swift
|
// OKProject
|
//
|
// Created by 无故事王国 on 2023/5/22.
|
// Copyright © 2023 yangwang. All rights reserved.
|
//
|
|
import Foundation
|
import RxSwift
|
import RxCocoa
|
|
class EnterpriseViewModel:YYViewModel{
|
func queryEnterpriseInfo(_ clouse:@escaping (ResponseStatus<EnterpriseInfoModel>)->Void){
|
show()
|
APIManager.shared.provider.rx.request(.queryCompany).mapTravelThenValidate(EnterpriseInfoModel.self).subscribe { result in
|
self.hidden()
|
switch result {
|
case .success(let element):
|
clouse(ResponseStatus.success(element!))
|
case .failure(let e):
|
clouse(ResponseStatus.error(e))
|
}
|
} onError: { error in
|
self.hidden()
|
clouse(ResponseStatus.error(error))
|
}.disposed(by: disposeBag)
|
}
|
|
func submitEnterprise(id:Int? = nil,name:String,mailbox:String,legalName:String,legalPhone:String,identifier:String,contactAddress:String,businessLicense:String,clouse: @escaping (ResponseStatus<Nothing>)->Void){
|
show()
|
APIManager.shared.provider.rx.request(.submitCompany(name: name, mailbox: mailbox, legalName: legalName, legalPhone: legalPhone, identifier: identifier, contactAddress: contactAddress, businessLicense: businessLicense)).mapTravelThenValidate(Nothing.self).subscribe { result in
|
self.hidden()
|
switch result {
|
case .success(_):
|
clouse(ResponseStatus.success(nil))
|
case .failure(let e):
|
clouse(ResponseStatus.error(e))
|
}
|
} onError: { error in
|
self.hidden()
|
clouse(ResponseStatus.error(error))
|
}.disposed(by: disposeBag)
|
}
|
|
func saveCompanyLimit(applyQuota:String,applyReason:String,clouse: @escaping (ResponseStatus<Nothing>)->Void){
|
show()
|
APIManager.shared.provider.rx.request(.saveCompanyLimit(applyQuota: applyQuota, applyReason: applyReason)).mapTravelThenValidate(Nothing.self).subscribe { result in
|
self.hidden()
|
switch result {
|
case .success(_):
|
clouse(ResponseStatus.success(nil))
|
case .failure(let e):
|
clouse(ResponseStatus.error(e))
|
}
|
} onError: { error in
|
self.hidden()
|
clouse(ResponseStatus.error(error))
|
}.disposed(by: disposeBag)
|
}
|
|
func getCompanyLimitDetail(id:Int,clouse: @escaping (ResponseStatus<LinesModel>)->Void){
|
show()
|
APIManager.shared.provider.rx.request(.getCompanyLimitDetail(id: id)).mapTravelThenValidate(LinesModel.self).subscribe { result in
|
self.hidden()
|
switch result {
|
case .success(let m):
|
clouse(ResponseStatus.success(m))
|
case .failure(let e):
|
clouse(ResponseStatus.error(e))
|
}
|
} onError: { error in
|
self.hidden()
|
clouse(ResponseStatus.error(error))
|
}.disposed(by: disposeBag)
|
}
|
|
/// 额度审核
|
/// - Parameters:
|
/// - id: id
|
/// - remark: 拒绝备注
|
/// - status: 审核状态(1审核通过 2审核拒绝)
|
func companyLimitApprove(id:Int,remark:String? = nil,status:Int,clouse: @escaping (ResponseStatus<Nothing>)->Void){
|
show()
|
APIManager.shared.provider.rx.request(.companyLimitApprove(id: id, remark: remark, status: status)).mapTravelThenValidate(Nothing.self).subscribe { result in
|
self.hidden()
|
switch result {
|
case .success(_):
|
clouse(ResponseStatus.success(nil))
|
case .failure(let e):
|
clouse(ResponseStatus.error(e))
|
}
|
} onError: { error in
|
self.hidden()
|
clouse(ResponseStatus.error(error))
|
}.disposed(by: disposeBag)
|
}
|
}
|