LoginController.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. package jnpf.controller;
  2. import cn.hutool.core.collection.CollectionUtil;
  3. import cn.hutool.core.net.url.UrlBuilder;
  4. import cn.hutool.core.text.StrPool;
  5. import io.swagger.v3.oas.annotations.Operation;
  6. import io.swagger.v3.oas.annotations.Parameter;
  7. import io.swagger.v3.oas.annotations.Parameters;
  8. import io.swagger.v3.oas.annotations.tags.Tag;
  9. import jnpf.base.ActionResult;
  10. import jnpf.base.UserInfo;
  11. import jnpf.base.service.SysconfigService;
  12. import jnpf.config.ConfigValueUtil;
  13. import jnpf.config.JnpfOauthConfig;
  14. import jnpf.constant.JnpfConst;
  15. import jnpf.constant.MsgCode;
  16. import jnpf.constant.PermissionConst;
  17. import jnpf.consts.AuthConsts;
  18. import jnpf.consts.DeviceType;
  19. import jnpf.consts.LoginTicketStatus;
  20. import jnpf.consts.ScanCodeTicketStatus;
  21. import jnpf.database.util.TenantDataSourceUtil;
  22. import jnpf.exception.LoginException;
  23. import jnpf.granter.TokenGranter;
  24. import jnpf.granter.TokenGranterBuilder;
  25. import jnpf.granter.UserDetailsServiceBuilder;
  26. import jnpf.model.*;
  27. import jnpf.model.login.MeInfoVO;
  28. import jnpf.model.login.PcUserVO;
  29. import jnpf.model.login.UserSystemVO;
  30. import jnpf.model.logout.LogoutResultModel;
  31. import jnpf.permission.controller.SocialsUserController;
  32. import jnpf.permission.entity.UserEntity;
  33. import jnpf.permission.model.socails.SocialsUserVo;
  34. import jnpf.permission.service.UserService;
  35. import jnpf.service.AuthService;
  36. import jnpf.service.LogService;
  37. import jnpf.service.LoginService;
  38. import jnpf.util.*;
  39. import lombok.extern.slf4j.Slf4j;
  40. import org.springframework.beans.factory.annotation.Autowired;
  41. import org.springframework.web.bind.annotation.*;
  42. import java.io.IOException;
  43. import java.util.*;
  44. import static jnpf.consts.AuthConsts.PARAMS_JNPF_TICKET;
  45. /**
  46. * 登录控制器
  47. *
  48. * @author JNPF开发平台组
  49. * @version V3.1.0
  50. * @copyright 引迈信息技术有限公司
  51. * @date 2019年9月26日 上午9:18
  52. */
  53. @Tag(name = "登陆数据", description = "oauth")
  54. @Slf4j
  55. @RestController
  56. @RequestMapping("/api/oauth")
  57. public class LoginController {
  58. @Autowired
  59. private UserService userApi;
  60. @Autowired
  61. private LoginService loginService;
  62. @Autowired
  63. private AuthService authService;
  64. @Autowired
  65. private ConfigValueUtil configValueUtil;
  66. @Autowired
  67. private JnpfOauthConfig oauthConfig;
  68. @Autowired
  69. private SysconfigService sysConfigApi;
  70. @Autowired
  71. private RedisUtil redisUtil;
  72. @Autowired
  73. private TokenGranterBuilder tokenGranterBuilder;
  74. @Autowired
  75. private SocialsUserController socialsUserApi;
  76. @Autowired
  77. private UserDetailsServiceBuilder userDetailsServiceBuilder;
  78. @Autowired
  79. private LogService logApi;
  80. /**
  81. * 登陆
  82. *
  83. * @param parameters 登录参数
  84. * @return
  85. * @throws LoginException 登录异常
  86. */
  87. @NoDataSourceBind
  88. @Operation(summary = "登陆")
  89. @Parameters({
  90. @Parameter(name = "parameters", description = "登录参数", required = true)
  91. })
  92. @RequestMapping(value = "/Login/**", method = {RequestMethod.GET, RequestMethod.POST})
  93. public ActionResult<LoginVO> login(@RequestParam Map<String, String> parameters) throws LoginException {
  94. return authService.login(parameters);
  95. }
  96. /**
  97. * 验证密码
  98. *
  99. * @param loginForm 登录模型
  100. * @return
  101. * @throws LoginException 登录异常
  102. */
  103. @Operation(summary = "锁屏解锁登录")
  104. @Parameters({
  105. @Parameter(name = "loginForm", description = "登录模型", required = true)
  106. })
  107. @PostMapping("/LockScreen")
  108. public ActionResult lockScreen(@RequestBody LoginForm loginForm) throws LoginException {
  109. UserEntity userEntity = userApi.getUserByAccount(loginForm.getAccount());
  110. if (userEntity == null) {
  111. UserInfo userInfo = UserProvider.getUser();
  112. if (userInfo.getUserId() != null) {
  113. UserProvider.logoutByUserId(userInfo.getUserId());
  114. }
  115. throw new LoginException(MsgCode.FA001.get());
  116. }
  117. if (!Md5Util.getStringMd5(loginForm.getPassword().toLowerCase() + userEntity.getSecretkey().toLowerCase()).equals(userEntity.getPassword())) {
  118. throw new LoginException(MsgCode.OA020.get());
  119. }
  120. return ActionResult.success(MsgCode.SU005.get());
  121. }
  122. /**
  123. * 登录注销
  124. *
  125. * @param grandtype 登录类型
  126. * @return
  127. */
  128. @NoDataSourceBind
  129. @Operation(summary = "退出")
  130. @Parameters({
  131. @Parameter(name = "grandtype", description = "登录类型", required = true)
  132. })
  133. @RequestMapping(value = {"/Logout", "/Logout/{grandtype}"}, method = {RequestMethod.GET, RequestMethod.POST})
  134. public ActionResult<LogoutResultModel> logout(@PathVariable(value = "grandtype", required = false) String grandtype) {
  135. long millis = System.currentTimeMillis();
  136. TokenGranter tokenGranter = tokenGranterBuilder.getGranterByLogin(grandtype);
  137. if (tokenGranter != null) {
  138. UserInfo userInfo = UserProvider.getUser();
  139. logApi.writeLogAsync(userInfo.getUserId(), userInfo.getUserName() + "/" + userInfo.getUserAccount(), "退出登录", userInfo, 1, 1, (System.currentTimeMillis() - millis));
  140. return tokenGranter.logout();
  141. }
  142. return ActionResult.success();
  143. }
  144. /**
  145. * 踢出指定用户, 推送Websocket用户被强制下线
  146. *
  147. * @param tokens token集合
  148. * @param userId 租户id
  149. * @param tenantId 租户id
  150. */
  151. @NoDataSourceBind
  152. @Operation(summary = "踢出指定用户")
  153. @Parameters({
  154. @Parameter(name = "tokens", description = "token集合"),
  155. @Parameter(name = "userId", description = "租户id"),
  156. @Parameter(name = "tenantId", description = "租户id"),
  157. })
  158. @PostMapping(value = {"/KickoutToken"})
  159. public void kickoutByToken(@RequestParam(value = "tokens", required = false) String[] tokens, @RequestParam(name = "userId", required = false) String userId, @RequestParam(name = "tenantId", required = false) String tenantId) {
  160. if (StringUtil.isNotEmpty(tokens)) {
  161. authService.kickoutByToken(tokens);
  162. } else {
  163. authService.kickoutByUserId(userId, tenantId);
  164. }
  165. }
  166. /**
  167. * 获取用户登录信息
  168. *
  169. * @param type Web/App
  170. * @return
  171. * @throws LoginException 登录异常
  172. */
  173. @Operation(summary = "获取用户登录信息")
  174. @Parameters({
  175. @Parameter(name = "type", description = "Web/App")
  176. })
  177. @GetMapping("/CurrentUser")
  178. public ActionResult<PcUserVO> currentUser(String type, String systemCode, @RequestParam(value = "isBackend", required = false) Integer isBackend) throws LoginException {
  179. type = StringUtil.isEmpty(type) ? JnpfConst.WEB : JnpfConst.APP;
  180. if (!Objects.equals(isBackend, 1)) {
  181. isBackend = 0;
  182. }
  183. UserInfo userInfo = UserProvider.getUser();
  184. if (DeviceType.TEMPUSERLIMITED.getDevice().equals(userInfo.getLoginDevice())) {
  185. throw new LoginException(MsgCode.OA022.get());
  186. }
  187. PcUserVO pcUserVO = loginService.getCurrentUser(type, systemCode, isBackend);
  188. if (pcUserVO == null) {
  189. throw new LoginException(MsgCode.LOG001.get());
  190. }
  191. //自动切身份
  192. if (StringUtil.isEmpty(pcUserVO.getCurrentSystemId()) && JnpfConst.APP.equals(type)
  193. && CollectionUtil.isNotEmpty(pcUserVO.getUserInfo().getStandingList())) {
  194. List<UserSystemVO> standingList = pcUserVO.getUserInfo().getStandingList();
  195. //先切使用者
  196. UserSystemVO userSystemVO = standingList.stream().filter(t -> PermissionConst.USER.equals(t.getEnCode())).findFirst().orElse(null);
  197. if (userSystemVO != null) {
  198. UserEntity user = new UserEntity();
  199. user.setId(userInfo.getUserId());
  200. user.setAppStanding(userSystemVO.getId());
  201. boolean update = userApi.updateById(user);
  202. if (update) {
  203. pcUserVO = loginService.getCurrentUser(type, systemCode, isBackend);
  204. }
  205. }
  206. //没有使用者遍历其他身份
  207. if (userSystemVO == null || StringUtil.isEmpty(pcUserVO.getCurrentSystemId())) {
  208. for (UserSystemVO standVo : standingList) {
  209. if (!standVo.isCurrentStanding()) {
  210. UserEntity user = new UserEntity();
  211. user.setId(userInfo.getUserId());
  212. user.setAppStanding(standVo.getId());
  213. boolean update = userApi.updateById(user);
  214. if (update) {
  215. pcUserVO = loginService.getCurrentUser(type, systemCode, isBackend);
  216. }
  217. if (!StringUtil.isEmpty(pcUserVO.getCurrentSystemId())) break;
  218. }
  219. }
  220. }
  221. //身份切换后还是没有系统报错
  222. if (StringUtil.isEmpty(pcUserVO.getCurrentSystemId())) {
  223. throw new LoginException(MsgCode.LOG004.get());
  224. }
  225. }
  226. pcUserVO.setCurrentSystemId(null);
  227. //当前身份没有菜单信息时,直接提示权限不足
  228. if (pcUserVO.getMenuList().isEmpty() && StringUtil.isNotEmpty(systemCode)) {
  229. throw new LoginException(MsgCode.LOG004.get());
  230. }
  231. //app没有身份和权限的时候直接退出
  232. if (JnpfConst.APP.equals(type)
  233. && CollectionUtil.isEmpty(pcUserVO.getUserInfo().getStandingList())
  234. && pcUserVO.getMenuList().isEmpty()) {
  235. userApi.logoutUser(MsgCode.LOG004.get(), Arrays.asList(userInfo.getUserId()));
  236. }
  237. return ActionResult.success(pcUserVO);
  238. }
  239. /**
  240. * 修改密码信息发送
  241. */
  242. @Operation(summary = "修改密码信息发送")
  243. @PostMapping("/updatePasswordMessage")
  244. public ActionResult updatePasswordMessage() {
  245. loginService.updatePasswordMessage();
  246. return ActionResult.success();
  247. }
  248. /**
  249. * 图形验证码
  250. *
  251. * @param codeLength 验证码长度
  252. * @param timestamp 验证码标识
  253. */
  254. @NoDataSourceBind()
  255. @Operation(summary = "图形验证码")
  256. @Parameters({
  257. @Parameter(name = "codeLength", description = "验证码长度", required = true),
  258. @Parameter(name = "timestamp", description = "验证码标识", required = true)
  259. })
  260. @GetMapping("/ImageCode/{codeLength}/{timestamp}")
  261. public void imageCode(@PathVariable("codeLength") Integer codeLength, @PathVariable("timestamp") String timestamp) {
  262. DownUtil.downCode(codeLength);
  263. redisUtil.insert(timestamp, ServletUtil.getSession().getAttribute(CodeUtil.RANDOMCODEKEY), 300);
  264. }
  265. /**
  266. * 注销用户
  267. *
  268. * @return
  269. */
  270. @Operation(summary = "注销用户")
  271. @PostMapping("/logoutCurrentUser")
  272. public ActionResult logoutCurrentUser() {
  273. UserInfo userInfo = UserProvider.getUser();
  274. if (userInfo.getIsAdministrator() != null && UserProvider.getUser().getIsAdministrator()) {
  275. return ActionResult.fail(MsgCode.OA023.get());
  276. }
  277. if (userInfo.getIsAdministrator() != null) {
  278. if (!userInfo.getIsAdministrator()) {
  279. userApi.delete(userApi.getInfo(userInfo.getUserId()));
  280. UserProvider.kickoutByUserId(userInfo.getUserId(), userInfo.getTenantId());
  281. }
  282. }
  283. return ActionResult.success(MsgCode.SU005.get());
  284. }
  285. /**
  286. * 判断是否需要验证码
  287. *
  288. * @param account 账号
  289. */
  290. @NoDataSourceBind()
  291. @Operation(summary = "判断是否需要验证码")
  292. @Parameters({
  293. @Parameter(name = "account", description = "账号", required = true)
  294. })
  295. @GetMapping("/getConfig/{account}")
  296. public ActionResult<LoginModel> check(@PathVariable("account") String account) throws LoginException {
  297. LoginModel loginModel = new LoginModel();
  298. if (configValueUtil.isMultiTenancy()) {
  299. LoginForm loginForm = new LoginForm();
  300. loginForm.setAccount(account);
  301. UserInfo userInfo = new UserInfo();
  302. userInfo.setUserAccount(loginForm.getAccount());
  303. userInfo = loginService.getTenantAccount(userInfo);
  304. }
  305. // 获取配置
  306. BaseSystemInfo sysConfigInfo = sysConfigApi.getSysInfo();
  307. // 是否开启验证码
  308. if (Objects.nonNull(sysConfigInfo) && "1".equals(String.valueOf(sysConfigInfo.getEnableVerificationCode()))) {
  309. loginModel.setEnableVerificationCode(1);
  310. Integer verificationCodeNumber = sysConfigInfo.getVerificationCodeNumber();
  311. loginModel.setVerificationCodeNumber(verificationCodeNumber == null ? 4 : verificationCodeNumber);
  312. return ActionResult.success(loginModel);
  313. }
  314. loginModel.setEnableVerificationCode(0);
  315. return ActionResult.success(loginModel);
  316. }
  317. /**
  318. * 获取登录配置, 是否需要跳转、第三方登录信息
  319. *
  320. * @return {re}
  321. * @throws LoginException 登录异常
  322. */
  323. @NoDataSourceBind()
  324. @Operation(summary = "获取登录配置")
  325. @GetMapping("/getLoginConfig")
  326. public ActionResult<LoginConfigModel> getLoginConfig() {
  327. LoginConfigModel loginConfigModel = new LoginConfigModel();
  328. if (oauthConfig.getSsoEnabled()) {
  329. String url = oauthConfig.getLoginPath() + StrPool.SLASH + oauthConfig.getDefaultSSO();
  330. loginConfigModel.setRedirect(true);
  331. loginConfigModel.setUrl(url);
  332. loginConfigModel.setTicketParams(PARAMS_JNPF_TICKET);
  333. } else {
  334. //追加第三方登录配置
  335. List<SocialsUserVo> loginList = socialsUserApi.getLoginList(PARAMS_JNPF_TICKET.toUpperCase());
  336. if (CollectionUtil.isNotEmpty(loginList)) {
  337. loginConfigModel.setSocialsList(loginList);
  338. loginConfigModel.setRedirect(false);
  339. loginConfigModel.setTicketParams(PARAMS_JNPF_TICKET);
  340. }
  341. }
  342. return ActionResult.success(loginConfigModel);
  343. }
  344. /**
  345. * 获取登录票据
  346. *
  347. * @return {msg:有效期, data:票据}
  348. */
  349. @NoDataSourceBind()
  350. @Operation(summary = "获取登录票据")
  351. @GetMapping("/getTicket")
  352. public ActionResult<String> getTicket() {
  353. LoginTicketModel ticketModel = new LoginTicketModel();
  354. ticketModel.setTicketTimeout(System.currentTimeMillis() + oauthConfig.getTicketTimeout() * 1000);
  355. String ticket = TicketUtil.createTicket(ticketModel, oauthConfig.getTicketTimeout());
  356. return ActionResult.success(ticketModel.getTicketTimeout().toString(), ticket);
  357. }
  358. /**
  359. * 检测票据登录状态
  360. *
  361. * @return {re}
  362. * @throws LoginException
  363. */
  364. @NoDataSourceBind()
  365. @Operation(summary = "获取登录状态")
  366. @GetMapping("/getTicketStatus/{ticket}")
  367. public ActionResult<LoginTicketModel> getTicketStatus(@PathVariable("ticket") String ticket) {
  368. LoginTicketModel ticketModel = TicketUtil.parseTicket(ticket);
  369. if (ticketModel == null) {
  370. ticketModel = new LoginTicketModel().setStatus(LoginTicketStatus.Invalid.getStatus()).setValue("票据失效!");
  371. } else {
  372. if (ticketModel.getStatus() != LoginTicketStatus.UnLogin.getStatus()
  373. && ticketModel.getStatus() != LoginTicketStatus.UnBind.getStatus()
  374. && ticketModel.getStatus() != LoginTicketStatus.UnBindMes.getStatus()
  375. && ticketModel.getStatus() != LoginTicketStatus.Multitenancy.getStatus()) {
  376. TicketUtil.deleteTicket(ticket);
  377. }
  378. }
  379. return ActionResult.success(ticketModel);
  380. }
  381. /**
  382. * 官网重置密码专用
  383. *
  384. * @return
  385. */
  386. @NoDataSourceBind()
  387. @Operation(summary = "官网重置密码专用")
  388. @GetMapping("/resetOfficialPassword/{mobile}/{code}")
  389. public ActionResult resetOfficialPassword(@PathVariable("mobile") String mobile, @PathVariable("code") String code) throws LoginException {
  390. //校验验证码
  391. TenantDataSourceUtil.checkOfficialSmsCode(mobile, code, 2);
  392. //切换租户
  393. LoginForm loginForm = new LoginForm();
  394. loginForm.setAccount(mobile);
  395. UserInfo userInfo = new UserInfo();
  396. userInfo.setUserAccount(loginForm.getAccount());
  397. try {
  398. userInfo = loginService.getTenantAccount(userInfo);
  399. } catch (Exception e) {
  400. return ActionResult.fail(MsgCode.LOG105.get());
  401. }
  402. // 重置密码 123456
  403. UserEntity userEntity = userDetailsServiceBuilder.getUserDetailService(AuthConsts.USERDETAIL_ACCOUNT).loadUserEntity(userInfo);
  404. userEntity.setPassword("e10adc3949ba59abbe56e057f20f883e");
  405. userEntity.setPassword(Md5Util.getStringMd5(userEntity.getPassword().toLowerCase() + userEntity.getSecretkey().toLowerCase()));
  406. boolean result = userApi.updateById(userEntity);
  407. if (result) {
  408. return ActionResult.success(MsgCode.LOG205.get());
  409. } else {
  410. return ActionResult.fail(MsgCode.LOG206.get());
  411. }
  412. }
  413. /**
  414. * 生成扫码凭证
  415. *
  416. * @return
  417. */
  418. @NoDataSourceBind()
  419. @Operation(summary = "生成扫码凭证")
  420. @GetMapping("/codeCertificate")
  421. public ActionResult codeCertificate() throws LoginException {
  422. ScanCodeLoginConfigModel ticketModel = new ScanCodeLoginConfigModel();
  423. ticketModel.setTicketTimeout(System.currentTimeMillis() + configValueUtil.getCodeCertificateTimeout() * 1000);
  424. String ticket = TicketUtil.createTicket(ticketModel, configValueUtil.getCodeCertificateTimeout());
  425. return ActionResult.success(ticketModel.getTicketTimeout().toString(), ticket);
  426. }
  427. /**
  428. * 获取扫码凭证状态
  429. *
  430. * @param ticket
  431. * @return
  432. * @throws LoginException
  433. */
  434. @NoDataSourceBind()
  435. @Operation(summary = "获取扫码凭证状态")
  436. @GetMapping("/codeCertificateStatus/{ticket}")
  437. public ActionResult codeCertificateStatus(@PathVariable("ticket") String ticket) throws LoginException {
  438. ScanCodeLoginConfigModel ticketModel = TicketUtil.parseTicket(ticket);
  439. if (ticketModel == null) {
  440. ticketModel = new ScanCodeLoginConfigModel();
  441. ticketModel.setStatus(ScanCodeTicketStatus.Invalid.getStatus());
  442. }
  443. return ActionResult.success(ticketModel);
  444. }
  445. /**
  446. * 确认登录
  447. *
  448. * @param ticket
  449. * @return
  450. * @throws LoginException
  451. */
  452. @NoDataSourceBind()
  453. @Operation(summary = "确认登录")
  454. @GetMapping("/confirmLogin/{ticket}")
  455. public ActionResult confirmLogin(@PathVariable("ticket") String ticket) throws LoginException {
  456. ScanCodeLoginConfigModel ticketModel = TicketUtil.parseTicket(ticket);
  457. if (ticketModel == null || !Objects.equals(ticketModel.getStatus(), 1)) {
  458. ticketModel = new ScanCodeLoginConfigModel();
  459. ticketModel.setStatus(ScanCodeTicketStatus.Invalid.getStatus());
  460. return ActionResult.success(ticketModel);
  461. }
  462. ticketModel.setStatus(ScanCodeTicketStatus.Success.getStatus());
  463. Map<String, String> parameters = new HashMap<>();
  464. parameters.put("grant_type", "scancode");
  465. parameters.put("token", UserProvider.getToken());
  466. ticketModel.setValue(authService.login(parameters).getData().getToken());
  467. TicketUtil.updateTicket(ticket, ticketModel, null);
  468. return ActionResult.success(ticketModel);
  469. }
  470. /**
  471. * 更改扫码凭证状态
  472. *
  473. * @param ticket
  474. * @return
  475. * @throws LoginException
  476. */
  477. @NoDataSourceBind()
  478. @Operation(summary = "更改扫码凭证状态")
  479. @GetMapping("/setCodeCertificateStatus/{ticket}/{status}")
  480. public ActionResult setCodeCertificateStatus(@PathVariable("ticket") String ticket, @PathVariable("status") Integer status) throws LoginException {
  481. ScanCodeLoginConfigModel ticketModel = TicketUtil.parseTicket(ticket);
  482. if (ticketModel == null) {
  483. ticketModel = new ScanCodeLoginConfigModel();
  484. ticketModel.setStatus(ScanCodeTicketStatus.Invalid.getStatus());
  485. } else {
  486. ticketModel.setStatus(status);
  487. }
  488. ticketModel.setTicketTimeout(System.currentTimeMillis() + configValueUtil.getCodeCertificateTimeout() * 1000);
  489. TicketUtil.updateTicket(ticket, ticketModel, configValueUtil.getCodeCertificateTimeout());
  490. return ActionResult.success(ticketModel);
  491. }
  492. /**
  493. * 获取用户登录信息
  494. *
  495. * @return
  496. * @throws LoginException 登录异常
  497. */
  498. @Operation(summary = "获取用户基本信息")
  499. @GetMapping("/me")
  500. public ActionResult<MeInfoVO> me() throws LoginException {
  501. UserInfo userInfo = UserProvider.getUser();
  502. MeInfoVO meInfoVO = new MeInfoVO()
  503. .setUserName(userInfo.getUserName())
  504. .setUserId(userInfo.getUserId())
  505. .setUserAccount(userInfo.getUserAccount())
  506. .setTenantId(userInfo.getTenantId());
  507. return ActionResult.success(meInfoVO);
  508. }
  509. @GetMapping("/white/jumpIndex")
  510. @NoDataSourceBind
  511. @Operation(summary = "跳转前端首页, 判断桌面端或者移动端跳转至不同的地址")
  512. public void jumpIndex(@RequestParam(value = "from", required = false) String from) throws IOException {
  513. String url = ServletUtil.getIsMobileDevice()?configValueUtil.getAppDomain():configValueUtil.getFrontDomain();
  514. UrlBuilder urlBuilder = UrlBuilder.of(url);
  515. if(StringUtil.isNotBlank(from)){
  516. urlBuilder.addQuery("from", from);
  517. }
  518. ServletUtil.getResponse().sendRedirect(urlBuilder.build());
  519. }
  520. }