Browse Source

[공통][Bug] 회원/비회원 구분, 완전 비회원과 비정상 회원 구분하여 결과 리턴

hyodong.min 6 years ago
parent
commit
db29d24415

+ 77 - 9
app/src/main/java/kr/co/zumo/app/lifeplus/network/api/LifeplusAPIRepository.java

@@ -3,6 +3,8 @@
  */
 package kr.co.zumo.app.lifeplus.network.api;
 
+import java.util.ArrayList;
+
 import io.reactivex.Single;
 import kr.co.zumo.app.lifeplus.bean.api.AuthConfirmRequestBean;
 import kr.co.zumo.app.lifeplus.bean.api.AuthNumberRequestBean;
@@ -31,6 +33,7 @@ import kr.co.zumo.app.lifeplus.bean.api.CoinInfoRequestBean;
 import kr.co.zumo.app.lifeplus.bean.api.CoinInfoResultBean;
 import kr.co.zumo.app.lifeplus.bean.api.ContentsBookmarkRequestBean;
 import kr.co.zumo.app.lifeplus.bean.api.ContentsDetailResultBean;
+import kr.co.zumo.app.lifeplus.bean.api.ContentsFlagBean;
 import kr.co.zumo.app.lifeplus.bean.api.ContentsFlagResultBean;
 import kr.co.zumo.app.lifeplus.bean.api.ContentsLikeRequestBean;
 import kr.co.zumo.app.lifeplus.bean.api.EventDetailResultBean;
@@ -349,8 +352,15 @@ public class LifeplusAPIRepository implements LifeplusAPI {
      * 회원 / 비회원 구분 처리
      */
     if (SuperModel.getInstance().isJoined()) {
-      // 회원 - 서버에 저장
-      return new LifeplusAPIService().setLiked(bean);
+      if (SuperModel.getInstance().isActiveMember()) {
+        // 회원 - 서버에 저장
+        return new LifeplusAPIService().setLiked(bean);
+      }
+      else {
+        return Single.fromCallable(() -> {
+          return new LifeplusAPIBean(LifeplusAPIBean.RETURN_PARAMETER_ERROR, "");
+        });
+      }
     }
     else {
       // 비회원 - 로컬에 저장
@@ -360,7 +370,26 @@ public class LifeplusAPIRepository implements LifeplusAPI {
 
   @Override
   public Single<LifeplusAPIBean> setBookmarked(ContentsBookmarkRequestBean bean) {
-    return new LifeplusAPIService().setBookmarked(bean);
+    /**
+     * 회원 / 비회원 구분 처리
+     */
+    if (SuperModel.getInstance().isJoined()) {
+      if (SuperModel.getInstance().isActiveMember()) {
+        // 회원 - 서버에 저장
+        return new LifeplusAPIService().setBookmarked(bean);
+      }
+      else {
+        return Single.fromCallable(() -> {
+          return new LifeplusAPIBean(LifeplusAPIBean.RETURN_PARAMETER_ERROR, "");
+        });
+      }
+    }
+    else {
+      // 비회원 - 실패 처리, 이미 ui 에서 막고 있긴 함
+      return Single.fromCallable(() -> {
+        return new LifeplusAPIBean(LifeplusAPIBean.RETURN_PARAMETER_ERROR, "");
+      });
+    }
   }
 
   @Override
@@ -369,8 +398,23 @@ public class LifeplusAPIRepository implements LifeplusAPI {
      * 회원 / 비회원 구분 처리
      */
     if (SuperModel.getInstance().isJoined()) {
-      // 회원 - 서버에서 로딩
-      return new LifeplusAPIService().getContentsFlagList(bean);
+      if (SuperModel.getInstance().isActiveMember()) {
+        // 회원 - 서버에서 로딩
+        return new LifeplusAPIService().getContentsFlagList(bean);
+      }
+      else {
+        // 비정상 회원 - 0 리턴
+        return Single.fromCallable(() -> {
+          ContentsFlagResultBean contentsFlagResultBean = new ContentsFlagResultBean();
+          contentsFlagResultBean.setCode(LifeplusAPIBean.RETURN_SUCCESS);
+          ContentsFlagBean contentsFlagBean = new ContentsFlagBean();
+          contentsFlagBean.setBookmarkedList(new ArrayList<>());
+          contentsFlagBean.setLikedList(new ArrayList<>());
+          contentsFlagResultBean.setData(contentsFlagBean);
+
+          return contentsFlagResultBean;
+        });
+      }
     }
     else {
       // 비회원 - 로컬에서 로딩
@@ -389,8 +433,19 @@ public class LifeplusAPIRepository implements LifeplusAPI {
      * 회원 / 비회원 구분 처리
      */
     if (SuperModel.getInstance().isJoined()) {
-      // 회원 - 서버에서 로딩
-      return new LifeplusAPIService().getSharePoint(bean);
+      if (SuperModel.getInstance().isActiveMember()) {
+        // 회원 - 서버에서 로딩
+        return new LifeplusAPIService().getSharePoint(bean);
+      }
+      else {
+        // 비정상 회원 - 0 리턴
+        return Single.fromCallable(() -> {
+          ShareCoinResultBean shareCoinResultBean = new ShareCoinResultBean();
+          shareCoinResultBean.getData().setCoin("0");
+
+          return shareCoinResultBean;
+        });
+      }
     }
     else {
       // 비회원 - 로컬에서 로딩
@@ -425,8 +480,21 @@ public class LifeplusAPIRepository implements LifeplusAPI {
      * 회원 / 비회원 구분 처리
      */
     if (SuperModel.getInstance().isJoined()) {
-      // 회원 - 서버에서 로딩
-      return new LifeplusAPIService().getCoinInfo(bean);
+      if (SuperModel.getInstance().isActiveMember()) {
+        // 회원 - 서버에서 로딩
+        return new LifeplusAPIService().getCoinInfo(bean);
+      }
+      else {
+        // 비정상 회원 - 0 리턴
+        return Single.fromCallable(() -> {
+          CoinInfoResultBean coinInfoResultBean = new CoinInfoResultBean();
+          coinInfoResultBean.setCoin("0");
+          coinInfoResultBean.setExpiringCoin("0");
+          coinInfoResultBean.setData(new ArrayList<>());
+
+          return coinInfoResultBean;
+        });
+      }
     }
     else {
       // 비회원 - 로컬에서 로딩