From db95cdb81183d248353bc7d47d059af5849e6513 Mon Sep 17 00:00:00 2001 From: tanc <2512769611@qq.com> Date: Tue, 22 Oct 2024 21:02:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=90=8E=E7=AB=AF=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=BC=A0=E5=88=B0=E5=AE=89=E5=8D=93=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liyueling_final/AdvertisementApi.java | 2 +- .../com/example/liyueling_final/ChatApi.java | 2 +- .../example/liyueling_final/Class2Api.java | 2 +- .../com/example/liyueling_final/ClassApi.java | 2 +- .../example/liyueling_final/Expert1Api.java | 2 +- .../example/liyueling_final/Expert2Api.java | 2 +- .../example/liyueling_final/Goods1Api.java | 2 +- .../example/liyueling_final/Goods2Api.java | 2 +- .../example/liyueling_final/LoginUser.java | 28 +++++++++++++++++++ .../example/liyueling_final/LoginUserApi.java | 13 +++++++++ .../liyueling_final/MainexpertFragment.java | 8 ++++-- .../liyueling_final/MaingoodFragment.java | 4 +-- .../liyueling_final/MainhomeFragment.java | 4 +-- .../liyueling_final/MainmajorFragment.java | 4 +-- .../example/liyueling_final/PeopleApi.java | 2 +- .../liyueling_final/Study_pinglun.java | 2 +- .../com/example/liyueling_final/UserApi.java | 2 +- .../example/liyueling_final/UserFragment.java | 8 +++--- 新建 文本文档.txt | 0 19 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/example/liyueling_final/LoginUser.java create mode 100644 src/main/java/com/example/liyueling_final/LoginUserApi.java delete mode 100644 新建 文本文档.txt diff --git a/src/main/java/com/example/liyueling_final/AdvertisementApi.java b/src/main/java/com/example/liyueling_final/AdvertisementApi.java index 7cb6f6b..51c7d5c 100644 --- a/src/main/java/com/example/liyueling_final/AdvertisementApi.java +++ b/src/main/java/com/example/liyueling_final/AdvertisementApi.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface AdvertisementApi { @FormUrlEncoded - @POST("advertise") + @POST("advertise/getAdvertiseList") Call advertise (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/ChatApi.java b/src/main/java/com/example/liyueling_final/ChatApi.java index 1747ced..b9cfd74 100644 --- a/src/main/java/com/example/liyueling_final/ChatApi.java +++ b/src/main/java/com/example/liyueling_final/ChatApi.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface ChatApi { @FormUrlEncoded - @POST("chat") + @POST("chat/getChatList") Call chat (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/Class2Api.java b/src/main/java/com/example/liyueling_final/Class2Api.java index b50c2bc..fbe4e7f 100644 --- a/src/main/java/com/example/liyueling_final/Class2Api.java +++ b/src/main/java/com/example/liyueling_final/Class2Api.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface Class2Api { @FormUrlEncoded - @POST("Class2") + @POST("Class2/getClass2List") Call class2 (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/ClassApi.java b/src/main/java/com/example/liyueling_final/ClassApi.java index 0b9d832..2678f27 100644 --- a/src/main/java/com/example/liyueling_final/ClassApi.java +++ b/src/main/java/com/example/liyueling_final/ClassApi.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface ClassApi { @FormUrlEncoded - @POST("Class") + @POST("Class/getClassList") Call class1 (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/Expert1Api.java b/src/main/java/com/example/liyueling_final/Expert1Api.java index dd815f9..76701fb 100644 --- a/src/main/java/com/example/liyueling_final/Expert1Api.java +++ b/src/main/java/com/example/liyueling_final/Expert1Api.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface Expert1Api { @FormUrlEncoded - @POST("expert1") + @POST("expert1/getExpert1List") Call people (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/Expert2Api.java b/src/main/java/com/example/liyueling_final/Expert2Api.java index 653609e..1d2c1f1 100644 --- a/src/main/java/com/example/liyueling_final/Expert2Api.java +++ b/src/main/java/com/example/liyueling_final/Expert2Api.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface Expert2Api { @FormUrlEncoded - @POST("expert2") + @POST("expert2/getExpert2List") Call people2 (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/Goods1Api.java b/src/main/java/com/example/liyueling_final/Goods1Api.java index c21b577..1ad30d5 100644 --- a/src/main/java/com/example/liyueling_final/Goods1Api.java +++ b/src/main/java/com/example/liyueling_final/Goods1Api.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface Goods1Api { @FormUrlEncoded - @POST("goods1") + @POST("goods1/getGoods1List") Call good (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/Goods2Api.java b/src/main/java/com/example/liyueling_final/Goods2Api.java index ca0fb27..f90e12e 100644 --- a/src/main/java/com/example/liyueling_final/Goods2Api.java +++ b/src/main/java/com/example/liyueling_final/Goods2Api.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface Goods2Api { @FormUrlEncoded - @POST("goods2") + @POST("goods1/getGoods1List") Call good (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/LoginUser.java b/src/main/java/com/example/liyueling_final/LoginUser.java new file mode 100644 index 0000000..d79be5e --- /dev/null +++ b/src/main/java/com/example/liyueling_final/LoginUser.java @@ -0,0 +1,28 @@ +package com.example.liyueling_final; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class LoginUser { + + @SerializedName("msg") + public String msg; + @SerializedName("code") + public Integer code; + @SerializedName("data") + public List data; + + public static class DataDTO { + @SerializedName("id") + public Integer id; + @SerializedName("username") + public String username; + @SerializedName("password") + public String password; + @SerializedName("phone") + public String phone; + @SerializedName("userImg") + public String userImg; + } +} diff --git a/src/main/java/com/example/liyueling_final/LoginUserApi.java b/src/main/java/com/example/liyueling_final/LoginUserApi.java new file mode 100644 index 0000000..0a50bd4 --- /dev/null +++ b/src/main/java/com/example/liyueling_final/LoginUserApi.java @@ -0,0 +1,13 @@ +package com.example.liyueling_final; + +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.Field; +import retrofit2.http.FormUrlEncoded; +import retrofit2.http.POST; + +public interface LoginUserApi { + @FormUrlEncoded + @POST("login") + Call login(@Field("id") Integer id); +} diff --git a/src/main/java/com/example/liyueling_final/MainexpertFragment.java b/src/main/java/com/example/liyueling_final/MainexpertFragment.java index 60f4c36..4210ff7 100644 --- a/src/main/java/com/example/liyueling_final/MainexpertFragment.java +++ b/src/main/java/com/example/liyueling_final/MainexpertFragment.java @@ -81,13 +81,14 @@ public class MainexpertFragment extends Fragment { recyclerView3.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false)); - Expert1Api expert1Api = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(Expert1Api.class); - Expert2Api expert2Api = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(Expert2Api.class); + Expert1Api expert1Api = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(Expert1Api.class); + Expert2Api expert2Api = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(Expert2Api.class); Call call = expert1Api.people(0); Log.i("123456", "onFailure: "); call.enqueue(new Callback() { @Override public void onResponse(Call call, Response response) { + Log.i("ui123456", "onFailure: "); Expert1 expert1 = response.body(); for (Expert1.DataDTO data : expert1.data) { if (data.id < 7) { @@ -99,9 +100,10 @@ public class MainexpertFragment extends Fragment { myAdpater.notifyDataSetChanged(); } + @Override public void onFailure(Call call, Throwable t) { - + Log.i("data", "Request failed: " + t.getMessage()); } }); recyclerView = view.findViewById(R.id.recyclerview1); diff --git a/src/main/java/com/example/liyueling_final/MaingoodFragment.java b/src/main/java/com/example/liyueling_final/MaingoodFragment.java index 0f61e22..ad2a7a5 100644 --- a/src/main/java/com/example/liyueling_final/MaingoodFragment.java +++ b/src/main/java/com/example/liyueling_final/MaingoodFragment.java @@ -66,8 +66,8 @@ public class MaingoodFragment extends Fragment { recyclerView3.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false)); - Goods1Api goods1Api = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(Goods1Api.class); - Goods2Api goods2Api = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(Goods2Api.class); + Goods1Api goods1Api = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(Goods1Api.class); + Goods2Api goods2Api = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(Goods2Api.class); Call call = goods1Api.good(0); Log.i("123456", "onFailure: "); call.enqueue(new Callback() { diff --git a/src/main/java/com/example/liyueling_final/MainhomeFragment.java b/src/main/java/com/example/liyueling_final/MainhomeFragment.java index a64b3e8..3bf392e 100644 --- a/src/main/java/com/example/liyueling_final/MainhomeFragment.java +++ b/src/main/java/com/example/liyueling_final/MainhomeFragment.java @@ -95,7 +95,7 @@ public class MainhomeFragment extends Fragment { recyclerView4.setAdapter(myAdpater2); recyclerView4.setLayoutManager(new LinearLayoutManager(getActivity())); // Inflate the layout for this fragment - ClassApi classApi = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(ClassApi.class); + ClassApi classApi = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(ClassApi.class); Call call = classApi.class1(0); Log.i("123456", "onFailure: "); call.enqueue(new Callback() { @@ -125,7 +125,7 @@ public class MainhomeFragment extends Fragment { } }); - Class2Api class2Api = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(Class2Api.class); + Class2Api class2Api = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(Class2Api.class); Call call2 = class2Api.class2(0); Log.i("123456", "onFailure: "); call2.enqueue(new Callback() { diff --git a/src/main/java/com/example/liyueling_final/MainmajorFragment.java b/src/main/java/com/example/liyueling_final/MainmajorFragment.java index a9cff07..9875a6d 100644 --- a/src/main/java/com/example/liyueling_final/MainmajorFragment.java +++ b/src/main/java/com/example/liyueling_final/MainmajorFragment.java @@ -39,7 +39,7 @@ public class MainmajorFragment extends Fragment { Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_mainmajor, container, false); - PeopleApi peopleApi = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(PeopleApi.class); + PeopleApi peopleApi = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(PeopleApi.class); Call call = peopleApi.Introduce(0); Log.i("123456", "onFailure: "); call.enqueue(new Callback() { @@ -59,7 +59,7 @@ public class MainmajorFragment extends Fragment { } }); - AdvertisementApi advertisementApi = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(AdvertisementApi.class); + AdvertisementApi advertisementApi = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(AdvertisementApi.class); Call call2 = advertisementApi.advertise(0); Log.i("123456", "onFailure: "); call2.enqueue(new Callback() { diff --git a/src/main/java/com/example/liyueling_final/PeopleApi.java b/src/main/java/com/example/liyueling_final/PeopleApi.java index 566b3b5..fa26432 100644 --- a/src/main/java/com/example/liyueling_final/PeopleApi.java +++ b/src/main/java/com/example/liyueling_final/PeopleApi.java @@ -7,6 +7,6 @@ import retrofit2.http.POST; public interface PeopleApi { @FormUrlEncoded - @POST("people") + @POST("people/getPeopleList") Call Introduce (@Field("id") Integer id); } diff --git a/src/main/java/com/example/liyueling_final/Study_pinglun.java b/src/main/java/com/example/liyueling_final/Study_pinglun.java index 1becff3..1e445fd 100644 --- a/src/main/java/com/example/liyueling_final/Study_pinglun.java +++ b/src/main/java/com/example/liyueling_final/Study_pinglun.java @@ -60,7 +60,7 @@ public class Study_pinglun extends Fragment { } }); - UserApi userApi = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(UserApi.class); + UserApi userApi = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(UserApi.class); for(int i=1;i<8;i++){ Call call = userApi.Comment(i); call.enqueue(new Callback() { diff --git a/src/main/java/com/example/liyueling_final/UserApi.java b/src/main/java/com/example/liyueling_final/UserApi.java index c6e5e25..572b811 100644 --- a/src/main/java/com/example/liyueling_final/UserApi.java +++ b/src/main/java/com/example/liyueling_final/UserApi.java @@ -7,7 +7,7 @@ import retrofit2.http.POST; public interface UserApi { @FormUrlEncoded - @POST("comment") + @POST("comment/getCommentList") Call Comment (@Field("id") Integer id); diff --git a/src/main/java/com/example/liyueling_final/UserFragment.java b/src/main/java/com/example/liyueling_final/UserFragment.java index f64926c..425390c 100644 --- a/src/main/java/com/example/liyueling_final/UserFragment.java +++ b/src/main/java/com/example/liyueling_final/UserFragment.java @@ -83,8 +83,8 @@ public class UserFragment extends Fragment { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setMessage("Are you sure you want to logout?") - .setPositiveButton("Logout", new DialogInterface.OnClickListener() { + builder.setMessage("你确定你要退出吗?") + .setPositiveButton("退出", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // 执行退出登录操作 Intent intent = new Intent(getActivity(), LoginMainActivity.class); @@ -92,7 +92,7 @@ public class UserFragment extends Fragment { getActivity().finish(); } }) - .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + .setNegativeButton("取消", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // 取消操作,关闭对话框 dialog.dismiss(); @@ -163,7 +163,7 @@ public class UserFragment extends Fragment { } }); - ChatApi chatApi = RetrofitUtils.getRetrofit("https://dev.usemock.com/664ac0559e857b0cdafce629/").create(ChatApi.class); + ChatApi chatApi = RetrofitUtils.getRetrofit("http://10.0.2.2:8081/").create(ChatApi.class); Call call = chatApi.chat(0); call.enqueue(new Callback() { @Override diff --git a/新建 文本文档.txt b/新建 文本文档.txt deleted file mode 100644 index e69de29..0000000