package com.uas.sso.util; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.uas.sso.AccountConfig; import com.uas.sso.ResultWrap; import com.uas.sso.common.util.HttpUtil; import com.uas.sso.entity.*; import org.springframework.data.domain.Page; import org.springframework.ui.ModelMap; import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * 客户端使用,操作企业资料、用户资料 * * @author wangmh * */ public class AccountUtils { /** * 企业解除绑定的应用 * * @author wangmh * @date 2018/1/26 16:34 * @param spaceUU 企业uu号 * @param appId 应用id * @throws Exception */ public static void unbindApp(Long spaceUU, String appId) throws Exception { String saveUrl = AccountConfig.getSpaceSaveUrl(); if (!StringUtils.isEmpty(saveUrl)) { ModelMap formData = new ModelMap(); formData.put("_operate", "unbind"); formData.put("spaceUU", spaceUU); formData.put("appId", appId); HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } } } } /** * 企业开通应用 * @param spaceUU 企业uu号 * @param appId 应用id * @throws Exception */ public static void bindApp(Long spaceUU, String appId) throws Exception { String saveUrl = AccountConfig.getSpaceSaveUrl(); if (!StringUtils.isEmpty(saveUrl)) { ModelMap formData = new ModelMap(); formData.put("_operate", "bind"); formData.put("spaceUU", spaceUU); formData.put("appId", appId); HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } } } } /** * 用户解除绑定企业 * @param userUU 用户uu号 * @param spaceUU 企业uu号 * @throws Exception */ public static void unbindUserSpace(Long userUU, Long spaceUU) throws Exception { String saveUrl = AccountConfig.getUserSaveUrl(); if (!StringUtils.isEmpty(saveUrl)) { ModelMap formData = new ModelMap(); formData.put("_operate", "bind"); formData.put("userUU", userUU); formData.put("spaceUU", spaceUU); HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } } } } /** * 用户绑定企业 * @param userUU 用户uu号 * @param spaceUU 企业uu号 * @throws Exception */ public static void bindUserSpace(Long userUU, Long spaceUU) throws Exception { String saveUrl = AccountConfig.getUserSaveUrl(); if (!StringUtils.isEmpty(saveUrl)) { ModelMap formData = new ModelMap(); formData.put("_operate", "unbind"); formData.put("userUU", userUU); formData.put("spaceUU", spaceUU); HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } } } } /** * 根据营业执照号获得企业信息 * @param businessCode 营业执照号 * @return */ public List findByBusinessCode(String businessCode) throws Exception { String saveUrl = AccountConfig.getSpaceSaveUrl(); if (!StringUtils.isEmpty(saveUrl)) { ModelMap formData = new ModelMap(); saveUrl = saveUrl + "/info/businessCode"; formData.put("businessCode", businessCode); HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } else if (result.getContent() != null){ return JSON.parseArray(result.getContent().toString(), UserSpaceView.class); } } } return null; } /** * 根据营业执照号获得企业信息 * @param spaceName 营业执照号 * @return */ public List findBySpaceName(String spaceName) throws Exception { String saveUrl = AccountConfig.getSpaceSaveUrl(); if (!StringUtils.isEmpty(saveUrl)) { ModelMap formData = new ModelMap(); saveUrl = saveUrl + "/info/businessCode"; formData.put("spaceName", spaceName); HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } else if (result.getContent() != null){ return JSON.parseArray(result.getContent().toString(), UserSpaceView.class); } } } return null; } /** * 用户申请绑定企业 * @param userUU 用户uu号 * @param spaceUU 企业uu号 * @throws Exception */ public static void applyUserSpace(Long userUU, Long spaceUU) throws Exception { String saveUrl = AccountConfig.getUserSaveUrl(); if (!StringUtils.isEmpty(saveUrl)) { ModelMap formData = new ModelMap(); saveUrl = saveUrl + "/apply/bind"; formData.put("userUU", userUU); formData.put("spaceUU", spaceUU); HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } } } } /** * 分页查找个人申请记录 * * @author wangmh * @date 2018/2/1 15:47 * @param userUU 用户uu号 * @param page 页数(从0开始) * @param size 每页大小 * @return * @throws Exception */ public static Page findApplyInfo(Long userUU, int page, int size) throws Exception { String url = AccountConfig.getUserSaveUrl(); if (!StringUtils.isEmpty(url)) { url = url + "/apply/info"; ModelMap data = new ModelMap(); data.put("userUU", userUU); data.put("page", page); data.put("size", size); HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } else if (result.getContent() != null) { return JSON.parseObject(result.getContent().toString(), new TypeReference>() { }); } } } return null; } /** * 统计该企业审批记录数量 * @param spaceUU 企业uu号 * @return * @throws Exception */ public static Map applyCount(Long spaceUU) throws Exception { String url = AccountConfig.getSpaceSaveUrl(); if (!StringUtils.isEmpty(url)) { url = url + "/apply/count"; ModelMap data = new ModelMap(); data.put("spaceUU", spaceUU); HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } else if (result.getContent() != null) { return JSON.parseObject(result.getContent().toString(), Map.class); } } } return null; } /** * 校验企业名称 * @param spaceName 企业名称 */ public static void checkSpaceName(String spaceName) throws Exception { String url = AccountConfig.getSpaceSaveUrl(); if (!StringUtils.isEmpty(url)) { url = url + "/checkSpaceName"; ModelMap data = new ModelMap(); data.put("spaceName", spaceName); HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } } } } /** * 校验企业营业执照号 * @param businessCode 企业营业执照号 */ public static void checkBusinessCode(String businessCode) throws Exception { String url = AccountConfig.getSpaceSaveUrl(); if (!StringUtils.isEmpty(url)) { url = url + "/checkBusinessCode"; ModelMap data = new ModelMap(); data.put("businessCode", businessCode); HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } } } } /** * 根据用户uu号获取用户信息 * @param userUU 用户uu号 * @return * @throws Exception */ public static UserView findByUserUU(Long userUU) throws Exception { String url = AccountConfig.getUserSaveUrl(); if (!StringUtils.isEmpty(url)) { url = url + "/info"; ModelMap data = new ModelMap(); data.put("userUU", userUU); HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } else if (result.getContent() != null) { return JSON.parseObject(result.getContent().toString(), UserView.class); } } } return null; } /** * 根据用户uu号获取用户信息 * @param spaceUU 企业uu号 * @return * @throws Exception */ public static UserSpaceView findBySpaceUU(Long spaceUU) throws Exception { String url = AccountConfig.getUserSaveUrl(); if (!StringUtils.isEmpty(url)) { url = url + "/checkBusinessCode"; ModelMap data = new ModelMap(); data.put("spaceUU", spaceUU); HttpUtil.ResponseWrap res = HttpUtil.doGet(url, data); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } else if (result.getContent() != null) { return JSON.parseObject(result.getContent().toString(), UserSpaceView.class); } } } return null; } /** * 通过当前企业号和企业列表中的企业号查询申请状态 * * @return * @throws Exception */ public static RequestStatus getStatusByCustUidAndVendUid(String custBusinessCode, String vendBusinessCode) throws Exception { String url = AccountConfig.getEnPartnersUrl(); RequestStatus request = new RequestStatus(); if (!StringUtils.isEmpty(url)) { HttpUtil.ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "getRequestStatus") .addAttribute("vendBusinessCode", vendBusinessCode) .addAttribute("custBusinessCode", custBusinessCode)); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { request = JSON.parseObject(res.getContent(), RequestStatus.class); } } return request; } /// 之后方法会恢复并修改 // // /** // * 获取校验码 // * // * @param username // * 手机号或邮箱地址 // * @return // */ // public static void sendValidCode(String username) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(saveUrl)) { // ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "getVcode").addAttribute("username", username)); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else { // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); // if (!result.isSuccess()) // throw new Exception(result.getErrMsg()); // } // } // } // // /** // * 验证校验码 // * // * @param username // * 手机号或邮箱地址 // * @param validCode // * 校验码 // * @return // */ // public static boolean checkValidCode(String username, String validCode) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(saveUrl)) { // ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "checkVcode").addAttribute("username", username) // .addAttribute("validCode", validCode)); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else { // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); // if (!result.isSuccess()) // throw new Exception(result.getErrMsg()); // else // return true; // } // } // return false; // } // // public static String getAccessToken(String appId, String spaceDialectUID, String uid) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(saveUrl)) { // saveUrl = saveUrl + "/getToken"; // JSONObject formData = new JSONObject(); // formData.put("appId", appId); // formData.put("spaceDialectUID", spaceDialectUID); // formData.put("uid", uid); // ResponseWrap res = HttpUtil.doGet(saveUrl, formData); // if (!res.isSuccess()) { // throw new Exception(res.getContent()); // } else { // return res.getContent(); // } // } // return null; // } // // /** // * 验证密码,返回绑定身份信息的token // * // * @return // */ // public static String getAccessToken(User user) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(saveUrl)) { // JSONObject formData = JSON.parseObject(JSON.toJSONString(user)); // formData.put("_operate", "getToken"); // ResponseWrap res = HttpUtil.doGet(saveUrl, formData); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else { // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); // if (!result.isSuccess()) // throw new Exception(result.getErrMsg()); // else // return String.valueOf(result.getContent()); // } // } // return null; // } // // /** // * 验证token,返回当前应用相关的身份信息 // * // * @return // */ // public static UserView checkAccessToken(String token) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(saveUrl)) { // ResponseWrap res = HttpUtil.doGet( // saveUrl, // new ModelMap("_operate", "checkToken").addAttribute("token", token).addAttribute("appId", // SSOHelper.getSSOService().getConfig().getAppName())); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else { // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); // if (!result.isSuccess()) // throw new Exception(result.getErrMsg()); // else // return JSON.parseObject(JSON.toJSONString(result.getContent()), UserView.class); // } // } // return null; // } // // /** // * 用token验证登录 // * // * @param request // * @param response // * @param token // * @throws Exception // */ // public static UserView loginByAccessToken(HttpServletRequest request, HttpServletResponse response, String token) throws Exception { // UserView user = checkAccessToken(token); // if (null != user) { // SSOToken st = new SSOToken(request, user.getUid()); // st.setData(JSON.toJSONString(user)); // SSOHelper.setSSOCookie(request, response, st, true); // } // return user; // } /** * 传入当前登录的企业的营业执照号,查询发出的申请 * * @param businessCode 营业执照号 * @param statusCode 状态吗 * @param keyword 关键词 * @param pageNumber 页号(0开始) * @param pageSize 每页数量 * @return * @throws Exception */ public static Page getAllRequest(String businessCode, Integer statusCode, String keyword, int pageNumber, int pageSize) throws Exception { String getUrl = AccountConfig.getEnPartnersUrl(); if (!StringUtils.isEmpty(getUrl)) { HttpUtil.ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequest").addAttribute("businessCode", businessCode) .addAttribute("statusCode", statusCode).addAttribute("businessCode", businessCode).addAttribute("keyword", keyword) .addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize)); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class); if (!result.isSuccess()) { throw new Exception(result.getErrMsg()); } else if (result.getContent() != null) { return JSONObject.parseObject(res.getContent(), new TypeReference>() {}); } } } return null; } // // /** // * 通过已存在uu过滤,取出全部合作伙伴(UAS接口用) // * @param businessCode // * @param statusCode // * @param keyword // * @param pageNumber // * @param pageSize // * @param partnerUUs // * @return // */ // public static Page getRequestFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, List partnerUUs, int pageNumber, int pageSize) throws Exception { // String getUrl = AccountConfig.getEnPartnersUrl(); // if (!StringUtils.isEmpty(getUrl)) { // ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequestFilterByPartnerUUs").addAttribute("businessCode", businessCode) // .addAttribute("statusCode", statusCode).addAttribute("keyword", keyword).addAttribute("partnerUUs", JSON.toJSON(partnerUUs)) // .addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize)); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // return JSON.parseObject(res.getContent(), new TypeReference>() { // }); // } // return null; // } // /** * 进入企业圈 * * @return * @throws Exception */ public static String redirectContactPage() throws Exception { String enterUrl = AccountConfig.getContactPageUrl(); return enterUrl; } // // /** // * 通过关键词搜索企业信息 // * // * @param keyword // * @return // * @throws Exception // */ // public static Page getUserSpacesByKeyword(String keyword, int pageNumber, int pageSize) throws Exception { // String Url = AccountConfig.getEnPartnersUrl(); // if (!StringUtils.isEmpty(Url)) { // ResponseWrap res = HttpUtil.doGet(Url, // new ModelMap("_operate", "getUserSpaces").addAttribute("keyword", keyword).addAttribute("pageNumber", pageNumber) // .addAttribute("pageSize", pageSize)); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // return JSON.parseObject(res.getContent(), new TypeReference>() { // }); // } // return null; // } // // /** // * 通过手机号搜索用户账号信息 // * // * @param uid // * @return // * @throws Exception // */ // public static List getUserInfoByUid(String uid) throws Exception { // String Url = AccountConfig.getSpaceSaveUrl(); // if (!StringUtils.isEmpty(Url)) { // ResponseWrap res = HttpUtil.doGet(Url + "/userInfo", // new ModelMap("uid", uid)); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // String resText = res.getContent(); // JSONObject object = JSON.parseObject(resText); // String contentText = object.getString("content"); // return JSON.parseArray(contentText, User.class); // } // return null; // } // // /** // * 通过营业执照号获取企业应用 // * // * @param uid // * @return // * @throws Exception // */ // public static List getUserSpaceByUid(String uid) throws Exception { // String Url = AccountConfig.getSpaceSaveUrl(); // if (!StringUtils.isEmpty(Url)) { // ResponseWrap res = HttpUtil.doGet(Url + "/" + uid); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // String resText = res.getContent(); // JSONObject object = JSON.parseObject(resText); // String contentText = object.getString("content"); // return JSON.parseArray(contentText, UserSpace.class); // } // return null; // } /** * 新增一条合作关系记录 * * @param record * @return * @throws Exception */ public static String addNewRecord(PartnershipRecordView record) throws Exception { String url = AccountConfig.getEnPartnersUrl(); String result = null; if (!StringUtils.isEmpty(url)) { JSONObject formData = JSON.parseObject(JSON.toJSONString(record)); formData.put("_operate", "addPartner"); HttpUtil.ResponseWrap res = HttpUtil.doPost(url, formData); result = res.getContent(); } return result; } /** * 同步供应商关系为合作关系记录 * * @param record * @return * @throws Exception */ public static String synchronizeRecord(PartnershipRecordView record) throws Exception { String url = AccountConfig.getEnPartnersUrl(); String result = null; if (!StringUtils.isEmpty(url)) { JSONObject formData = JSON.parseObject(JSON.toJSONString(record)); formData.put("_operate", "synchronizePartner"); HttpUtil.ResponseWrap res = HttpUtil.doPost(url, formData); result = res.getContent(); } return result; } /** * 通过id和申请人的电话进行确认 * * @param id * @param vendUserTel * @param appId * @return * @throws Exception */ public static String acceptRequest(Long id, String vendUserTel, String appId) throws Exception { String url = AccountConfig.getEnPartnersUrl(); String result = null; if (!StringUtils.isEmpty(url)) { HttpUtil.ResponseWrap res = HttpUtil.doGet( url, new ModelMap("_operate", "acceptRequest").addAttribute("id", id).addAttribute("vendUserTel", vendUserTel) .addAttribute("appId", appId)); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { result = res.getContent(); } } return result; } // /** * 申请不通过,通过申请人的电话操作,并标出原因 * * @param id * @param reason * @param vendUserTel * @param appId * @return * @throws Exception */ public static String rejectRequest(Long id, String reason, String vendUserTel, String appId) throws Exception { String url = AccountConfig.getEnPartnersUrl(); String result = null; if (!StringUtils.isEmpty(url)) { HttpUtil.ResponseWrap res = HttpUtil.doGet( url, new ModelMap("_operate", "rejectRequest").addAttribute("id", id).addAttribute("reason", reason) .addAttribute("vendUserTel", vendUserTel).addAttribute("appId", appId)); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { result = res.getContent(); } } return result; } // /** // * 通过当前企业号和企业列表中的企业号查询申请状态 // * // * @return // * @throws Exception // */ // public static RequsetStatus getStatusByCustUidAndVendUid(String custUid, String vendUid) throws Exception { // String url = AccountConfig.getEnPartnersUrl(); // RequsetStatus request = new RequsetStatus(); // if (!StringUtils.isEmpty(url)) { // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "getRequestStatus").addAttribute("custUid", custUid) // .addAttribute("vendUid", vendUid)); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else { // request = JSON.parseObject(res.getContent(), RequsetStatus.class); // } // } // return request; // } // // /** // * 搜索词通过id返回数据 // * // * @param ids // * @return // * @throws Exception // */ // public static List findAll(String ids) throws Exception { // String url = AccountConfig.getEnPartnersUrl(); // List details = new ArrayList(); // if (!StringUtils.isEmpty(url)) { // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "findAll").addAttribute("ids", ids)); // if(!res.isSuccess()) // throw new Exception(res.getContent()); // else // details = JSONObject.parseArray(res.getContent(), UserSpaceDetail.class); // } // return details; // } /** * 通过企业营业执照查询收到的待处理的请求 * * @param businessCode * @return * @throws Exception */ public static String getRequestTodo(String businessCode) throws Exception { String url = AccountConfig.getEnPartnersUrl(); String result = null; if (!StringUtils.isEmpty(url)) { HttpUtil.ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "getRequestTodo").addAttribute("businessCode", businessCode)); if (!res.isSuccess()) { throw new Exception(res.getContent()); } else { result = res.getContent(); } } return result; } /** * 其他应用发起邀请注册,同步数据 * * @param jsonStr * @throws Exception */ public static void synchroInvitation(String jsonStr) throws Exception { String url = AccountConfig.getEnPartnersUrl(); if (!StringUtils.isEmpty(url)) { HttpUtil.doPost(url, new ModelMap("_operate", "invitation").addAttribute("jsonStr", jsonStr)); } } // /** // * ERP、SAAS新开账套名称校验 // * // * @param name // * @return // * @throws Exception // */ // public static String validName(String name) throws Exception { // String result = null; // String url = AccountConfig.getSpaceSaveUrl(); // if (!StringUtils.isEmpty(url)) { // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "validName").addAttribute("name", name), // 50); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else // result = res.getContent(); // } // return result; // } // // /** // * ERP、SAAS新开账套名称校验 // * // * @param businessCode // * @return // * @throws Exception // */ // public static String validBusinessCode(String businessCode) throws Exception { // String result = null; // String url = AccountConfig.getSpaceSaveUrl(); // if (!StringUtils.isEmpty(url)) { // ResponseWrap res = HttpUtil.doGet(url, // new ModelMap("_operate", "validBusinessCode").addAttribute("businessCode", businessCode), 50); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else // result = res.getContent(); // } // return result; // } // // /** // * 通过营业执照号查找 企业详细信息 // * // * @param // * @return // * @throws Exception // */ // public static UserSpaceDetail findByBusinessCode(String businessCode) throws Exception { // String result = null; // String url = AccountConfig.getSpaceSaveUrl(); // if (!StringUtils.isEmpty(url)) { // ResponseWrap res = HttpUtil.doGet(url, // new ModelMap("_operate", "findByBusinessCode").addAttribute("businessCode", businessCode), 50); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else // result = res.getContent(); // } // return JSON.parseObject(result,UserSpaceDetail.class); // } // // /** // * ERP、SAAS新开账套 // * // * @param userSpaceDetail // * @param users // * @throws Exception // */ // public static String applyApp(UserSpaceDetail userSpaceDetail, List users) throws Exception { // String url = AccountConfig.getSpaceSaveUrl(); // String result = null; // if (!StringUtils.isEmpty(url)) { // ResponseWrap res = HttpUtil.doPost(url, new ModelMap("_operate", "registerBranchAccount") // .addAttribute("detail", JSON.toJSON(userSpaceDetail)) // .addAttribute("userInfos", JSON.toJSON(users))); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else // result = res.getContent(); // } // return result; // } // // /** // * 商城个人账号增加企业注册 // * // * @param userSpaceDetail // * @throws Exception // */ // public static String applyAppForMall(UserSpaceDetail userSpaceDetail) throws Exception { // String url = AccountConfig.getSpaceSaveUrl(); // String result = null; // if (!StringUtils.isEmpty(url)) { // ResponseWrap res = HttpUtil.doPost(url, // new ModelMap("_operate", "registForMall") // .addAttribute("detail", JSON.toJSON(userSpaceDetail))); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else // result = res.getContent(); // } // return result; // } // // /** // * 设置hr账号 // * // * @param user // * @param detail // * @return // * @throws Exception // */ // public static String setHrAccount(User user, UuzcUserSpaceDetail detail) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // saveUrl = saveUrl + "/setHrAccount"; // if (!StringUtils.isEmpty(saveUrl)) { // JSONObject formData = new JSONObject(); // if (detail != null) { // formData = JSON.parseObject(JSON.toJSONString(detail)); // } // if (null != user) { // formData.putAll(JSON.parseObject(JSON.toJSONString(user))); // } // ResponseWrap response = HttpUtil.doPost(saveUrl, formData); // if (!response.isSuccess()) // throw new Exception(response.getContent()); // else { // return response.getContent(); // } // } // return null; // } // // /** // * 根据营业执照获取众创需要的企业资料 // * // * @param businessCode // * @return // * @throws Exception // */ // public static UuzcUserSpaceDetail getUuzcUserSpaceDetail(String businessCode) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(saveUrl)) { // ResponseWrap response = HttpUtil.doGet(saveUrl + "/uuzcSpace" , new ModelMap("businessCode", businessCode)); // if (!response.isSuccess()) // throw new Exception(response.getContent()); // else { // return JSONObject.parseObject(response.getContent(), UuzcUserSpaceDetail.class); // } // } // return null; // } // // /** // * 判断当前企业是否设置了hr // * // * @param businessCode // * @return // * @throws Exception // */ // public static String getHrAccount(String businessCode) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(saveUrl)) { // ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrcount" , new ModelMap("businessCode", businessCode)); // if (!response.isSuccess()) // throw new Exception(response.getContent()); // else { // return response.getContent(); // } // } // return null; // } // // /** // * 获取当前企业的HR信息 // * // * @param businessCode // * @return // * @throws Exception // */ // public static User getHrInfo(String businessCode) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(saveUrl)) { // ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrInfo" , new ModelMap("businessCode", businessCode)); // if (!response.isSuccess()) // throw new Exception(response.getContent()); // else { // return JSONObject.parseObject(response.getContent(), User.class); // } // } // return null; // } // // /** // * 获取当前企业人员账号信息 // * // * @param businessCode // * @return // * @throws Exception // */ // public static List getEmployees(String businessCode) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // saveUrl = saveUrl + "/employees"; // if (!StringUtils.isEmpty(saveUrl)) { // ResponseWrap response = HttpUtil.doPost(saveUrl, new ModelMap("businessCode", businessCode)); // if (!response.isSuccess()) // throw new Exception(response.getContent()); // else { // return JSON.parseArray(response.getContent(), User.class); // } // } // return null; // } // // /** // * 保存用户密保问题 // * @param questions // * @throws Exception // */ // public static void saveUserQuestions(List questions) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // saveUrl = saveUrl + "/save/question"; // if (!StringUtils.isEmpty(saveUrl)) { // ResponseWrap res = HttpUtil.doPost(saveUrl, new ModelMap("question", questions)); // if (!res.isSuccess()) { // throw new Exception(res.getContent()); // } // } // } // // /** // * 保存用户密保问题 // * @param userQuestion // * @throws Exception // */ // public static void saveUserQuestion(UserQuestion userQuestion) throws Exception { // String saveUrl = AccountConfig.getUserSaveUrl(); // saveUrl = saveUrl + "/save/question"; // if (!StringUtils.isEmpty(saveUrl)) { // JSONObject formData = JSON.parseObject(JSON.toJSONString(userQuestion)); // formData.put("_count", "one"); // ResponseWrap res = HttpUtil.doPost(saveUrl, formData); // if (!res.isSuccess()) { // throw new Exception(res.getContent()); // } // } // } // // /** // * 根据imId获取用户userUU(没有则返回null) // */ // public static User getUserByImId (Long imId) throws Exception { // String url = AccountConfig.getUserSaveUrl(); // User result = null; // if (!StringUtils.isEmpty(url)) { // ResponseWrap res = HttpUtil.doGet(url, // new ModelMap("_operate", "getUserByImId") // .addAttribute("imId", imId)); // if (!res.isSuccess()) // throw new Exception(res.getContent()); // else // result = JSON.parseObject(res.getContent(), User.class); // } // return result; // } // // /** // * 根据营业执照号分页查找该企业的用户 // * @param businessCode // * @param pageNumber // * @param pageSize // * @return // * @throws Exception // */ // public Page findUsersByBusinessCode(String businessCode, int pageNumber, int pageSize) throws Exception { // String url = AccountConfig.getUserSaveUrl(); // if (!StringUtils.isEmpty(url)) { // url = url + "/findByBusinessCode"; // String appId = SSOHelper.getSSOService().getConfig().getAppName(); // ModelMap data = new ModelMap(); // data.put("businessCode", businessCode); // data.put("appId", appId); // data.put("pageNumber", pageNumber); // data.put("pageSize", pageSize); // ResponseWrap res = HttpUtil.doGet(url, data); // if (!res.isSuccess()) { // throw new Exception(res.getContent()); // } else { // return JSON.parseObject(res.getContent(), new TypeReference>() {}); // } // } // return null; // } }