| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108 |
- 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 removeUser(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 userUU 用户uu号
- * @param spaceUU 企业uu号
- * @throws Exception
- */
- public static void addUser(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 businessCode 营业执照号
- * @return
- */
- public UserSpaceView 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.parseObject(result.getContent().toString(), UserSpaceView.class);
- }
- }
- }
- return null;
- }
- /**
- * 根据企业名获得企业信息
- * @param spaceName 企业名
- * @return
- */
- public UserSpaceView 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.parseObject(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<ApplyUserSpaceView> 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<Page<ApplyUserSpaceView>>() {
- });
- }
- }
- }
- return null;
- }
- /**
- * 统计该企业申请记录数量
- * @param spaceUU 企业uu号
- * @return
- * @throws Exception
- */
- public static Map<String, Integer> 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;
- }
- /**
- * 校验密码
- *
- * <pre>
- * 全匹配模式
- * </pre>
- *
- * @param user
- * @throws Exception
- */
- public static boolean fuzzyCheckPassword(UserView user) throws Exception {
- String saveUrl = AccountConfig.getUserSaveUrl();
- if (!StringUtils.isEmpty(saveUrl)) {
- JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
- formData.put("_operate", "fuzzyCheck");
- HttpUtil.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 true;
- }
- }
- }
- return false;
- }
- /// 之后方法会恢复并修改
- //
- // /**
- // * 获取校验码
- // *
- // * @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<PartnershipRecordView> 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<Page<PartnershipRecordView>>() {});
- }
- }
- }
- return null;
- }
- //
- // /**
- // * 通过已存在uu过滤,取出全部合作伙伴(UAS接口用)
- // * @param businessCode
- // * @param statusCode
- // * @param keyword
- // * @param pageNumber
- // * @param pageSize
- // * @param partnerUUs
- // * @return
- // */
- // public static Page<PartnershipRecord> getRequestFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, List<Long> 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<Page<PartnershipRecord>>() {
- // });
- // }
- // 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<UserSpaceDetail> 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<Page<UserSpaceDetail>>() {
- // });
- // }
- // return null;
- // }
- //
- // /**
- // * 通过手机号搜索用户账号信息
- // *
- // * @param uid
- // * @return
- // * @throws Exception
- // */
- // public static List<User> 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<UserSpace> 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;
- }
- // /**
- // * 搜索词通过id返回数据
- // *
- // * @param ids
- // * @return
- // * @throws Exception
- // */
- // public static List<UserSpaceDetail> findAll(String ids) throws Exception {
- // String url = AccountConfig.getEnPartnersUrl();
- // List<UserSpaceDetail> details = new ArrayList<UserSpaceDetail>();
- // 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)) {
- HttpUtil.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)) {
- HttpUtil.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;
- }
- /**
- * ERP、SAAS新开账套
- *
- * @param userSpaceDetail
- * @param users
- * @throws Exception
- */
- public static String applyApp(UserSpaceView userSpaceDetail, List<UserView> users) throws Exception {
- String url = AccountConfig.getSpaceSaveUrl();
- String result = null;
- if (!StringUtils.isEmpty(url)) {
- HttpUtil.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<User> 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<UserQuestion> 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<User> 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<Page<User>>() {});
- // }
- // }
- // return null;
- // }
- }
|