AccountUtils.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. package com.uas.sso.util;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.uas.sso.AccountConfig;
  5. import com.uas.sso.ResultWrap;
  6. import com.uas.sso.common.util.HttpUtil;
  7. import com.uas.sso.entity.UserSpaceView;
  8. import com.uas.sso.entity.UserView;
  9. import org.springframework.ui.ModelMap;
  10. import org.springframework.util.StringUtils;
  11. /**
  12. * 客户端使用,操作企业资料、用户资料
  13. *
  14. * @author yingp
  15. *
  16. */
  17. public class AccountUtils {
  18. /**
  19. * 企业解除绑定的应用
  20. *
  21. * @author wangmh
  22. * @date 2018/1/26 16:34
  23. * @param spaceUU 企业uu号
  24. * @param appId 应用id
  25. * @throws Exception
  26. */
  27. public static void unbindApp(Long spaceUU, String appId) throws Exception {
  28. String saveUrl = AccountConfig.getSpaceSaveUrl();
  29. if (!StringUtils.isEmpty(saveUrl)) {
  30. ModelMap formData = new ModelMap();
  31. formData.put("_operate", "unbind");
  32. formData.put("spaceUU", spaceUU);
  33. formData.put("appId", appId);
  34. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  35. if (!res.isSuccess()) {
  36. throw new Exception(res.getContent());
  37. } else {
  38. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  39. if (!result.isSuccess()) {
  40. throw new Exception(result.getErrMsg());
  41. }
  42. }
  43. }
  44. }
  45. /**
  46. * 企业开通应用
  47. * @param spaceUU 企业uu号
  48. * @param appId 应用id
  49. * @throws Exception
  50. */
  51. public static void bindApp(Long spaceUU, String appId) throws Exception {
  52. String saveUrl = AccountConfig.getSpaceSaveUrl();
  53. if (!StringUtils.isEmpty(saveUrl)) {
  54. ModelMap formData = new ModelMap();
  55. formData.put("_operate", "bind");
  56. formData.put("spaceUU", spaceUU);
  57. formData.put("appId", appId);
  58. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  59. if (!res.isSuccess()) {
  60. throw new Exception(res.getContent());
  61. } else {
  62. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  63. if (!result.isSuccess()) {
  64. throw new Exception(result.getErrMsg());
  65. }
  66. }
  67. }
  68. }
  69. /**
  70. * 用户解除绑定企业
  71. * @param userUU 用户uu号
  72. * @param spaceUU 企业uu号
  73. * @throws Exception
  74. */
  75. public static void unbindUserSpace(Long userUU, Long spaceUU) throws Exception {
  76. String saveUrl = AccountConfig.getUserSaveUrl();
  77. if (!StringUtils.isEmpty(saveUrl)) {
  78. ModelMap formData = new ModelMap();
  79. formData.put("_operate", "unbind");
  80. formData.put("userUU", userUU);
  81. formData.put("spaceUU", spaceUU);
  82. HttpUtil.ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  83. if (!res.isSuccess()) {
  84. throw new Exception(res.getContent());
  85. } else {
  86. ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  87. if (!result.isSuccess()) {
  88. throw new Exception(result.getErrMsg());
  89. }
  90. }
  91. }
  92. }
  93. /// 之后方法会恢复并修改
  94. //
  95. // /**
  96. // * 获取校验码
  97. // *
  98. // * @param username
  99. // * 手机号或邮箱地址
  100. // * @return
  101. // */
  102. // public static void sendValidCode(String username) throws Exception {
  103. // String saveUrl = AccountConfig.getUserSaveUrl();
  104. // if (!StringUtils.isEmpty(saveUrl)) {
  105. // ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "getVcode").addAttribute("username", username));
  106. // if (!res.isSuccess())
  107. // throw new Exception(res.getContent());
  108. // else {
  109. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  110. // if (!result.isSuccess())
  111. // throw new Exception(result.getErrMsg());
  112. // }
  113. // }
  114. // }
  115. //
  116. // /**
  117. // * 验证校验码
  118. // *
  119. // * @param username
  120. // * 手机号或邮箱地址
  121. // * @param validCode
  122. // * 校验码
  123. // * @return
  124. // */
  125. // public static boolean checkValidCode(String username, String validCode) throws Exception {
  126. // String saveUrl = AccountConfig.getUserSaveUrl();
  127. // if (!StringUtils.isEmpty(saveUrl)) {
  128. // ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "checkVcode").addAttribute("username", username)
  129. // .addAttribute("validCode", validCode));
  130. // if (!res.isSuccess())
  131. // throw new Exception(res.getContent());
  132. // else {
  133. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  134. // if (!result.isSuccess())
  135. // throw new Exception(result.getErrMsg());
  136. // else
  137. // return true;
  138. // }
  139. // }
  140. // return false;
  141. // }
  142. //
  143. // public static String getAccessToken(String appId, String spaceDialectUID, String uid) throws Exception {
  144. // String saveUrl = AccountConfig.getUserSaveUrl();
  145. // if (!StringUtils.isEmpty(saveUrl)) {
  146. // saveUrl = saveUrl + "/getToken";
  147. // JSONObject formData = new JSONObject();
  148. // formData.put("appId", appId);
  149. // formData.put("spaceDialectUID", spaceDialectUID);
  150. // formData.put("uid", uid);
  151. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  152. // if (!res.isSuccess()) {
  153. // throw new Exception(res.getContent());
  154. // } else {
  155. // return res.getContent();
  156. // }
  157. // }
  158. // return null;
  159. // }
  160. //
  161. // /**
  162. // * 验证密码,返回绑定身份信息的token
  163. // *
  164. // * @return
  165. // */
  166. // public static String getAccessToken(User user) throws Exception {
  167. // String saveUrl = AccountConfig.getUserSaveUrl();
  168. // if (!StringUtils.isEmpty(saveUrl)) {
  169. // JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
  170. // formData.put("_operate", "getToken");
  171. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  172. // if (!res.isSuccess())
  173. // throw new Exception(res.getContent());
  174. // else {
  175. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  176. // if (!result.isSuccess())
  177. // throw new Exception(result.getErrMsg());
  178. // else
  179. // return String.valueOf(result.getContent());
  180. // }
  181. // }
  182. // return null;
  183. // }
  184. //
  185. // /**
  186. // * 验证token,返回当前应用相关的身份信息
  187. // *
  188. // * @return
  189. // */
  190. // public static UserView checkAccessToken(String token) throws Exception {
  191. // String saveUrl = AccountConfig.getUserSaveUrl();
  192. // if (!StringUtils.isEmpty(saveUrl)) {
  193. // ResponseWrap res = HttpUtil.doGet(
  194. // saveUrl,
  195. // new ModelMap("_operate", "checkToken").addAttribute("token", token).addAttribute("appId",
  196. // SSOHelper.getSSOService().getConfig().getAppName()));
  197. // if (!res.isSuccess())
  198. // throw new Exception(res.getContent());
  199. // else {
  200. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  201. // if (!result.isSuccess())
  202. // throw new Exception(result.getErrMsg());
  203. // else
  204. // return JSON.parseObject(JSON.toJSONString(result.getContent()), UserView.class);
  205. // }
  206. // }
  207. // return null;
  208. // }
  209. //
  210. // /**
  211. // * 用token验证登录
  212. // *
  213. // * @param request
  214. // * @param response
  215. // * @param token
  216. // * @throws Exception
  217. // */
  218. // public static UserView loginByAccessToken(HttpServletRequest request, HttpServletResponse response, String token) throws Exception {
  219. // UserView user = checkAccessToken(token);
  220. // if (null != user) {
  221. // SSOToken st = new SSOToken(request, user.getUid());
  222. // st.setData(JSON.toJSONString(user));
  223. // SSOHelper.setSSOCookie(request, response, st, true);
  224. // }
  225. // return user;
  226. // }
  227. //
  228. // /**
  229. // * 传入当前登录的企业的营业执照号,查询发出的申请
  230. // *
  231. // * @param businessCode
  232. // * @param statusCode
  233. // * @param keyword
  234. // * @param pageNumber
  235. // * @param pageSize
  236. // * @return
  237. // * @throws Exception
  238. // */
  239. // public static Page<PartnershipRecord> getAllRequest(String businessCode, Integer statusCode, String keyword, int pageNumber,
  240. // int pageSize) throws Exception {
  241. // String getUrl = AccountConfig.getEnPartnersUrl();
  242. // if (!StringUtils.isEmpty(getUrl)) {
  243. // ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequest").addAttribute("businessCode", businessCode)
  244. // .addAttribute("statusCode", statusCode).addAttribute("businessCode", businessCode).addAttribute("keyword", keyword)
  245. // .addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize));
  246. // if (!res.isSuccess())
  247. // throw new Exception(res.getContent());
  248. // return JSONObject.parseObject(res.getContent(), new TypeReference<Page<PartnershipRecord>>() {
  249. // });
  250. // }
  251. // return null;
  252. // }
  253. //
  254. // /**
  255. // * 通过已存在uu过滤,取出全部合作伙伴(UAS接口用)
  256. // * @param businessCode
  257. // * @param statusCode
  258. // * @param keyword
  259. // * @param pageNumber
  260. // * @param pageSize
  261. // * @param partnerUUs
  262. // * @return
  263. // */
  264. // public static Page<PartnershipRecord> getRequestFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, List<Long> partnerUUs, int pageNumber, int pageSize) throws Exception {
  265. // String getUrl = AccountConfig.getEnPartnersUrl();
  266. // if (!StringUtils.isEmpty(getUrl)) {
  267. // ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequestFilterByPartnerUUs").addAttribute("businessCode", businessCode)
  268. // .addAttribute("statusCode", statusCode).addAttribute("keyword", keyword).addAttribute("partnerUUs", JSON.toJSON(partnerUUs))
  269. // .addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize));
  270. // if (!res.isSuccess())
  271. // throw new Exception(res.getContent());
  272. // return JSON.parseObject(res.getContent(), new TypeReference<Page<PartnershipRecord>>() {
  273. // });
  274. // }
  275. // return null;
  276. // }
  277. //
  278. // /**
  279. // * 进入企业圈
  280. // *
  281. // * @return
  282. // * @throws Exception
  283. // */
  284. // public static String redirectContactPage() throws Exception {
  285. // String enterUrl = AccountConfig.getContactPageUrl();
  286. // return enterUrl;
  287. // }
  288. //
  289. // /**
  290. // * 通过关键词搜索企业信息
  291. // *
  292. // * @param keyword
  293. // * @return
  294. // * @throws Exception
  295. // */
  296. // public static Page<UserSpaceDetail> getUserSpacesByKeyword(String keyword, int pageNumber, int pageSize) throws Exception {
  297. // String Url = AccountConfig.getEnPartnersUrl();
  298. // if (!StringUtils.isEmpty(Url)) {
  299. // ResponseWrap res = HttpUtil.doGet(Url,
  300. // new ModelMap("_operate", "getUserSpaces").addAttribute("keyword", keyword).addAttribute("pageNumber", pageNumber)
  301. // .addAttribute("pageSize", pageSize));
  302. // if (!res.isSuccess())
  303. // throw new Exception(res.getContent());
  304. // return JSON.parseObject(res.getContent(), new TypeReference<Page<UserSpaceDetail>>() {
  305. // });
  306. // }
  307. // return null;
  308. // }
  309. //
  310. // /**
  311. // * 通过手机号搜索用户账号信息
  312. // *
  313. // * @param uid
  314. // * @return
  315. // * @throws Exception
  316. // */
  317. // public static List<User> getUserInfoByUid(String uid) throws Exception {
  318. // String Url = AccountConfig.getSpaceSaveUrl();
  319. // if (!StringUtils.isEmpty(Url)) {
  320. // ResponseWrap res = HttpUtil.doGet(Url + "/userInfo",
  321. // new ModelMap("uid", uid));
  322. // if (!res.isSuccess())
  323. // throw new Exception(res.getContent());
  324. // String resText = res.getContent();
  325. // JSONObject object = JSON.parseObject(resText);
  326. // String contentText = object.getString("content");
  327. // return JSON.parseArray(contentText, User.class);
  328. // }
  329. // return null;
  330. // }
  331. //
  332. // /**
  333. // * 通过营业执照号获取企业应用
  334. // *
  335. // * @param uid
  336. // * @return
  337. // * @throws Exception
  338. // */
  339. // public static List<UserSpace> getUserSpaceByUid(String uid) throws Exception {
  340. // String Url = AccountConfig.getSpaceSaveUrl();
  341. // if (!StringUtils.isEmpty(Url)) {
  342. // ResponseWrap res = HttpUtil.doGet(Url + "/" + uid);
  343. // if (!res.isSuccess())
  344. // throw new Exception(res.getContent());
  345. // String resText = res.getContent();
  346. // JSONObject object = JSON.parseObject(resText);
  347. // String contentText = object.getString("content");
  348. // return JSON.parseArray(contentText, UserSpace.class);
  349. // }
  350. // return null;
  351. // }
  352. //
  353. // /**
  354. // * 新增一条合作关系记录
  355. // *
  356. // * @param record
  357. // * @return
  358. // * @throws Exception
  359. // */
  360. // public static String addNewRecord(PartnershipRecord record) throws Exception {
  361. // String url = AccountConfig.getEnPartnersUrl();
  362. // String result = null;
  363. // if (!StringUtils.isEmpty(url)) {
  364. // JSONObject formData = JSON.parseObject(JSON.toJSONString(record));
  365. // formData.put("_operate", "addPartner");
  366. // ResponseWrap res = HttpUtil.doPost(url, formData);
  367. // result = res.getContent();
  368. // }
  369. // return result;
  370. // }
  371. //
  372. // /**
  373. // * 同步供应商关系为合作关系记录
  374. // *
  375. // * @param record
  376. // * @return
  377. // * @throws Exception
  378. // */
  379. // public static String synchronizeRecord(PartnershipRecord record) throws Exception {
  380. // String url = AccountConfig.getEnPartnersUrl();
  381. // String result = null;
  382. // if (!StringUtils.isEmpty(url)) {
  383. // JSONObject formData = JSON.parseObject(JSON.toJSONString(record));
  384. // formData.put("_operate", "synchronizePartner");
  385. // ResponseWrap res = HttpUtil.doPost(url, formData);
  386. // result = res.getContent();
  387. // }
  388. // return result;
  389. // }
  390. //
  391. // /**
  392. // * 通过id和申请人的电话进行确认
  393. // *
  394. // * @param id
  395. // * @param vendUserTel
  396. // * @param appId
  397. // * @return
  398. // * @throws Exception
  399. // */
  400. // public static String acceptRequest(Long id, String vendUserTel, String appId) throws Exception {
  401. // String url = AccountConfig.getEnPartnersUrl();
  402. // String result = null;
  403. // if (!StringUtils.isEmpty(url)) {
  404. // ResponseWrap res = HttpUtil.doGet(
  405. // url,
  406. // new ModelMap("_operate", "acceptRequest").addAttribute("id", id).addAttribute("vendUserTel", vendUserTel)
  407. // .addAttribute("appId", appId));
  408. // if (!res.isSuccess())
  409. // throw new Exception(res.getContent());
  410. // else {
  411. // result = res.getContent();
  412. // }
  413. // }
  414. // return result;
  415. // }
  416. //
  417. // /**
  418. // * 申请不通过,通过申请人的电话操作,并标出原因
  419. // *
  420. // * @param id
  421. // * @param reason
  422. // * @param vendUserTel
  423. // * @param appId
  424. // * @return
  425. // * @throws Exception
  426. // */
  427. // public static String rejectRequest(Long id, String reason, String vendUserTel, String appId) throws Exception {
  428. // String url = AccountConfig.getEnPartnersUrl();
  429. // String result = null;
  430. // if (!StringUtils.isEmpty(url)) {
  431. // ResponseWrap res = HttpUtil.doGet(
  432. // url,
  433. // new ModelMap("_operate", "rejectRequest").addAttribute("id", id).addAttribute("reason", reason)
  434. // .addAttribute("vendUserTel", vendUserTel).addAttribute("appId", appId));
  435. // if (!res.isSuccess())
  436. // throw new Exception(res.getContent());
  437. // else {
  438. // result = res.getContent();
  439. // }
  440. // }
  441. // return result;
  442. // }
  443. //
  444. // /**
  445. // * 通过当前企业号和企业列表中的企业号查询申请状态
  446. // *
  447. // * @return
  448. // * @throws Exception
  449. // */
  450. // public static RequsetStatus getStatusByCustUidAndVendUid(String custUid, String vendUid) throws Exception {
  451. // String url = AccountConfig.getEnPartnersUrl();
  452. // RequsetStatus request = new RequsetStatus();
  453. // if (!StringUtils.isEmpty(url)) {
  454. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "getRequestStatus").addAttribute("custUid", custUid)
  455. // .addAttribute("vendUid", vendUid));
  456. // if (!res.isSuccess())
  457. // throw new Exception(res.getContent());
  458. // else {
  459. // request = JSON.parseObject(res.getContent(), RequsetStatus.class);
  460. // }
  461. // }
  462. // return request;
  463. // }
  464. //
  465. // /**
  466. // * 搜索词通过id返回数据
  467. // *
  468. // * @param ids
  469. // * @return
  470. // * @throws Exception
  471. // */
  472. // public static List<UserSpaceDetail> findAll(String ids) throws Exception {
  473. // String url = AccountConfig.getEnPartnersUrl();
  474. // List<UserSpaceDetail> details = new ArrayList<UserSpaceDetail>();
  475. // if (!StringUtils.isEmpty(url)) {
  476. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "findAll").addAttribute("ids", ids));
  477. // if(!res.isSuccess())
  478. // throw new Exception(res.getContent());
  479. // else
  480. // details = JSONObject.parseArray(res.getContent(), UserSpaceDetail.class);
  481. // }
  482. // return details;
  483. // }
  484. //
  485. // /**
  486. // * 通过企业营业执照查询收到的待处理的请求
  487. // *
  488. // * @param businessCode
  489. // * @return
  490. // * @throws Exception
  491. // */
  492. // public static String getRequestTodo(String businessCode) throws Exception {
  493. // String url = AccountConfig.getEnPartnersUrl();
  494. // String result = null;
  495. // if (!StringUtils.isEmpty(url)) {
  496. // ResponseWrap res = HttpUtil.doGet(url,
  497. // new ModelMap("_operate", "getRequestTodo").addAttribute("businessCode", businessCode));
  498. // if (!res.isSuccess())
  499. // throw new Exception(res.getContent());
  500. // else
  501. // result = res.getContent();
  502. // }
  503. // return result;
  504. // }
  505. //
  506. // /**
  507. // * 其他应用发起邀请注册,同步数据
  508. // *
  509. // * @param jsonStr
  510. // * @throws Exception
  511. // */
  512. // public static void synchroInvitation(String jsonStr) throws Exception {
  513. // String url = AccountConfig.getEnPartnersUrl();
  514. // if (!StringUtils.isEmpty(url)) {
  515. // HttpUtil.doPost(url, new ModelMap("_operate", "invitation").addAttribute("jsonStr", jsonStr));
  516. // }
  517. // }
  518. //
  519. // /**
  520. // * ERP、SAAS新开账套名称校验
  521. // *
  522. // * @param name
  523. // * @return
  524. // * @throws Exception
  525. // */
  526. // public static String validName(String name) throws Exception {
  527. // String result = null;
  528. // String url = AccountConfig.getSpaceSaveUrl();
  529. // if (!StringUtils.isEmpty(url)) {
  530. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "validName").addAttribute("name", name),
  531. // 50);
  532. // if (!res.isSuccess())
  533. // throw new Exception(res.getContent());
  534. // else
  535. // result = res.getContent();
  536. // }
  537. // return result;
  538. // }
  539. //
  540. // /**
  541. // * ERP、SAAS新开账套名称校验
  542. // *
  543. // * @param businessCode
  544. // * @return
  545. // * @throws Exception
  546. // */
  547. // public static String validBusinessCode(String businessCode) throws Exception {
  548. // String result = null;
  549. // String url = AccountConfig.getSpaceSaveUrl();
  550. // if (!StringUtils.isEmpty(url)) {
  551. // ResponseWrap res = HttpUtil.doGet(url,
  552. // new ModelMap("_operate", "validBusinessCode").addAttribute("businessCode", businessCode), 50);
  553. // if (!res.isSuccess())
  554. // throw new Exception(res.getContent());
  555. // else
  556. // result = res.getContent();
  557. // }
  558. // return result;
  559. // }
  560. //
  561. // /**
  562. // * 通过营业执照号查找 企业详细信息
  563. // *
  564. // * @param
  565. // * @return
  566. // * @throws Exception
  567. // */
  568. // public static UserSpaceDetail findByBusinessCode(String businessCode) throws Exception {
  569. // String result = null;
  570. // String url = AccountConfig.getSpaceSaveUrl();
  571. // if (!StringUtils.isEmpty(url)) {
  572. // ResponseWrap res = HttpUtil.doGet(url,
  573. // new ModelMap("_operate", "findByBusinessCode").addAttribute("businessCode", businessCode), 50);
  574. // if (!res.isSuccess())
  575. // throw new Exception(res.getContent());
  576. // else
  577. // result = res.getContent();
  578. // }
  579. // return JSON.parseObject(result,UserSpaceDetail.class);
  580. // }
  581. //
  582. // /**
  583. // * ERP、SAAS新开账套
  584. // *
  585. // * @param userSpaceDetail
  586. // * @param users
  587. // * @throws Exception
  588. // */
  589. // public static String applyApp(UserSpaceDetail userSpaceDetail, List<UserDetail> users) throws Exception {
  590. // String url = AccountConfig.getSpaceSaveUrl();
  591. // String result = null;
  592. // if (!StringUtils.isEmpty(url)) {
  593. // ResponseWrap res = HttpUtil.doPost(url, new ModelMap("_operate", "registerBranchAccount")
  594. // .addAttribute("detail", JSON.toJSON(userSpaceDetail))
  595. // .addAttribute("userInfos", JSON.toJSON(users)));
  596. // if (!res.isSuccess())
  597. // throw new Exception(res.getContent());
  598. // else
  599. // result = res.getContent();
  600. // }
  601. // return result;
  602. // }
  603. //
  604. // /**
  605. // * 商城个人账号增加企业注册
  606. // *
  607. // * @param userSpaceDetail
  608. // * @throws Exception
  609. // */
  610. // public static String applyAppForMall(UserSpaceDetail userSpaceDetail) throws Exception {
  611. // String url = AccountConfig.getSpaceSaveUrl();
  612. // String result = null;
  613. // if (!StringUtils.isEmpty(url)) {
  614. // ResponseWrap res = HttpUtil.doPost(url,
  615. // new ModelMap("_operate", "registForMall")
  616. // .addAttribute("detail", JSON.toJSON(userSpaceDetail)));
  617. // if (!res.isSuccess())
  618. // throw new Exception(res.getContent());
  619. // else
  620. // result = res.getContent();
  621. // }
  622. // return result;
  623. // }
  624. //
  625. // /**
  626. // * 设置hr账号
  627. // *
  628. // * @param user
  629. // * @param detail
  630. // * @return
  631. // * @throws Exception
  632. // */
  633. // public static String setHrAccount(User user, UuzcUserSpaceDetail detail) throws Exception {
  634. // String saveUrl = AccountConfig.getUserSaveUrl();
  635. // saveUrl = saveUrl + "/setHrAccount";
  636. // if (!StringUtils.isEmpty(saveUrl)) {
  637. // JSONObject formData = new JSONObject();
  638. // if (detail != null) {
  639. // formData = JSON.parseObject(JSON.toJSONString(detail));
  640. // }
  641. // if (null != user) {
  642. // formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
  643. // }
  644. // ResponseWrap response = HttpUtil.doPost(saveUrl, formData);
  645. // if (!response.isSuccess())
  646. // throw new Exception(response.getContent());
  647. // else {
  648. // return response.getContent();
  649. // }
  650. // }
  651. // return null;
  652. // }
  653. //
  654. // /**
  655. // * 根据营业执照获取众创需要的企业资料
  656. // *
  657. // * @param businessCode
  658. // * @return
  659. // * @throws Exception
  660. // */
  661. // public static UuzcUserSpaceDetail getUuzcUserSpaceDetail(String businessCode) throws Exception {
  662. // String saveUrl = AccountConfig.getUserSaveUrl();
  663. // if (!StringUtils.isEmpty(saveUrl)) {
  664. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/uuzcSpace" , new ModelMap("businessCode", businessCode));
  665. // if (!response.isSuccess())
  666. // throw new Exception(response.getContent());
  667. // else {
  668. // return JSONObject.parseObject(response.getContent(), UuzcUserSpaceDetail.class);
  669. // }
  670. // }
  671. // return null;
  672. // }
  673. //
  674. // /**
  675. // * 判断当前企业是否设置了hr
  676. // *
  677. // * @param businessCode
  678. // * @return
  679. // * @throws Exception
  680. // */
  681. // public static String getHrAccount(String businessCode) throws Exception {
  682. // String saveUrl = AccountConfig.getUserSaveUrl();
  683. // if (!StringUtils.isEmpty(saveUrl)) {
  684. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrcount" , new ModelMap("businessCode", businessCode));
  685. // if (!response.isSuccess())
  686. // throw new Exception(response.getContent());
  687. // else {
  688. // return response.getContent();
  689. // }
  690. // }
  691. // return null;
  692. // }
  693. //
  694. // /**
  695. // * 获取当前企业的HR信息
  696. // *
  697. // * @param businessCode
  698. // * @return
  699. // * @throws Exception
  700. // */
  701. // public static User getHrInfo(String businessCode) throws Exception {
  702. // String saveUrl = AccountConfig.getUserSaveUrl();
  703. // if (!StringUtils.isEmpty(saveUrl)) {
  704. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrInfo" , new ModelMap("businessCode", businessCode));
  705. // if (!response.isSuccess())
  706. // throw new Exception(response.getContent());
  707. // else {
  708. // return JSONObject.parseObject(response.getContent(), User.class);
  709. // }
  710. // }
  711. // return null;
  712. // }
  713. //
  714. // /**
  715. // * 获取当前企业人员账号信息
  716. // *
  717. // * @param businessCode
  718. // * @return
  719. // * @throws Exception
  720. // */
  721. // public static List<User> getEmployees(String businessCode) throws Exception {
  722. // String saveUrl = AccountConfig.getUserSaveUrl();
  723. // saveUrl = saveUrl + "/employees";
  724. // if (!StringUtils.isEmpty(saveUrl)) {
  725. // ResponseWrap response = HttpUtil.doPost(saveUrl, new ModelMap("businessCode", businessCode));
  726. // if (!response.isSuccess())
  727. // throw new Exception(response.getContent());
  728. // else {
  729. // return JSON.parseArray(response.getContent(), User.class);
  730. // }
  731. // }
  732. // return null;
  733. // }
  734. //
  735. // /**
  736. // * 保存用户密保问题
  737. // * @param questions
  738. // * @throws Exception
  739. // */
  740. // public static void saveUserQuestions(List<UserQuestion> questions) throws Exception {
  741. // String saveUrl = AccountConfig.getUserSaveUrl();
  742. // saveUrl = saveUrl + "/save/question";
  743. // if (!StringUtils.isEmpty(saveUrl)) {
  744. // ResponseWrap res = HttpUtil.doPost(saveUrl, new ModelMap("question", questions));
  745. // if (!res.isSuccess()) {
  746. // throw new Exception(res.getContent());
  747. // }
  748. // }
  749. // }
  750. //
  751. // /**
  752. // * 保存用户密保问题
  753. // * @param userQuestion
  754. // * @throws Exception
  755. // */
  756. // public static void saveUserQuestion(UserQuestion userQuestion) throws Exception {
  757. // String saveUrl = AccountConfig.getUserSaveUrl();
  758. // saveUrl = saveUrl + "/save/question";
  759. // if (!StringUtils.isEmpty(saveUrl)) {
  760. // JSONObject formData = JSON.parseObject(JSON.toJSONString(userQuestion));
  761. // formData.put("_count", "one");
  762. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  763. // if (!res.isSuccess()) {
  764. // throw new Exception(res.getContent());
  765. // }
  766. // }
  767. // }
  768. //
  769. // /**
  770. // * 根据imId获取用户userUU(没有则返回null)
  771. // */
  772. // public static User getUserByImId (Long imId) throws Exception {
  773. // String url = AccountConfig.getUserSaveUrl();
  774. // User result = null;
  775. // if (!StringUtils.isEmpty(url)) {
  776. // ResponseWrap res = HttpUtil.doGet(url,
  777. // new ModelMap("_operate", "getUserByImId")
  778. // .addAttribute("imId", imId));
  779. // if (!res.isSuccess())
  780. // throw new Exception(res.getContent());
  781. // else
  782. // result = JSON.parseObject(res.getContent(), User.class);
  783. // }
  784. // return result;
  785. // }
  786. //
  787. // /**
  788. // * 根据营业执照号分页查找该企业的用户
  789. // * @param businessCode
  790. // * @param pageNumber
  791. // * @param pageSize
  792. // * @return
  793. // * @throws Exception
  794. // */
  795. // public Page<User> findUsersByBusinessCode(String businessCode, int pageNumber, int pageSize) throws Exception {
  796. // String url = AccountConfig.getUserSaveUrl();
  797. // if (!StringUtils.isEmpty(url)) {
  798. // url = url + "/findByBusinessCode";
  799. // String appId = SSOHelper.getSSOService().getConfig().getAppName();
  800. // ModelMap data = new ModelMap();
  801. // data.put("businessCode", businessCode);
  802. // data.put("appId", appId);
  803. // data.put("pageNumber", pageNumber);
  804. // data.put("pageSize", pageSize);
  805. // ResponseWrap res = HttpUtil.doGet(url, data);
  806. // if (!res.isSuccess()) {
  807. // throw new Exception(res.getContent());
  808. // } else {
  809. // return JSON.parseObject(res.getContent(), new TypeReference<Page<User>>() {});
  810. // }
  811. // }
  812. // return null;
  813. // }
  814. }