handyjson加另外的参数-不定的参数

定义

  • 具体查看项目的代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    @discardableResult
    public func lw_api_getVehicleList(par:lw_request_getVehicleList,otherParam:Dictionary<String, Any>,resultCallBack:@escaping BaseRequestParam.Block) -> URLSessionDataTask!
    {
    let url = "vehiclAdmin/getVehicleList";
    let sessionDataTask = BaseRequest.request(url: url, data: par, otherParam: otherParam) { (isOK, error, data:BaseResponse<lw_mode_getVehicleList>?) in
    resultCallBack(isOK, error, data?.data)
    }
    return sessionDataTask
    }




    @discardableResult
    public static func request<T:PotBaseResponse>(
    url: String,
    data: BaseSignParam,
    otherParam:Dictionary<String, Any>,
    callback:@escaping (Bool, BaseException?, T?)->Void)
    -> URLSessionDataTask
    {
    return BaseRequest.post(
    url: url,
    data: data,
    image: nil,
    otherParam:otherParam,
    imageFormName: "",
    compress: 0,
    usingRequestSerializer:AFHTTPRequestSerializer()){
    (o:Bool, e:BaseException?, d:T?,r:Any?)->Void in
    callback(o,e,d);
    }
    }

使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
func requePerson() {
let r = lw_request_getVehicleList()
r.keyWord = keyWorld

var dict = Dictionary<String, Any>()
if isAllPerson {

dict["companyId"] = String(MXHHandleLoginData.userData.companyId)
}else{
dict["orgId"] = orgId
}

ProgressHUD.show()
ApiMine().lw_api_getVehicleList(par: r, otherParam: dict) { [weak self](isOK, error, data) in
ProgressHUD.dismiss()

if isOK,(data != nil) {
let response = data as! lw_mode_getVehicleList
self?.searchPersonArray = response.userList
self?.tableView.reloadData()
}else{
MarXToolsToast().lws_toasterTopDefaultTime(msg: error?.description ?? "服务器异常")
}
}

}