public AddVisitorResModel addVisitor(String baseUrl, File file, AddVisitorReqModel uploadJson) throws IOException {
Retrofit retrofit = createRetrofit(baseUrl);
HttpService httpService = retrofit.create(HttpService.class);
MultipartBody.Builder builder = new MultipartBody.Builder();
builder.addFormDataPart("PeoName", uploadJson.getPeoName());
builder.addFormDataPart("PeoCardNum", uploadJson.getPeoCardNum());
builder.addFormDataPart("PeoSex", uploadJson.getPeoSex());
RequestBody requestBody = RequestBody.create(MediaType.parse("image/jpg"), file);
builder.addFormDataPart("file", file.getName(), requestBody);
builder.setType(MultipartBody.FORM);
MultipartBody multipartBody = builder.build();
Call<AddVisitorResModel> call = httpService.addVisitor(multipartBody);
Log.i(TAG, "call:" + call);
Response<AddVisitorResModel> repo = call.execute();
Log.i(TAG, "repo:" + repo);
if (repo == null || repo.body() == null) {
return null;
}
return repo.body();
}
@POST(URL_ADD_VISITOR)
Call<AddVisitorResModel> addVisitor(@Body MultipartBody multipartBody);