|
|
@@ -3,10 +3,14 @@ package com.webrain.dailypay.ui.mvp.model;
|
|
|
import android.content.Context;
|
|
|
|
|
|
import com.webrain.baselibrary.AppConstant;
|
|
|
+import com.webrain.baselibrary.utils.DateUtils;
|
|
|
+import com.webrain.dailypay.AppCacheManager;
|
|
|
import com.webrain.dailypay.bean.PositionBean;
|
|
|
import com.webrain.dailypay.bean.PositionListBean;
|
|
|
import com.webrain.dailypay.bean.api.ApiNormalBean;
|
|
|
import com.webrain.dailypay.bean.api.ApiPositionListBean;
|
|
|
+import com.webrain.dailypay.bean.api.ApiPositionPauseBean;
|
|
|
+import com.webrain.dailypay.bean.api.ApiPositionRefreshBean;
|
|
|
import com.webrain.dailypay.callback.MvpDataCallBack;
|
|
|
import com.webrain.dailypay.http.ApiObserver;
|
|
|
import com.webrain.dailypay.http.RetrofitHttpParams;
|
|
|
@@ -24,7 +28,9 @@ public class PositionListFragmentModel extends BaseModel implements PositionList
|
|
|
private int pageNum = 0;//第一页为1开始 初始为0
|
|
|
private boolean isLoading = false;//是否加载中
|
|
|
private boolean isLastPage;//是否已经最后一页
|
|
|
- private int state;//状态
|
|
|
+ private int authenticationStatus = -1;//(1:等待认证 2:未通过 3:已认证)
|
|
|
+ private int isOn = -1;//(0:下架 1:上架)
|
|
|
+ private int isPause = -1;//(0:不是 1:是)
|
|
|
|
|
|
|
|
|
public PositionListFragmentModel(Context mContext) {
|
|
|
@@ -42,48 +48,54 @@ public class PositionListFragmentModel extends BaseModel implements PositionList
|
|
|
* @param callBack
|
|
|
*/
|
|
|
private void httpPositionList(final MvpDataCallBack<List<PositionListBean>> callBack, boolean isShowDialog, final boolean isInit) {
|
|
|
- isLoading = true;
|
|
|
- RetrofitHttpParams params = new RetrofitHttpParams(mContext);
|
|
|
- params.put("pageNo", pageNum + 1);
|
|
|
- params.put("pageSize", 10);
|
|
|
- if (state == AppConstant.POSITION_LIST_BACK) {
|
|
|
- params.put("authenticationStatus", 2);
|
|
|
- } else if (state == AppConstant.POSITION_LIST_IN) {
|
|
|
- params.put("isPause", 0);
|
|
|
- }
|
|
|
- new PositionSubscribe(mContext).requestGetPositions(params.getRequestParams(), new ApiObserver<ApiPositionListBean>(mContext, isShowDialog, false) {
|
|
|
- @Override
|
|
|
- public void onSuccess(ApiPositionListBean data) {
|
|
|
- if (data != null) {
|
|
|
- pageNum = data.getPageNum();
|
|
|
- isLastPage = data.isLastPage();
|
|
|
- if (pageNum == 1 || pageNum == 0) {
|
|
|
- mPositionData.clear();
|
|
|
- }
|
|
|
- if (data.getPositions() != null && !data.getPositions().isEmpty()) {
|
|
|
- mPositionData.addAll(data.getPositions());
|
|
|
+// if (AppCacheManager.getInstance().isLogin() && AppCacheManager.getInstance().getLoginModel().getAuthenticationStatus() == AppConstant.APPROVE_SUCCESS) {//身份认证成功后才可
|
|
|
+ isLoading = true;
|
|
|
+ RetrofitHttpParams params = new RetrofitHttpParams(mContext);
|
|
|
+ params.put("pageNo", pageNum + 1);
|
|
|
+ params.put("pageSize", 10);
|
|
|
+ if (authenticationStatus != -1) {
|
|
|
+ params.put("authenticationStatus", authenticationStatus);
|
|
|
+ }
|
|
|
+ if (isPause != -1) {
|
|
|
+ params.put("isPause", isPause);
|
|
|
+ }
|
|
|
+ if (isOn != -1) {
|
|
|
+ params.put("isOn", isOn);
|
|
|
+ }
|
|
|
+ new PositionSubscribe(mContext).requestGetPositions(params.getRequestParams(), new ApiObserver<ApiPositionListBean>(mContext, isShowDialog, false) {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(ApiPositionListBean data) {
|
|
|
+ if (data != null) {
|
|
|
+ pageNum = data.getPageNum();
|
|
|
+ isLastPage = data.isLastPage();
|
|
|
+ if (pageNum == 1 || pageNum == 0) {
|
|
|
+ mPositionData.clear();
|
|
|
+ }
|
|
|
+ if (data.getPositions() != null && !data.getPositions().isEmpty()) {
|
|
|
+ mPositionData.addAll(data.getPositions());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void onError(ApiPositionListBean data, ApiException exception) {
|
|
|
- super.onError(data, exception);
|
|
|
- if (isInit)
|
|
|
- isError = true;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void onError(ApiPositionListBean data, ApiException exception) {
|
|
|
+ super.onError(data, exception);
|
|
|
+ if (isInit)
|
|
|
+ isError = true;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onFinish() {
|
|
|
- callBack.onData(mPositionData);
|
|
|
- if (isError) {
|
|
|
- callBack.onError();
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ callBack.onData(mPositionData);
|
|
|
+ if (isError) {
|
|
|
+ callBack.onError();
|
|
|
+ }
|
|
|
+ isError = false;
|
|
|
+ isLoading = false;
|
|
|
}
|
|
|
- isError = false;
|
|
|
- isLoading = false;
|
|
|
- }
|
|
|
|
|
|
- });
|
|
|
+ });
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -114,15 +126,6 @@ public class PositionListFragmentModel extends BaseModel implements PositionList
|
|
|
pageNum = 0;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置列表状态
|
|
|
- *
|
|
|
- * @param state
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void setState(int state) {
|
|
|
- this.state = state;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 刷新
|
|
|
@@ -130,13 +133,17 @@ public class PositionListFragmentModel extends BaseModel implements PositionList
|
|
|
* @param bean
|
|
|
*/
|
|
|
@Override
|
|
|
- public void doRefresh(PositionBean bean, final MvpDataCallBack<Boolean> callBack) {
|
|
|
+ public void doRefresh(final PositionBean bean, final MvpDataCallBack<Boolean> callBack) {
|
|
|
RetrofitHttpParams params = new RetrofitHttpParams(mContext);
|
|
|
params.put("id", bean.getId());
|
|
|
- new PositionSubscribe(mContext).requestUpdateTime(params.getRequestParams(), new ApiObserver<ApiNormalBean>(mContext, true, false) {
|
|
|
+ new PositionSubscribe(mContext).requestUpdateTime(params.getRequestParams(), new ApiObserver<ApiPositionRefreshBean>(mContext, true, false) {
|
|
|
@Override
|
|
|
- public void onSuccess(ApiNormalBean data) {
|
|
|
- callBack.onData(true);
|
|
|
+ public void onSuccess(ApiPositionRefreshBean data) {
|
|
|
+ if (data != null) {
|
|
|
+ String date = DateUtils.getFormatLongToStr(data.getDate(), "yyyy-MM-dd HH:mm:ss");
|
|
|
+ bean.setUpdateTime(date);
|
|
|
+ callBack.onData(true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -153,12 +160,19 @@ public class PositionListFragmentModel extends BaseModel implements PositionList
|
|
|
* @param bean
|
|
|
*/
|
|
|
@Override
|
|
|
- public void doPause(PositionBean bean, MvpDataCallBack<Boolean> callBack) {
|
|
|
+ public void doPause(final PositionBean bean, final MvpDataCallBack<Boolean> callBack) {
|
|
|
RetrofitHttpParams params = new RetrofitHttpParams(mContext);
|
|
|
params.put("id", bean.getId());
|
|
|
- new PositionSubscribe(mContext).requestUpdateTime(params.getRequestParams(), new ApiObserver<ApiNormalBean>(mContext, true, false) {
|
|
|
+ params.put("isPause", bean.getIsPause() == 0 ? 1 : 0);
|
|
|
+ new PositionSubscribe(mContext).requestPausePosition(params.getRequestParams(), new ApiObserver<ApiPositionPauseBean>(mContext, true, false) {
|
|
|
@Override
|
|
|
- public void onSuccess(ApiNormalBean data) {
|
|
|
+ public void onSuccess(ApiPositionPauseBean data) {
|
|
|
+ if (data != null) {
|
|
|
+ if ("1".equals(data.getIsPause()) || "0".equals(data.getIsPause())) {
|
|
|
+ bean.setIsPause(Integer.parseInt(data.getIsPause()));
|
|
|
+ callBack.onData(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -175,12 +189,15 @@ public class PositionListFragmentModel extends BaseModel implements PositionList
|
|
|
* @param bean
|
|
|
*/
|
|
|
@Override
|
|
|
- public void doEnd(PositionBean bean, MvpDataCallBack<Boolean> callBack) {
|
|
|
+ public void doEnd(final PositionBean bean, final MvpDataCallBack<Boolean> callBack) {
|
|
|
RetrofitHttpParams params = new RetrofitHttpParams(mContext);
|
|
|
params.put("id", bean.getId());
|
|
|
- new PositionSubscribe(mContext).requestUpdateTime(params.getRequestParams(), new ApiObserver<ApiNormalBean>(mContext, true, false) {
|
|
|
+ params.put("isOn", "0");
|
|
|
+ new PositionSubscribe(mContext).requestOverPosition(params.getRequestParams(), new ApiObserver<ApiNormalBean>(mContext, true, false) {
|
|
|
@Override
|
|
|
public void onSuccess(ApiNormalBean data) {
|
|
|
+ bean.setIsOn(0);
|
|
|
+ callBack.onData(true);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -190,4 +207,64 @@ public class PositionListFragmentModel extends BaseModel implements PositionList
|
|
|
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看全部状态
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void changeAllState() {
|
|
|
+ isOn = -1;
|
|
|
+ isPause = -1;
|
|
|
+ authenticationStatus = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看正在招聘状态
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void changeStartState() {
|
|
|
+ isOn = 1;
|
|
|
+ isPause = 0;
|
|
|
+ authenticationStatus = 3;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看暂停招聘状态
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void changePauseState() {
|
|
|
+ isOn = -1;
|
|
|
+ isPause = 1;
|
|
|
+ authenticationStatus = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看结束状态
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void changeOverState() {
|
|
|
+ isOn = 0;
|
|
|
+ isPause = -1;
|
|
|
+ authenticationStatus = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核中
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void changeInState() {
|
|
|
+ isOn = -1;
|
|
|
+ isPause = -1;
|
|
|
+ authenticationStatus = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核驳回
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void changeNoState() {
|
|
|
+ isOn = -1;
|
|
|
+ isPause = -1;
|
|
|
+ authenticationStatus = 2;
|
|
|
+ }
|
|
|
}
|