Quellcode durchsuchen

修改我的反馈接口问题

Pq vor 3 Jahren
Ursprung
Commit
0004fe4e1d

+ 2 - 1
student/src/main/java/com/cooleshow/student/api/APIService.java

@@ -443,8 +443,9 @@ public interface APIService {
      * @param body
      * @return
      */
+    @FormUrlEncoded
     @POST(STUDENT_GROUP + "sysSuggestion/add")
-    Observable<BaseResponse<Object>> addSuggestion(@Body RequestBody body);
+    Observable<BaseResponse<Object>> addSuggestion(@FieldMap Map<String, String> params);
 
     /**
      * 文件下载

+ 4 - 2
student/src/main/java/com/cooleshow/student/presenter/mine/FeedBackPresenter.java

@@ -9,6 +9,8 @@ import com.cooleshow.base.utils.ErrorParse;
 import com.cooleshow.student.api.APIService;
 import com.cooleshow.student.contract.FeedBackContract;
 
+import java.util.Map;
+
 /**
  * 创建日期:2022/5/18 16:26
  *
@@ -16,9 +18,9 @@ import com.cooleshow.student.contract.FeedBackContract;
  * 类说明:
  */
 public class FeedBackPresenter extends BasePresenter<FeedBackContract.FeedBackView> implements FeedBackContract.Presenter {
-    public void addSuggestion(String jsonStr) {
+    public void addSuggestion(Map<String, String> params) {
         getView().showLoading();
-        addSubscribe(create(APIService.class).addSuggestion(RequestBodyUtil.convertToRequestBodyJson(jsonStr)), new BaseObserver<Object>(getView()) {
+        addSubscribe(create(APIService.class).addSuggestion(params), new BaseObserver<Object>(getView()) {
             @Override
             protected void onSuccess(Object data) {
                 if (getView() != null) {

+ 12 - 11
student/src/main/java/com/cooleshow/student/ui/mine/FeedBackActivity.java

@@ -18,6 +18,9 @@ import com.cooleshow.student.presenter.mine.FeedBackPresenter;
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import io.rong.imkit.utils.StatusBarUtil;
 
 /**
@@ -30,29 +33,27 @@ import io.rong.imkit.utils.StatusBarUtil;
 public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackBinding, FeedBackPresenter> implements FeedBackContract.FeedBackView, View.OnClickListener {
     @Override
     public void onClick(View view) {
-        switch (view.getId()){
+        switch (view.getId()) {
             case R.id.tv_submit:
                 String content = viewBinding.etContent.getText().toString().trim();
-                if (TextUtils.isEmpty(content)){
+                if (TextUtils.isEmpty(content)) {
                     ToastUtils.showShort("请输入您的反馈意见");
                     break;
                 }
                 String mobileNo = viewBinding.etConnect.getText().toString().trim();
-                if (TextUtils.isEmpty(mobileNo)){
+                if (TextUtils.isEmpty(mobileNo)) {
                     ToastUtils.showShort("请输入您的邮箱或手机号");
                     break;
                 }
-                JSONObject jsonObject = new JSONObject();
-                try {
-                    jsonObject.putOpt("content", content);
-                    jsonObject.putOpt("mobileNo", mobileNo);
-                } catch (JSONException e) {
-                    e.printStackTrace();
-                }
-                presenter.addSuggestion(jsonObject.toString());
+                Map<String, String> params = new HashMap<>();
+                params.put("clientType", "Android");
+                params.put("content", content);
+                params.put("mobileNo", mobileNo);
+                presenter.addSuggestion(params);
                 break;
         }
     }
+
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

+ 2 - 1
teacher/src/main/java/com/cooleshow/teacher/api/APIService.java

@@ -438,8 +438,9 @@ public interface APIService {
      * @param body
      * @return
      */
+    @FormUrlEncoded
     @POST(TEACHER_GROUP + "sysSuggestion/add")
-    Observable<BaseResponse<Object>> addSuggestion(@Body SysSuggestionEntry body);
+    Observable<BaseResponse<Object>> addSuggestion(@FieldMap Map<String, String> params);
 
     /**
      * 银行卡查询

+ 4 - 4
teacher/src/main/java/com/cooleshow/teacher/presenter/mine/FeedBackPresenter.java

@@ -10,6 +10,8 @@ import com.cooleshow.teacher.api.APIService;
 import com.cooleshow.teacher.bean.request.SysSuggestionEntry;
 import com.cooleshow.teacher.contract.FeedBackContract;
 
+import java.util.Map;
+
 /**
  * 创建日期:2022/5/18 16:26
  *
@@ -17,11 +19,9 @@ import com.cooleshow.teacher.contract.FeedBackContract;
  * 类说明:
  */
 public class FeedBackPresenter extends BasePresenter<FeedBackContract.FeedBackView> implements FeedBackContract.Presenter {
-    public void addSuggestion(String jsonStr) {
+    public void addSuggestion(Map<String, String> params) {
         getView().showLoading();
-        SysSuggestionEntry entry = new SysSuggestionEntry();
-        entry.content = jsonStr;
-        addSubscribe(create(APIService.class).addSuggestion(entry), new BaseObserver<Object>(getView()) {
+        addSubscribe(create(APIService.class).addSuggestion(params), new BaseObserver<Object>(getView()) {
             @Override
             protected void onSuccess(Object data) {
                 if (getView() != null) {

+ 7 - 1
teacher/src/main/java/com/cooleshow/teacher/ui/mine/FeedBackActivity.java

@@ -18,6 +18,9 @@ import com.cooleshow.teacher.presenter.mine.FeedBackPresenter;
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import io.rong.imkit.utils.StatusBarUtil;
 
 /**
@@ -42,7 +45,10 @@ public class FeedBackActivity extends BaseMVPActivity<ActivityFeedbackBinding, F
 //                    ToastUtils.showShort("请输入您的邮箱或手机号");
 //                    break;
 //                }
-                presenter.addSuggestion(content);
+                Map<String, String> params = new HashMap<>();
+                params.put("clientType", "Android");
+                params.put("content", content);
+                presenter.addSuggestion(params);
                 break;
         }
     }