wjc
2023-07-07 22494af577e21a930abef309f2f60c03c9615bd1
app/src/main/java/com/hdl/photovoltaic/other/HdlAccountLogic.java
@@ -3,6 +3,13 @@
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.hdl.linkpm.sdk.core.exception.HDLException;
import com.hdl.linkpm.sdk.user.HDLLinkPMUser;
import com.hdl.linkpm.sdk.user.bean.HDLLoginBean;
import com.hdl.linkpm.sdk.user.bean.HDLUserRegionBean;
import com.hdl.linkpm.sdk.user.callback.ILoginCallBack;
import com.hdl.linkpm.sdk.user.callback.IRegionByAccountCallBack;
import com.hdl.linkpm.sdk.user.controller.HDLPMUserController;
import com.hdl.photovoltaic.ui.bean.LoginUserBean;
import com.hdl.photovoltaic.ui.bean.LoginUserRegionBean;
import com.hdl.photovoltaic.bean.HttpResponsePack;
@@ -46,27 +53,19 @@
     *
     * @param i_account 账号
     */
    public void regionByAccount(String i_account, CloudCallBeak<LoginUserRegionBean> cloudCallBeak) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("account", i_account);
        String full = AppConfigManage.getAPPRegionUrl() + HttpApi.POST_RegionByUserAccount;
        HttpClient.getInstance().requestFullHttp(full, jsonObject.toString(), true, true, new BaseSuccessFailureCallBeak() {
    public void regionByAccount(String i_account, CloudCallBeak<HDLUserRegionBean> cloudCallBeak) {
        HDLPMUserController.getInstance().regionByAccount(i_account, new IRegionByAccountCallBack() {
            @Override
            public void onSuccess(HttpResponsePack httpResponsePack) {
                if (httpResponsePack != null && httpResponsePack.getData() != null) {
                    Gson gson = new Gson();
                    String json = gson.toJson(httpResponsePack.getData());
                    LoginUserRegionBean loginUserRegionBean = new Gson().fromJson(json, LoginUserRegionBean.class);
                    if (cloudCallBeak != null) {
                        cloudCallBeak.onSuccess(loginUserRegionBean);
                    }
            public void onSuccess(HDLUserRegionBean regionBean) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onSuccess(regionBean);
                }
            }
            @Override
            public void onFailure(Exception exception) {
            public void onFailure(HDLException error) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
                    cloudCallBeak.onFailure(error);
                }
            }
        });
@@ -76,39 +75,54 @@
     * 登录(B端账号)
     * 通过账号和密码
     *
     * @param account       手机或者邮箱
     * @param loginPwd      密码
     * @param cloudCallBeak -
     * @param account  手机或者邮箱
     * @param loginPwd 密码
     * @param callBack -
     */
    public void loginByPassword(String account, String loginPwd, CloudCallBeak<LoginUserBean> cloudCallBeak) {
    public void loginByPassword(String account, String loginPwd, ILoginCallBack callBack) {
        String requestUrl = HttpApi.POST_Login;
        JsonObject json = new JsonObject();
        json.addProperty("account", account);
        json.addProperty("loginPwd", loginPwd);
//        json.addProperty("platform", "APP");
        json.addProperty("grantType", "password");
        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
        HDLPMUserController.getInstance().loginByPassword(account, loginPwd, new ILoginCallBack() {
            @Override
            public void onSuccess(HttpResponsePack httpResponsePack) {
                if (httpResponsePack != null && httpResponsePack.getData() != null) {
                    Gson gson = new Gson();
                    String json = gson.toJson(httpResponsePack.getData());
                    LoginUserBean loginUserBean = new Gson().fromJson(json, LoginUserBean.class);
                    saveUserData(loginUserBean);
                    if (cloudCallBeak != null) {
                        cloudCallBeak.onSuccess(loginUserBean);
                    }
            public void onSuccess(HDLLoginBean loginBean) {
                if (callBack != null) {
                    callBack.onSuccess(loginBean);
                }
            }
            @Override
            public void onFailure(Exception exception) {
                if (cloudCallBeak != null) {
                    cloudCallBeak.onFailure(exception);
            public void onFailure(HDLException error) {
                if (callBack != null) {
                    callBack.onFailure(error);
                }
            }
        });
//        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), true, true, new BaseSuccessFailureCallBeak() {
//            @Override
//            public void onSuccess(HttpResponsePack httpResponsePack) {
//                if (httpResponsePack != null && httpResponsePack.getData() != null) {
//                    Gson gson = new Gson();
//                    String json = gson.toJson(httpResponsePack.getData());
//                    LoginUserBean loginUserBean = new Gson().fromJson(json, LoginUserBean.class);
//                    saveUserData(loginUserBean);
//                    if (cloudCallBeak != null) {
//                        cloudCallBeak.onSuccess(loginUserBean);
//                    }
//                }
//            }
//
//            @Override
//            public void onFailure(Exception exception) {
//                if (cloudCallBeak != null) {
//                    cloudCallBeak.onFailure(exception);
//                }
//            }
//        });
    }
    /**