分类购物车model

xiaoxiao2025-10-18  6

api

package dongyushan.bwie.com.lianxi.model; import dongyushan.bwie.com.lianxi.bean.CarBean; import dongyushan.bwie.com.lianxi.bean.FenBean; import dongyushan.bwie.com.lianxi.bean.HomeBean; import dongyushan.bwie.com.lianxi.bean.SouBean; import dongyushan.bwie.com.lianxi.bean.XiangQingBean; import io.reactivex.Observable; import retrofit2.http.Field; import retrofit2.http.GET; import retrofit2.http.Query; public interface Api { @GET("home/getHome") Observable<HomeBean> shouye(); @GET("product/getProductCatagory") Observable<FenBean> fenlei(@Query("cid") String cid); //product/searchProducts @GET("product/searchProducts") Observable<SouBean> sousuo(@Query("keywords") String name,@Query("page" )int page); //product/getProductDetail @GET("product/getProductDetail") Observable<XiangQingBean> xiangqing(@Query("pid") int pid); @GET("product/getCarts") Observable<CarBean> gouwuche(@Query("uid") int uid); }

 

 

con

package dongyushan.bwie.com.lianxi.model; public class Constant { public static final String BASE_URL="http://www.zhaoapi.cn/"; }

 

 

httputils

package dongyushan.bwie.com.lianxi.model; import java.io.IOException; import okhttp3.Interceptor; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import retrofit2.Retrofit; import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import retrofit2.converter.gson.GsonConverterFactory; public class HttpUtils { public final Api apiClient; private HttpUtils() { OkHttpClient okHttpClient = new OkHttpClient.Builder() .addNetworkInterceptor(new LoggingIntercepter()) .build(); Retrofit retrofit = new Retrofit.Builder().baseUrl(Constant.BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .client(okHttpClient) .build(); apiClient = retrofit.create(Api.class); } class LoggingIntercepter implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request request=chain.request(); long t1=System.nanoTime(); Response response=chain.proceed(request); long t2=System.nanoTime(); return response; } } private static class GetHttpUtilsInstance{ private static HttpUtils httpUtils=new HttpUtils(); } public static HttpUtils getHttpUtilsInstance() { return GetHttpUtilsInstance.httpUtils; } }

 

 

 

转载请注明原文地址: https://www.6miu.com/read-5038120.html

最新回复(0)