AccountUtils.java 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167
  1. package com.uas.sso.util;
  2. /**
  3. * 客户端使用,操作企业资料、用户资料
  4. *
  5. * @author yingp
  6. *
  7. */
  8. public class AccountUtils {
  9. /// 之后方法会恢复并修改
  10. // /**
  11. // * 修改用户信息
  12. // *
  13. // * @param user
  14. // * @param userDetail
  15. // * @return
  16. // * @throws Exception
  17. // */
  18. // public static List<User> saveUser(User user, UserDetail userDetail) throws Exception {
  19. // String saveUrl = AccountConfig.getUserSaveUrl();
  20. // if (!StringUtils.isEmpty(saveUrl)) {
  21. // JSONObject formData = new JSONObject();
  22. // if (userDetail != null) {
  23. // formData = JSON.parseObject(JSON.toJSONString(userDetail));
  24. // }
  25. // if (user != null) {
  26. // if (user.getUid() == null) {
  27. // user.setUid(userDetail.getMobile());
  28. // }
  29. // if (user.getSecondUID() == null) {
  30. // user.setSecondUID(userDetail.getEmail());
  31. // }
  32. // if (user.getAppId() != null && user.getDialectUID() != null) {
  33. // if (user.getAppId().equals("b2b") || user.getAppId().equals("mall")) {
  34. // user.setSalt(user.getDialectUID());
  35. // }
  36. // }
  37. // formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
  38. // }
  39. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  40. // if (!res.isSuccess())
  41. // throw new Exception(res.getContent());
  42. // else {
  43. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  44. // if (result.isError()) {
  45. // throw new Exception(result.getErrMsg());
  46. // } else {
  47. // return JSON.parseArray(JSON.toJSONString(result.getContent()), User.class);
  48. // }
  49. // }
  50. // }
  51. // return null;
  52. // }
  53. //
  54. // /**
  55. // * 修改用户信息
  56. // *
  57. // * @param dialectUID
  58. // * 个人唯一标识
  59. // * @param spaceDialectUID
  60. // * 企业唯一标识
  61. // * @param userDetail
  62. // * 个人详细信息
  63. // * @return
  64. // * @throws Exception
  65. // */
  66. // public static List<User> saveUser(Object dialectUID, Object spaceDialectUID, UserDetail userDetail) throws Exception {
  67. // User user = new User();
  68. // user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
  69. // user.setDialectUID(dialectUID.toString());
  70. // if (spaceDialectUID != null) {
  71. // user.setSpaceDialectUID(spaceDialectUID.toString());
  72. // }
  73. // return saveUser(user, userDetail);
  74. // }
  75. //
  76. // /**
  77. // * 保存与当前应用无关的用户信息,借用appId=sso
  78. // *
  79. // * @param uid
  80. // * @param spaceUID
  81. // * @param userDetail
  82. // * @return
  83. // * @throws Exception
  84. // */
  85. // public static List<User> saveCustUser(Object uid, Object spaceUID, UserDetail userDetail) throws Exception {
  86. // User user = new User();
  87. // user.setAppId(AccountConfig.ACCOUNT_CENTER);
  88. // user.setDialectUID(uid.toString());
  89. // user.setSpaceUID(spaceUID.toString());
  90. // return saveUser(user, userDetail);
  91. // }
  92. //
  93. // /**
  94. // * 添加用户信息
  95. // *
  96. // * @param dialectUID
  97. // * 个人唯一标识
  98. // * @param spaceDialectUID
  99. // * 企业唯一标识
  100. // * @param userDetail
  101. // * 个人详细信息
  102. // * @param noEncryPwd
  103. // * 明文密码
  104. // * @return
  105. // * @throws Exception
  106. // */
  107. // public static List<User> addUser(Object dialectUID, Object spaceDialectUID, UserDetail userDetail, String noEncryPwd) throws Exception {
  108. // User user = new User();
  109. // user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
  110. // user.setDialectUID(dialectUID.toString());
  111. // if (spaceDialectUID != null) {
  112. // user.setSpaceDialectUID(spaceDialectUID.toString());
  113. // }
  114. // user.setPassword(noEncryPwd);
  115. // return saveUser(user, userDetail);
  116. // }
  117. //
  118. // /**
  119. // * 修改手机号
  120. // * @param oldTel
  121. // * @param newTel
  122. // * @return
  123. // * @throws Exception
  124. // */
  125. // public static List<User> updateTel (String oldTel, String newTel) throws Exception {
  126. // String saveUrl = AccountConfig.getUserSaveUrl();
  127. // if (!StringUtils.isEmpty(saveUrl)) {
  128. // saveUrl = saveUrl + "/updateTel";
  129. // JSONObject formData = new JSONObject();
  130. // formData.put("oldTel", oldTel);
  131. // formData.put("newTel", newTel);
  132. // formData.put("appId", SSOHelper.getSSOService().getConfig().getAppName());
  133. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  134. // if (!res.isSuccess()) {
  135. // throw new Exception(res.getContent());
  136. // } else {
  137. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  138. // if (result.isError()) {
  139. // throw new Exception(result.getErrMsg());
  140. // } else {
  141. // return JSON.parseArray(JSON.toJSONString(result.getContent()), User.class);
  142. // }
  143. // }
  144. // }
  145. // return null;
  146. // }
  147. //
  148. // /**
  149. // * 修改邮箱
  150. // * @param oldTel
  151. // * @param newEmail
  152. // * @return
  153. // * @throws Exception
  154. // */
  155. // public static List<User> updateEmail (String oldTel, String newEmail) throws Exception {
  156. // String saveUrl = AccountConfig.getUserSaveUrl();
  157. // if (!StringUtils.isEmpty(saveUrl)) {
  158. // saveUrl = saveUrl + "/updateEmail";
  159. // JSONObject formData = new JSONObject();
  160. // formData.put("oldTel", oldTel);
  161. // formData.put("newEmail", newEmail);
  162. // formData.put("appId", SSOHelper.getSSOService().getConfig().getAppName());
  163. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  164. // if (!res.isSuccess()) {
  165. // throw new Exception(res.getContent());
  166. // } else {
  167. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  168. // if (result.isError()) {
  169. // throw new Exception(result.getErrMsg());
  170. // } else {
  171. // return JSON.parseArray(JSON.toJSONString(result.getContent()), User.class);
  172. // }
  173. // }
  174. // }
  175. // return null;
  176. // }
  177. //
  178. // public static List<UserSpace> saveUserSpace(UserSpace space, UserSpaceDetail spaceDetail) throws Exception {
  179. // String saveUrl = AccountConfig.getSpaceSaveUrl();
  180. // if (!StringUtils.isEmpty(saveUrl)) {
  181. // JSONObject formData = new JSONObject();
  182. // if (spaceDetail != null) {
  183. // formData = JSON.parseObject(JSON.toJSONString(spaceDetail));
  184. // }
  185. // if (space != null) {
  186. // if (space.getUid() == null) {
  187. // space.setUid(spaceDetail.getBusinessCode());
  188. // }
  189. // formData.putAll(JSON.parseObject(JSON.toJSONString(space)));
  190. // }
  191. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  192. // if (!res.isSuccess())
  193. // throw new Exception(res.getContent());
  194. // else {
  195. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  196. // if (result.isError()) {
  197. // throw new Exception(result.getErrMsg());
  198. // } else {
  199. // return JSON.parseArray(JSON.toJSONString(result.getContent()), UserSpace.class);
  200. // }
  201. // }
  202. // }
  203. // return null;
  204. // }
  205. //
  206. // public static List<UserSpace> saveUserSpace(Object dialectUID, UserSpaceDetail spaceDetail) throws Exception {
  207. // UserSpace userSpace = new UserSpace();
  208. // userSpace.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
  209. // userSpace.setDialectUID(dialectUID.toString());
  210. // return saveUserSpace(userSpace, spaceDetail);
  211. // }
  212. //
  213. // /**
  214. // * 解除绑定的应用
  215. // *
  216. // * @param userSpace
  217. // * @throws Exception
  218. // */
  219. // public static void unbindUserSpace(UserSpace userSpace) throws Exception {
  220. // String saveUrl = AccountConfig.getSpaceSaveUrl();
  221. // if (!StringUtils.isEmpty(saveUrl)) {
  222. // JSONObject formData = JSON.parseObject(JSON.toJSONString(userSpace));
  223. // formData.put("_operate", "unbind");
  224. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  225. // if (!res.isSuccess())
  226. // throw new Exception(res.getContent());
  227. // }
  228. // }
  229. //
  230. // /**
  231. // * 解除绑定的应用
  232. // *
  233. // * @param uid
  234. // * @throws Exception
  235. // */
  236. // public static void unbindUserSpace(String uid) throws Exception {
  237. // unbindUserSpace(SSOHelper.getSSOService().getConfig().getAppName(), uid);
  238. // }
  239. //
  240. // /**
  241. // * 解除绑定的应用
  242. // *
  243. // * @param appId
  244. // * @param uid
  245. // * @throws Exception
  246. // */
  247. // public static void unbindUserSpace(String appId, String uid) throws Exception {
  248. // UserSpace userSpace = new UserSpace();
  249. // userSpace.setAppId(appId);
  250. // userSpace.setUid(uid);
  251. // unbindUserSpace(userSpace);
  252. // }
  253. //
  254. // /**
  255. // * 解除绑定的云账号
  256. // *
  257. // * @param user
  258. // * @throws Exception
  259. // */
  260. // public static void unbindUser(User user) throws Exception {
  261. // String saveUrl = AccountConfig.getUserSaveUrl();
  262. // if (!StringUtils.isEmpty(saveUrl)) {
  263. // JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
  264. // formData.put("_operate", "unbind");
  265. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  266. // if (!res.isSuccess())
  267. // throw new Exception(res.getContent());
  268. // }
  269. // }
  270. //
  271. // /**
  272. // * 解除绑定的云账号
  273. // *
  274. // * @param dialectUID
  275. // * @param spaceDialectUID
  276. // * @throws Exception
  277. // */
  278. // public static void unbindUser(Object dialectUID, Object spaceDialectUID) throws Exception {
  279. // User user = new User();
  280. // user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
  281. // user.setDialectUID(dialectUID.toString());
  282. // if (spaceDialectUID != null) {
  283. // user.setSpaceDialectUID(spaceDialectUID.toString());
  284. // }
  285. // unbindUser(user);
  286. // }
  287. //
  288. // /**
  289. // * 校验密码
  290. // *
  291. // * @param user
  292. // * @throws Exception
  293. // */
  294. // public static boolean checkPassword(User user) throws Exception {
  295. // String saveUrl = AccountConfig.getUserSaveUrl();
  296. // if (!StringUtils.isEmpty(saveUrl)) {
  297. // JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
  298. // formData.put("_operate", "check");
  299. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  300. // if (!res.isSuccess())
  301. // throw new Exception(res.getContent());
  302. // else {
  303. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  304. // if (!result.isSuccess())
  305. // throw new Exception(result.getErrMsg());
  306. // else
  307. // return true;
  308. // }
  309. // }
  310. // return false;
  311. // }
  312. //
  313. // /**
  314. // * 校验密码
  315. // *
  316. // * @param dialectUID
  317. // * @param spaceDialectUID
  318. // * @param password
  319. // * @throws Exception
  320. // */
  321. // public static boolean checkPassword(Object dialectUID, Object spaceDialectUID, String password) throws Exception {
  322. // User user = new User();
  323. // user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
  324. // user.setDialectUID(dialectUID.toString());
  325. // if (spaceDialectUID != null) {
  326. // user.setSpaceDialectUID(spaceDialectUID.toString());
  327. // }
  328. // user.setPassword(password);
  329. // return checkPassword(user);
  330. // }
  331. //
  332. // /**
  333. // * 校验密码
  334. // *
  335. // * <pre>
  336. // * 全匹配模式
  337. // * </pre>
  338. // *
  339. // * @param user
  340. // * @throws Exception
  341. // */
  342. // public static boolean fuzzyCheckPassword(User user) throws Exception {
  343. // String saveUrl = AccountConfig.getUserSaveUrl();
  344. // if (!StringUtils.isEmpty(saveUrl)) {
  345. // JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
  346. // formData.put("_operate", "fuzzyCheck");
  347. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  348. // if (!res.isSuccess())
  349. // throw new Exception(res.getContent());
  350. // else {
  351. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  352. // if (!result.isSuccess())
  353. // throw new Exception(result.getErrMsg());
  354. // else
  355. // return true;
  356. // }
  357. // }
  358. // return false;
  359. // }
  360. //
  361. // /**
  362. // * 校验密码
  363. // *
  364. // * <pre>
  365. // * 全匹配模式
  366. // * </pre>
  367. // *
  368. // * @param dialectUID
  369. // * @param spaceDialectUID
  370. // * @param password
  371. // * @throws Exception
  372. // */
  373. // public static boolean fuzzyCheckPassword(Object dialectUID, Object spaceDialectUID, String password) throws Exception {
  374. // User user = new User();
  375. // user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
  376. // user.setDialectUID(dialectUID.toString());
  377. // if (spaceDialectUID != null) {
  378. // user.setSpaceDialectUID(spaceDialectUID.toString());
  379. // }
  380. // user.setPassword(password);
  381. // return fuzzyCheckPassword(user);
  382. // }
  383. //
  384. // /**
  385. // * 重置密码
  386. // *
  387. // * @param user
  388. // * @throws Exception
  389. // */
  390. // public static void resetPassword(User user) throws Exception {
  391. // String saveUrl = AccountConfig.getUserSaveUrl();
  392. //// saveUrl = saveUrl + "/resetPwd";
  393. // if (!StringUtils.isEmpty(saveUrl)) {
  394. // JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
  395. // formData.put("_operate", "reset");
  396. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  397. // if (!res.isSuccess())
  398. // throw new Exception(res.getContent());
  399. // else {
  400. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  401. // if (!result.isSuccess())
  402. // throw new Exception(result.getErrMsg());
  403. // }
  404. // }
  405. // }
  406. //
  407. // /**
  408. // * 重置密码
  409. // *
  410. // * @param dialectUID
  411. // * 应用自己的用户唯一标识
  412. // * @param spaceDialectUID
  413. // * 企业唯一标识
  414. // * @param noEncryPwd
  415. // * 新密码(明文)
  416. // * @throws Exception
  417. // */
  418. // public static void resetPassword(Object dialectUID, Object spaceDialectUID, String noEncryPwd) throws Exception {
  419. // User user = new User();
  420. // user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
  421. // user.setDialectUID(dialectUID.toString());
  422. // if (spaceDialectUID != null) {
  423. // user.setSpaceDialectUID(spaceDialectUID.toString());
  424. // }
  425. // user.setPassword(noEncryPwd);
  426. // resetPassword(user);
  427. // }
  428. //
  429. // /**
  430. // * 重置密码
  431. // *
  432. // * @param mobile
  433. // * 手机号
  434. // * @param noEncryPwd
  435. // * 新密码(明文)
  436. // * @throws Exception
  437. // */
  438. // public static void resetPassword(String mobile, String noEncryPwd) throws Exception {
  439. // User user = new User();
  440. // user.setAppId(SSOHelper.getSSOService().getConfig().getAppName());
  441. // user.setUid(mobile);
  442. // user.setPassword(noEncryPwd);
  443. // resetPassword(user);
  444. // }
  445. //
  446. // /**
  447. // * 获取校验码
  448. // *
  449. // * @param username
  450. // * 手机号或邮箱地址
  451. // * @return
  452. // */
  453. // public static void sendValidCode(String username) throws Exception {
  454. // String saveUrl = AccountConfig.getUserSaveUrl();
  455. // if (!StringUtils.isEmpty(saveUrl)) {
  456. // ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "getVcode").addAttribute("username", username));
  457. // if (!res.isSuccess())
  458. // throw new Exception(res.getContent());
  459. // else {
  460. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  461. // if (!result.isSuccess())
  462. // throw new Exception(result.getErrMsg());
  463. // }
  464. // }
  465. // }
  466. //
  467. // /**
  468. // * 验证校验码
  469. // *
  470. // * @param username
  471. // * 手机号或邮箱地址
  472. // * @param validCode
  473. // * 校验码
  474. // * @return
  475. // */
  476. // public static boolean checkValidCode(String username, String validCode) throws Exception {
  477. // String saveUrl = AccountConfig.getUserSaveUrl();
  478. // if (!StringUtils.isEmpty(saveUrl)) {
  479. // ResponseWrap res = HttpUtil.doGet(saveUrl, new ModelMap("_operate", "checkVcode").addAttribute("username", username)
  480. // .addAttribute("validCode", validCode));
  481. // if (!res.isSuccess())
  482. // throw new Exception(res.getContent());
  483. // else {
  484. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  485. // if (!result.isSuccess())
  486. // throw new Exception(result.getErrMsg());
  487. // else
  488. // return true;
  489. // }
  490. // }
  491. // return false;
  492. // }
  493. //
  494. // public static String getAccessToken(String appId, String spaceDialectUID, String uid) throws Exception {
  495. // String saveUrl = AccountConfig.getUserSaveUrl();
  496. // if (!StringUtils.isEmpty(saveUrl)) {
  497. // saveUrl = saveUrl + "/getToken";
  498. // JSONObject formData = new JSONObject();
  499. // formData.put("appId", appId);
  500. // formData.put("spaceDialectUID", spaceDialectUID);
  501. // formData.put("uid", uid);
  502. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  503. // if (!res.isSuccess()) {
  504. // throw new Exception(res.getContent());
  505. // } else {
  506. // return res.getContent();
  507. // }
  508. // }
  509. // return null;
  510. // }
  511. //
  512. // /**
  513. // * 验证密码,返回绑定身份信息的token
  514. // *
  515. // * @return
  516. // */
  517. // public static String getAccessToken(User user) throws Exception {
  518. // String saveUrl = AccountConfig.getUserSaveUrl();
  519. // if (!StringUtils.isEmpty(saveUrl)) {
  520. // JSONObject formData = JSON.parseObject(JSON.toJSONString(user));
  521. // formData.put("_operate", "getToken");
  522. // ResponseWrap res = HttpUtil.doGet(saveUrl, formData);
  523. // if (!res.isSuccess())
  524. // throw new Exception(res.getContent());
  525. // else {
  526. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  527. // if (!result.isSuccess())
  528. // throw new Exception(result.getErrMsg());
  529. // else
  530. // return String.valueOf(result.getContent());
  531. // }
  532. // }
  533. // return null;
  534. // }
  535. //
  536. // /**
  537. // * 验证token,返回当前应用相关的身份信息
  538. // *
  539. // * @return
  540. // */
  541. // public static UserView checkAccessToken(String token) throws Exception {
  542. // String saveUrl = AccountConfig.getUserSaveUrl();
  543. // if (!StringUtils.isEmpty(saveUrl)) {
  544. // ResponseWrap res = HttpUtil.doGet(
  545. // saveUrl,
  546. // new ModelMap("_operate", "checkToken").addAttribute("token", token).addAttribute("appId",
  547. // SSOHelper.getSSOService().getConfig().getAppName()));
  548. // if (!res.isSuccess())
  549. // throw new Exception(res.getContent());
  550. // else {
  551. // ResultWrap result = JSON.parseObject(res.getContent(), ResultWrap.class);
  552. // if (!result.isSuccess())
  553. // throw new Exception(result.getErrMsg());
  554. // else
  555. // return JSON.parseObject(JSON.toJSONString(result.getContent()), UserView.class);
  556. // }
  557. // }
  558. // return null;
  559. // }
  560. //
  561. // /**
  562. // * 用token验证登录
  563. // *
  564. // * @param request
  565. // * @param response
  566. // * @param token
  567. // * @throws Exception
  568. // */
  569. // public static UserView loginByAccessToken(HttpServletRequest request, HttpServletResponse response, String token) throws Exception {
  570. // UserView user = checkAccessToken(token);
  571. // if (null != user) {
  572. // SSOToken st = new SSOToken(request, user.getUid());
  573. // st.setData(JSON.toJSONString(user));
  574. // SSOHelper.setSSOCookie(request, response, st, true);
  575. // }
  576. // return user;
  577. // }
  578. //
  579. // /**
  580. // * 传入当前登录的企业的营业执照号,查询发出的申请
  581. // *
  582. // * @param businessCode
  583. // * @param statusCode
  584. // * @param keyword
  585. // * @param pageNumber
  586. // * @param pageSize
  587. // * @return
  588. // * @throws Exception
  589. // */
  590. // public static Page<PartnershipRecord> getAllRequest(String businessCode, Integer statusCode, String keyword, int pageNumber,
  591. // int pageSize) throws Exception {
  592. // String getUrl = AccountConfig.getEnPartnersUrl();
  593. // if (!StringUtils.isEmpty(getUrl)) {
  594. // ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequest").addAttribute("businessCode", businessCode)
  595. // .addAttribute("statusCode", statusCode).addAttribute("businessCode", businessCode).addAttribute("keyword", keyword)
  596. // .addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize));
  597. // if (!res.isSuccess())
  598. // throw new Exception(res.getContent());
  599. // return JSONObject.parseObject(res.getContent(), new TypeReference<Page<PartnershipRecord>>() {
  600. // });
  601. // }
  602. // return null;
  603. // }
  604. //
  605. // /**
  606. // * 通过已存在uu过滤,取出全部合作伙伴(UAS接口用)
  607. // * @param businessCode
  608. // * @param statusCode
  609. // * @param keyword
  610. // * @param pageNumber
  611. // * @param pageSize
  612. // * @param partnerUUs
  613. // * @return
  614. // */
  615. // public static Page<PartnershipRecord> getRequestFilterByPartnerUUs(String businessCode, Integer statusCode, String keyword, List<Long> partnerUUs, int pageNumber, int pageSize) throws Exception {
  616. // String getUrl = AccountConfig.getEnPartnersUrl();
  617. // if (!StringUtils.isEmpty(getUrl)) {
  618. // ResponseWrap res = HttpUtil.doGet(getUrl, new ModelMap("_operate", "getAllRequestFilterByPartnerUUs").addAttribute("businessCode", businessCode)
  619. // .addAttribute("statusCode", statusCode).addAttribute("keyword", keyword).addAttribute("partnerUUs", JSON.toJSON(partnerUUs))
  620. // .addAttribute("pageNumber", pageNumber).addAttribute("pageSize", pageSize));
  621. // if (!res.isSuccess())
  622. // throw new Exception(res.getContent());
  623. // return JSON.parseObject(res.getContent(), new TypeReference<Page<PartnershipRecord>>() {
  624. // });
  625. // }
  626. // return null;
  627. // }
  628. //
  629. // /**
  630. // * 进入企业圈
  631. // *
  632. // * @return
  633. // * @throws Exception
  634. // */
  635. // public static String redirectContactPage() throws Exception {
  636. // String enterUrl = AccountConfig.getContactPageUrl();
  637. // return enterUrl;
  638. // }
  639. //
  640. // /**
  641. // * 通过关键词搜索企业信息
  642. // *
  643. // * @param keyword
  644. // * @return
  645. // * @throws Exception
  646. // */
  647. // public static Page<UserSpaceDetail> getUserSpacesByKeyword(String keyword, int pageNumber, int pageSize) throws Exception {
  648. // String Url = AccountConfig.getEnPartnersUrl();
  649. // if (!StringUtils.isEmpty(Url)) {
  650. // ResponseWrap res = HttpUtil.doGet(Url,
  651. // new ModelMap("_operate", "getUserSpaces").addAttribute("keyword", keyword).addAttribute("pageNumber", pageNumber)
  652. // .addAttribute("pageSize", pageSize));
  653. // if (!res.isSuccess())
  654. // throw new Exception(res.getContent());
  655. // return JSON.parseObject(res.getContent(), new TypeReference<Page<UserSpaceDetail>>() {
  656. // });
  657. // }
  658. // return null;
  659. // }
  660. //
  661. // /**
  662. // * 通过手机号搜索用户账号信息
  663. // *
  664. // * @param uid
  665. // * @return
  666. // * @throws Exception
  667. // */
  668. // public static List<User> getUserInfoByUid(String uid) throws Exception {
  669. // String Url = AccountConfig.getSpaceSaveUrl();
  670. // if (!StringUtils.isEmpty(Url)) {
  671. // ResponseWrap res = HttpUtil.doGet(Url + "/userInfo",
  672. // new ModelMap("uid", uid));
  673. // if (!res.isSuccess())
  674. // throw new Exception(res.getContent());
  675. // String resText = res.getContent();
  676. // JSONObject object = JSON.parseObject(resText);
  677. // String contentText = object.getString("content");
  678. // return JSON.parseArray(contentText, User.class);
  679. // }
  680. // return null;
  681. // }
  682. //
  683. // /**
  684. // * 通过营业执照号获取企业应用
  685. // *
  686. // * @param uid
  687. // * @return
  688. // * @throws Exception
  689. // */
  690. // public static List<UserSpace> getUserSpaceByUid(String uid) throws Exception {
  691. // String Url = AccountConfig.getSpaceSaveUrl();
  692. // if (!StringUtils.isEmpty(Url)) {
  693. // ResponseWrap res = HttpUtil.doGet(Url + "/" + uid);
  694. // if (!res.isSuccess())
  695. // throw new Exception(res.getContent());
  696. // String resText = res.getContent();
  697. // JSONObject object = JSON.parseObject(resText);
  698. // String contentText = object.getString("content");
  699. // return JSON.parseArray(contentText, UserSpace.class);
  700. // }
  701. // return null;
  702. // }
  703. //
  704. // /**
  705. // * 新增一条合作关系记录
  706. // *
  707. // * @param record
  708. // * @return
  709. // * @throws Exception
  710. // */
  711. // public static String addNewRecord(PartnershipRecord record) throws Exception {
  712. // String url = AccountConfig.getEnPartnersUrl();
  713. // String result = null;
  714. // if (!StringUtils.isEmpty(url)) {
  715. // JSONObject formData = JSON.parseObject(JSON.toJSONString(record));
  716. // formData.put("_operate", "addPartner");
  717. // ResponseWrap res = HttpUtil.doPost(url, formData);
  718. // result = res.getContent();
  719. // }
  720. // return result;
  721. // }
  722. //
  723. // /**
  724. // * 同步供应商关系为合作关系记录
  725. // *
  726. // * @param record
  727. // * @return
  728. // * @throws Exception
  729. // */
  730. // public static String synchronizeRecord(PartnershipRecord record) throws Exception {
  731. // String url = AccountConfig.getEnPartnersUrl();
  732. // String result = null;
  733. // if (!StringUtils.isEmpty(url)) {
  734. // JSONObject formData = JSON.parseObject(JSON.toJSONString(record));
  735. // formData.put("_operate", "synchronizePartner");
  736. // ResponseWrap res = HttpUtil.doPost(url, formData);
  737. // result = res.getContent();
  738. // }
  739. // return result;
  740. // }
  741. //
  742. // /**
  743. // * 通过id和申请人的电话进行确认
  744. // *
  745. // * @param id
  746. // * @param vendUserTel
  747. // * @param appId
  748. // * @return
  749. // * @throws Exception
  750. // */
  751. // public static String acceptRequest(Long id, String vendUserTel, String appId) throws Exception {
  752. // String url = AccountConfig.getEnPartnersUrl();
  753. // String result = null;
  754. // if (!StringUtils.isEmpty(url)) {
  755. // ResponseWrap res = HttpUtil.doGet(
  756. // url,
  757. // new ModelMap("_operate", "acceptRequest").addAttribute("id", id).addAttribute("vendUserTel", vendUserTel)
  758. // .addAttribute("appId", appId));
  759. // if (!res.isSuccess())
  760. // throw new Exception(res.getContent());
  761. // else {
  762. // result = res.getContent();
  763. // }
  764. // }
  765. // return result;
  766. // }
  767. //
  768. // /**
  769. // * 申请不通过,通过申请人的电话操作,并标出原因
  770. // *
  771. // * @param id
  772. // * @param reason
  773. // * @param vendUserTel
  774. // * @param appId
  775. // * @return
  776. // * @throws Exception
  777. // */
  778. // public static String rejectRequest(Long id, String reason, String vendUserTel, String appId) throws Exception {
  779. // String url = AccountConfig.getEnPartnersUrl();
  780. // String result = null;
  781. // if (!StringUtils.isEmpty(url)) {
  782. // ResponseWrap res = HttpUtil.doGet(
  783. // url,
  784. // new ModelMap("_operate", "rejectRequest").addAttribute("id", id).addAttribute("reason", reason)
  785. // .addAttribute("vendUserTel", vendUserTel).addAttribute("appId", appId));
  786. // if (!res.isSuccess())
  787. // throw new Exception(res.getContent());
  788. // else {
  789. // result = res.getContent();
  790. // }
  791. // }
  792. // return result;
  793. // }
  794. //
  795. // /**
  796. // * 通过当前企业号和企业列表中的企业号查询申请状态
  797. // *
  798. // * @return
  799. // * @throws Exception
  800. // */
  801. // public static RequsetStatus getStatusByCustUidAndVendUid(String custUid, String vendUid) throws Exception {
  802. // String url = AccountConfig.getEnPartnersUrl();
  803. // RequsetStatus request = new RequsetStatus();
  804. // if (!StringUtils.isEmpty(url)) {
  805. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "getRequestStatus").addAttribute("custUid", custUid)
  806. // .addAttribute("vendUid", vendUid));
  807. // if (!res.isSuccess())
  808. // throw new Exception(res.getContent());
  809. // else {
  810. // request = JSON.parseObject(res.getContent(), RequsetStatus.class);
  811. // }
  812. // }
  813. // return request;
  814. // }
  815. //
  816. // /**
  817. // * 搜索词通过id返回数据
  818. // *
  819. // * @param ids
  820. // * @return
  821. // * @throws Exception
  822. // */
  823. // public static List<UserSpaceDetail> findAll(String ids) throws Exception {
  824. // String url = AccountConfig.getEnPartnersUrl();
  825. // List<UserSpaceDetail> details = new ArrayList<UserSpaceDetail>();
  826. // if (!StringUtils.isEmpty(url)) {
  827. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "findAll").addAttribute("ids", ids));
  828. // if(!res.isSuccess())
  829. // throw new Exception(res.getContent());
  830. // else
  831. // details = JSONObject.parseArray(res.getContent(), UserSpaceDetail.class);
  832. // }
  833. // return details;
  834. // }
  835. //
  836. // /**
  837. // * 通过企业营业执照查询收到的待处理的请求
  838. // *
  839. // * @param businessCode
  840. // * @return
  841. // * @throws Exception
  842. // */
  843. // public static String getRequestTodo(String businessCode) throws Exception {
  844. // String url = AccountConfig.getEnPartnersUrl();
  845. // String result = null;
  846. // if (!StringUtils.isEmpty(url)) {
  847. // ResponseWrap res = HttpUtil.doGet(url,
  848. // new ModelMap("_operate", "getRequestTodo").addAttribute("businessCode", businessCode));
  849. // if (!res.isSuccess())
  850. // throw new Exception(res.getContent());
  851. // else
  852. // result = res.getContent();
  853. // }
  854. // return result;
  855. // }
  856. //
  857. // /**
  858. // * 其他应用发起邀请注册,同步数据
  859. // *
  860. // * @param jsonStr
  861. // * @throws Exception
  862. // */
  863. // public static void synchroInvitation(String jsonStr) throws Exception {
  864. // String url = AccountConfig.getEnPartnersUrl();
  865. // if (!StringUtils.isEmpty(url)) {
  866. // HttpUtil.doPost(url, new ModelMap("_operate", "invitation").addAttribute("jsonStr", jsonStr));
  867. // }
  868. // }
  869. //
  870. // /**
  871. // * ERP、SAAS新开账套名称校验
  872. // *
  873. // * @param name
  874. // * @return
  875. // * @throws Exception
  876. // */
  877. // public static String validName(String name) throws Exception {
  878. // String result = null;
  879. // String url = AccountConfig.getSpaceSaveUrl();
  880. // if (!StringUtils.isEmpty(url)) {
  881. // ResponseWrap res = HttpUtil.doGet(url, new ModelMap("_operate", "validName").addAttribute("name", name),
  882. // 50);
  883. // if (!res.isSuccess())
  884. // throw new Exception(res.getContent());
  885. // else
  886. // result = res.getContent();
  887. // }
  888. // return result;
  889. // }
  890. //
  891. // /**
  892. // * ERP、SAAS新开账套名称校验
  893. // *
  894. // * @param businessCode
  895. // * @return
  896. // * @throws Exception
  897. // */
  898. // public static String validBusinessCode(String businessCode) throws Exception {
  899. // String result = null;
  900. // String url = AccountConfig.getSpaceSaveUrl();
  901. // if (!StringUtils.isEmpty(url)) {
  902. // ResponseWrap res = HttpUtil.doGet(url,
  903. // new ModelMap("_operate", "validBusinessCode").addAttribute("businessCode", businessCode), 50);
  904. // if (!res.isSuccess())
  905. // throw new Exception(res.getContent());
  906. // else
  907. // result = res.getContent();
  908. // }
  909. // return result;
  910. // }
  911. //
  912. // /**
  913. // * 通过营业执照号查找 企业详细信息
  914. // *
  915. // * @param
  916. // * @return
  917. // * @throws Exception
  918. // */
  919. // public static UserSpaceDetail findByBusinessCode(String businessCode) throws Exception {
  920. // String result = null;
  921. // String url = AccountConfig.getSpaceSaveUrl();
  922. // if (!StringUtils.isEmpty(url)) {
  923. // ResponseWrap res = HttpUtil.doGet(url,
  924. // new ModelMap("_operate", "findByBusinessCode").addAttribute("businessCode", businessCode), 50);
  925. // if (!res.isSuccess())
  926. // throw new Exception(res.getContent());
  927. // else
  928. // result = res.getContent();
  929. // }
  930. // return JSON.parseObject(result,UserSpaceDetail.class);
  931. // }
  932. //
  933. // /**
  934. // * ERP、SAAS新开账套
  935. // *
  936. // * @param userSpaceDetail
  937. // * @param users
  938. // * @throws Exception
  939. // */
  940. // public static String applyApp(UserSpaceDetail userSpaceDetail, List<UserDetail> users) throws Exception {
  941. // String url = AccountConfig.getSpaceSaveUrl();
  942. // String result = null;
  943. // if (!StringUtils.isEmpty(url)) {
  944. // ResponseWrap res = HttpUtil.doPost(url, new ModelMap("_operate", "registerBranchAccount")
  945. // .addAttribute("detail", JSON.toJSON(userSpaceDetail))
  946. // .addAttribute("userInfos", JSON.toJSON(users)));
  947. // if (!res.isSuccess())
  948. // throw new Exception(res.getContent());
  949. // else
  950. // result = res.getContent();
  951. // }
  952. // return result;
  953. // }
  954. //
  955. // /**
  956. // * 商城个人账号增加企业注册
  957. // *
  958. // * @param userSpaceDetail
  959. // * @throws Exception
  960. // */
  961. // public static String applyAppForMall(UserSpaceDetail userSpaceDetail) throws Exception {
  962. // String url = AccountConfig.getSpaceSaveUrl();
  963. // String result = null;
  964. // if (!StringUtils.isEmpty(url)) {
  965. // ResponseWrap res = HttpUtil.doPost(url,
  966. // new ModelMap("_operate", "registForMall")
  967. // .addAttribute("detail", JSON.toJSON(userSpaceDetail)));
  968. // if (!res.isSuccess())
  969. // throw new Exception(res.getContent());
  970. // else
  971. // result = res.getContent();
  972. // }
  973. // return result;
  974. // }
  975. //
  976. // /**
  977. // * 设置hr账号
  978. // *
  979. // * @param user
  980. // * @param detail
  981. // * @return
  982. // * @throws Exception
  983. // */
  984. // public static String setHrAccount(User user, UuzcUserSpaceDetail detail) throws Exception {
  985. // String saveUrl = AccountConfig.getUserSaveUrl();
  986. // saveUrl = saveUrl + "/setHrAccount";
  987. // if (!StringUtils.isEmpty(saveUrl)) {
  988. // JSONObject formData = new JSONObject();
  989. // if (detail != null) {
  990. // formData = JSON.parseObject(JSON.toJSONString(detail));
  991. // }
  992. // if (null != user) {
  993. // formData.putAll(JSON.parseObject(JSON.toJSONString(user)));
  994. // }
  995. // ResponseWrap response = HttpUtil.doPost(saveUrl, formData);
  996. // if (!response.isSuccess())
  997. // throw new Exception(response.getContent());
  998. // else {
  999. // return response.getContent();
  1000. // }
  1001. // }
  1002. // return null;
  1003. // }
  1004. //
  1005. // /**
  1006. // * 根据营业执照获取众创需要的企业资料
  1007. // *
  1008. // * @param businessCode
  1009. // * @return
  1010. // * @throws Exception
  1011. // */
  1012. // public static UuzcUserSpaceDetail getUuzcUserSpaceDetail(String businessCode) throws Exception {
  1013. // String saveUrl = AccountConfig.getUserSaveUrl();
  1014. // if (!StringUtils.isEmpty(saveUrl)) {
  1015. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/uuzcSpace" , new ModelMap("businessCode", businessCode));
  1016. // if (!response.isSuccess())
  1017. // throw new Exception(response.getContent());
  1018. // else {
  1019. // return JSONObject.parseObject(response.getContent(), UuzcUserSpaceDetail.class);
  1020. // }
  1021. // }
  1022. // return null;
  1023. // }
  1024. //
  1025. // /**
  1026. // * 判断当前企业是否设置了hr
  1027. // *
  1028. // * @param businessCode
  1029. // * @return
  1030. // * @throws Exception
  1031. // */
  1032. // public static String getHrAccount(String businessCode) throws Exception {
  1033. // String saveUrl = AccountConfig.getUserSaveUrl();
  1034. // if (!StringUtils.isEmpty(saveUrl)) {
  1035. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrcount" , new ModelMap("businessCode", businessCode));
  1036. // if (!response.isSuccess())
  1037. // throw new Exception(response.getContent());
  1038. // else {
  1039. // return response.getContent();
  1040. // }
  1041. // }
  1042. // return null;
  1043. // }
  1044. //
  1045. // /**
  1046. // * 获取当前企业的HR信息
  1047. // *
  1048. // * @param businessCode
  1049. // * @return
  1050. // * @throws Exception
  1051. // */
  1052. // public static User getHrInfo(String businessCode) throws Exception {
  1053. // String saveUrl = AccountConfig.getUserSaveUrl();
  1054. // if (!StringUtils.isEmpty(saveUrl)) {
  1055. // ResponseWrap response = HttpUtil.doGet(saveUrl + "/hrInfo" , new ModelMap("businessCode", businessCode));
  1056. // if (!response.isSuccess())
  1057. // throw new Exception(response.getContent());
  1058. // else {
  1059. // return JSONObject.parseObject(response.getContent(), User.class);
  1060. // }
  1061. // }
  1062. // return null;
  1063. // }
  1064. //
  1065. // /**
  1066. // * 获取当前企业人员账号信息
  1067. // *
  1068. // * @param businessCode
  1069. // * @return
  1070. // * @throws Exception
  1071. // */
  1072. // public static List<User> getEmployees(String businessCode) throws Exception {
  1073. // String saveUrl = AccountConfig.getUserSaveUrl();
  1074. // saveUrl = saveUrl + "/employees";
  1075. // if (!StringUtils.isEmpty(saveUrl)) {
  1076. // ResponseWrap response = HttpUtil.doPost(saveUrl, new ModelMap("businessCode", businessCode));
  1077. // if (!response.isSuccess())
  1078. // throw new Exception(response.getContent());
  1079. // else {
  1080. // return JSON.parseArray(response.getContent(), User.class);
  1081. // }
  1082. // }
  1083. // return null;
  1084. // }
  1085. //
  1086. // /**
  1087. // * 保存用户密保问题
  1088. // * @param questions
  1089. // * @throws Exception
  1090. // */
  1091. // public static void saveUserQuestions(List<UserQuestion> questions) throws Exception {
  1092. // String saveUrl = AccountConfig.getUserSaveUrl();
  1093. // saveUrl = saveUrl + "/save/question";
  1094. // if (!StringUtils.isEmpty(saveUrl)) {
  1095. // ResponseWrap res = HttpUtil.doPost(saveUrl, new ModelMap("question", questions));
  1096. // if (!res.isSuccess()) {
  1097. // throw new Exception(res.getContent());
  1098. // }
  1099. // }
  1100. // }
  1101. //
  1102. // /**
  1103. // * 保存用户密保问题
  1104. // * @param userQuestion
  1105. // * @throws Exception
  1106. // */
  1107. // public static void saveUserQuestion(UserQuestion userQuestion) throws Exception {
  1108. // String saveUrl = AccountConfig.getUserSaveUrl();
  1109. // saveUrl = saveUrl + "/save/question";
  1110. // if (!StringUtils.isEmpty(saveUrl)) {
  1111. // JSONObject formData = JSON.parseObject(JSON.toJSONString(userQuestion));
  1112. // formData.put("_count", "one");
  1113. // ResponseWrap res = HttpUtil.doPost(saveUrl, formData);
  1114. // if (!res.isSuccess()) {
  1115. // throw new Exception(res.getContent());
  1116. // }
  1117. // }
  1118. // }
  1119. //
  1120. // /**
  1121. // * 根据imId获取用户userUU(没有则返回null)
  1122. // */
  1123. // public static User getUserByImId (Long imId) throws Exception {
  1124. // String url = AccountConfig.getUserSaveUrl();
  1125. // User result = null;
  1126. // if (!StringUtils.isEmpty(url)) {
  1127. // ResponseWrap res = HttpUtil.doGet(url,
  1128. // new ModelMap("_operate", "getUserByImId")
  1129. // .addAttribute("imId", imId));
  1130. // if (!res.isSuccess())
  1131. // throw new Exception(res.getContent());
  1132. // else
  1133. // result = JSON.parseObject(res.getContent(), User.class);
  1134. // }
  1135. // return result;
  1136. // }
  1137. //
  1138. // /**
  1139. // * 根据营业执照号分页查找该企业的用户
  1140. // * @param businessCode
  1141. // * @param pageNumber
  1142. // * @param pageSize
  1143. // * @return
  1144. // * @throws Exception
  1145. // */
  1146. // public Page<User> findUsersByBusinessCode(String businessCode, int pageNumber, int pageSize) throws Exception {
  1147. // String url = AccountConfig.getUserSaveUrl();
  1148. // if (!StringUtils.isEmpty(url)) {
  1149. // url = url + "/findByBusinessCode";
  1150. // String appId = SSOHelper.getSSOService().getConfig().getAppName();
  1151. // ModelMap data = new ModelMap();
  1152. // data.put("businessCode", businessCode);
  1153. // data.put("appId", appId);
  1154. // data.put("pageNumber", pageNumber);
  1155. // data.put("pageSize", pageSize);
  1156. // ResponseWrap res = HttpUtil.doGet(url, data);
  1157. // if (!res.isSuccess()) {
  1158. // throw new Exception(res.getContent());
  1159. // } else {
  1160. // return JSON.parseObject(res.getContent(), new TypeReference<Page<User>>() {});
  1161. // }
  1162. // }
  1163. // return null;
  1164. // }
  1165. }