From c660f059d4e07a1b784442a1bbb4a5109b82e837 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期二, 25 六月 2024 09:51:45 +0800 Subject: [PATCH] Merge branch 'dev' of http://172.16.1.23:6688/r/~wjc/HDLPhotovoltaicDebugAPP into dev --- app/src/main/java/com/hdl/photovoltaic/other/HdlMemberLogic.java | 402 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 402 insertions(+), 0 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlMemberLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlMemberLogic.java new file mode 100644 index 0000000..5aca561 --- /dev/null +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlMemberLogic.java @@ -0,0 +1,402 @@ +package com.hdl.photovoltaic.other; + +import android.text.TextUtils; + +import com.google.gson.Gson; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.photovoltaic.bean.PageNumberObject; +import com.hdl.photovoltaic.internet.HttpClient; +import com.hdl.photovoltaic.internet.api.HttpApi; +import com.hdl.photovoltaic.listener.CloudCallBeak; +import com.hdl.photovoltaic.ui.bean.MemberBean; +import com.hdl.photovoltaic.ui.bean.StaffBean; +import com.hdl.photovoltaic.ui.bean.UserRightTypeBean; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +/** + * 鎴愬憳閫昏緫 + */ +public class HdlMemberLogic { + private static volatile HdlMemberLogic sHdlMemberLogic; + + /** + * 鑾峰彇褰撳墠瀵硅薄 + * + * @return HdlAccountLogic + */ + public static synchronized HdlMemberLogic getInstance() { + if (sHdlMemberLogic == null) { + synchronized (HdlMemberLogic.class) { + if (sHdlMemberLogic == null) { + sHdlMemberLogic = new HdlMemberLogic(); + } + } + + } + return sHdlMemberLogic; + } + + /** + * 鑾峰彇褰撳墠璐﹀彿鍦ㄥ叕鍙哥殑韬唤 + * + * @param cloudCallBeak - + */ + public void getUserRightType(CloudCallBeak<UserRightTypeBean> cloudCallBeak) { + String requestUrl = HttpApi.B_POST_GET_USERRIGHTTYPE; + JsonObject json = new JsonObject(); + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (TextUtils.isEmpty(jsonStr)) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(new UserRightTypeBean()); + } + } + Gson gson = new Gson(); + + UserRightTypeBean userRightTypeBean = gson.fromJson(jsonStr, UserRightTypeBean.class); + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(userRightTypeBean); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + /** + * 鑾峰彇鍛樺伐鍒楄〃锛圔绔級 + * + * @param pageNo 椤电爜 + * @param pageSize 椤垫暟锛堜竴椤靛灏戞暟鎹級 + * @param cloudCallBeak - + */ + public void getStaffList(long pageNo, long pageSize, CloudCallBeak<PageNumberObject<StaffBean>> cloudCallBeak) { + String requestUrl = HttpApi.B_POST_GET_LISTBYPAGE; + JsonObject json = new JsonObject(); + json.addProperty("pageNo", pageNo); + json.addProperty("pageSize", pageSize); + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (TextUtils.isEmpty(jsonStr)) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(new PageNumberObject<>()); + } + } + Gson gson = new Gson(); + Type type = new TypeToken<PageNumberObject<StaffBean>>() { + }.getType(); + PageNumberObject<StaffBean> pageNumberObject = gson.fromJson(jsonStr, type); + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(pageNumberObject); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + /** + * 鑾峰彇鍛樺伐璇︽儏锛圔绔級 + * + * @param userId - + * @param cloudCallBeak - + */ + public void getStaffInfo(String userId, CloudCallBeak<StaffBean> cloudCallBeak) { + String requestUrl = HttpApi.B_POST_GET_MANAGE_INFO; + JsonObject json = new JsonObject(); + json.addProperty("userId", userId); + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (TextUtils.isEmpty(jsonStr)) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(new StaffBean()); + } + } + Gson gson = new Gson(); + + StaffBean staffBean = gson.fromJson(jsonStr, StaffBean.class); + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(staffBean); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + /** + * 鍛樺伐娣诲姞锛圔绔級 + * + * @param staffBean 鍛樺伐瀵硅薄 + * @param cloudCallBeak - + */ + public void getStaffAdd(StaffBean staffBean, CloudCallBeak<Boolean> cloudCallBeak) { + String requestUrl = HttpApi.B_POST_GET_MANAGE_CREATE; + JsonObject json = new JsonObject(); + if (!TextUtils.isEmpty(staffBean.getUserName())) { + json.addProperty("userName", staffBean.getUserName()); + } + if (staffBean.getUserSex() != 0) { + json.addProperty("userSex", staffBean.getUserSex()); + } + if (!TextUtils.isEmpty(staffBean.getUserPhone())) { + json.addProperty("userPhone", staffBean.getUserPhone()); + } + if (!TextUtils.isEmpty(staffBean.getUserEmail())) { + json.addProperty("userEmail", staffBean.getUserEmail()); + } + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(true); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + /** + * 鍛樺伐缂栬緫锛圔绔級 + * + * @param staffBean 鍛樺伐瀵硅薄 + * @param cloudCallBeak - + */ + public void getStaffEdit(StaffBean staffBean, CloudCallBeak<Boolean> cloudCallBeak) { + String requestUrl = HttpApi.B_POST_GET_MANAGE_EDIT; + JsonObject json = new JsonObject(); + if (!TextUtils.isEmpty(staffBean.getUserId())) { + json.addProperty("userId", staffBean.getUserId()); + } + if (!TextUtils.isEmpty(staffBean.getUserName())) { + json.addProperty("userName", staffBean.getUserName()); + } + if (staffBean.getUserSex() != 0) { + json.addProperty("userSex", staffBean.getUserSex()); + } + if (!TextUtils.isEmpty(staffBean.getUserPhone())) { + json.addProperty("userPhone", staffBean.getUserPhone()); + } + if (!TextUtils.isEmpty(staffBean.getUserEmail())) { + json.addProperty("userEmail", staffBean.getUserEmail()); + } + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(true); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + /** + * 鍛樺伐鍒犻櫎锛圔绔級 + * + * @param staffBean 鍛樺伐瀵硅薄 + * @param cloudCallBeak - + */ + public void getStaffDelete(StaffBean staffBean, CloudCallBeak<Boolean> cloudCallBeak) { + String requestUrl = HttpApi.B_POST_GET_MANAGE_DELETE; + JsonObject json = new JsonObject(); + json.addProperty("userId", staffBean.getUserId()); + + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(true); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + + /** + * 鑾峰彇鎴愬憳鍒楄〃锛圕绔級 + * + * @param memberBean 鎴愬憳瀵硅薄 + * @param cloudCallBeak - + */ + public void getMemberList(MemberBean memberBean, CloudCallBeak<List<MemberBean>> cloudCallBeak) { + String requestUrl = HttpApi.C_POST_MEMBER_LIST; + JsonObject json = new JsonObject(); + json.addProperty("homeId", memberBean.getHomeId()); + + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (TextUtils.isEmpty(jsonStr)) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(new ArrayList<>()); + } + } + Gson gson = new Gson(); + Type type = new TypeToken<List<MemberBean>>() { + }.getType(); + List<MemberBean> memberBeanList = gson.fromJson(jsonStr, type); + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(memberBeanList); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + + /** + * 娣诲姞鎴愬憳锛圕绔級 + * + * @param memberBean 鎴愬憳瀵硅薄 + * @param cloudCallBeak - + */ + public void getMemberAdd(MemberBean memberBean, CloudCallBeak<Boolean> cloudCallBeak) { + String requestUrl = HttpApi.C_POST_MEMBER_ADD; + JsonObject json = new JsonObject(); + json.addProperty("homeId", memberBean.getHomeId()); + json.addProperty("account", memberBean.getAccount()); + json.addProperty("childAccountType", memberBean.getChildAccountType());////瀛愯处鎴风被鍨�(ORDINARY 锛氭櫘閫氭垚鍛�,DEBUG 锛� 璋冭瘯浜哄憳,ADMIN 锛� 绠$悊鍛�,VIEW : 浠呮煡鐪�) + json.addProperty("nickName", memberBean.getNickName()); + + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(true); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + /** + * 缂栬緫鎴愬憳锛圕绔級 + * + * @param memberBean 鎴愬憳瀵硅薄 + * @param cloudCallBeak - + */ + public void getMemberEdit(MemberBean memberBean, CloudCallBeak<Boolean> cloudCallBeak) { + String requestUrl = HttpApi.C_POST_MEMBER_EDIT; + JsonObject json = new JsonObject(); + json.addProperty("homeId", memberBean.getHomeId()); + json.addProperty("childAccountId", memberBean.getChildAccountId()); + json.addProperty("childId", memberBean.getId());//鏌ユ壘瀛愯处鍙锋帴鍙h幏鍙栧埌鐨勬暟鎹紙涓婚敭id==childId锛� + json.addProperty("childAccountType", memberBean.getChildAccountType());////瀛愯处鎴风被鍨�(ORDINARY 锛氭櫘閫氭垚鍛�,DEBUG 锛� 璋冭瘯浜哄憳,ADMIN 锛� 绠$悊鍛�,VIEW : 浠呮煡鐪�) + json.addProperty("nickName", memberBean.getNickName()); +// json.addProperty("isRemoteControl", memberBean.getNickName());//杩滅▼鎺у埗 +// json.addProperty("isAllowCreateScene", memberBean.getNickName());//鍒涘缓鍦烘櫙 + + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(true); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + /** + * 鍒犻櫎鎴愬憳锛圕绔級 + * + * @param memberBean 鎴愬憳瀵硅薄 + * @param cloudCallBeak - + */ + public void getMemberDelete(MemberBean memberBean, CloudCallBeak<Boolean> cloudCallBeak) { + String requestUrl = HttpApi.C_POST_MEMBER_DELETE; + JsonObject json = new JsonObject(); + json.addProperty("homeId", memberBean.getHomeId()); + json.addProperty("childAccountId", memberBean.getChildAccountId()); + json.addProperty("childId", memberBean.getId());//鏌ユ壘瀛愯处鍙锋帴鍙h幏鍙栧埌鐨勬暟鎹紙涓婚敭id==childId锛� + + HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { + @Override + public void onSuccess(String jsonStr) { + if (cloudCallBeak != null) { + cloudCallBeak.onSuccess(true); + } + } + + @Override + public void onFailure(HDLException e) { + if (cloudCallBeak != null) { + cloudCallBeak.onFailure(e); + } + } + }); + + } + + +} -- Gitblit v1.8.0