diff --git a/pnkx-admin/src/main/java/com/pnkx/web/controller/system/SysLoginController.java b/pnkx-admin/src/main/java/com/pnkx/web/controller/system/SysLoginController.java index 5bf7e30..0af5ff2 100644 --- a/pnkx-admin/src/main/java/com/pnkx/web/controller/system/SysLoginController.java +++ b/pnkx-admin/src/main/java/com/pnkx/web/controller/system/SysLoginController.java @@ -111,28 +111,30 @@ public class SysLoginController { Set roles = permissionService.getRolePermission(user); // 权限集合 Set permissions = permissionService.getMenuPermission(user); - try { - // get请求获取群晖token - // 使用UriComponentsBuilder构建带有查询参数的URL - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(DSM_LOGIN_URL) - .queryParam("api", "SYNO.API.Auth") - .queryParam("version", "6") - .queryParam("method", "login") - .queryParam("account", user.getSynoUserName()) - .queryParam("passwd", user.getSynoPassword()) - .queryParam("enable_syno_token", "yes"); - // 构建完整的URL - String url = builder.toUriString(); - // 发送GET请求并获取响应 - RestTemplate restTemplate = new RestTemplate(); - String result = restTemplate.getForObject(url, String.class); - logger.info("群晖token:{}", result); - JSONObject jsonObject = JSONObject.fromObject(result); - if (jsonObject.get("success").equals(true)) { - user.setSynoToken(jsonObject.getJSONObject("data").getString("synotoken")); + if ("01".equals(user.getUserType())) { + try { + // get请求获取群晖token + // 使用UriComponentsBuilder构建带有查询参数的URL + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(DSM_LOGIN_URL) + .queryParam("api", "SYNO.API.Auth") + .queryParam("version", "6") + .queryParam("method", "login") + .queryParam("account", user.getSynoUserName()) + .queryParam("passwd", user.getSynoPassword()) + .queryParam("enable_syno_token", "yes"); + // 构建完整的URL + String url = builder.toUriString(); + // 发送GET请求并获取响应 + RestTemplate restTemplate = new RestTemplate(); + String result = restTemplate.getForObject(url, String.class); + logger.info("群晖token:{}", result); + JSONObject jsonObject = JSONObject.fromObject(result); + if (jsonObject.get("success").equals(true)) { + user.setSynoToken(jsonObject.getJSONObject("data").getString("synotoken")); + } + } catch (RestClientException e) { + logger.error("请求群晖token失败,异常信息", e); } - } catch (RestClientException e) { - logger.error("请求群晖token失败,异常信息", e); } AjaxResult ajax = AjaxResult.success(); ajax.put("user", user); diff --git a/pnkx-common/src/main/java/com/pnkx/common/core/domain/entity/SysUser.java b/pnkx-common/src/main/java/com/pnkx/common/core/domain/entity/SysUser.java index f193b49..571d902 100644 --- a/pnkx-common/src/main/java/com/pnkx/common/core/domain/entity/SysUser.java +++ b/pnkx-common/src/main/java/com/pnkx/common/core/domain/entity/SysUser.java @@ -43,6 +43,9 @@ public class SysUser extends BaseEntity { @Excel(name = "登录名称") private String userName; + // 用户类型 + private String userType; + /** * 用户昵称 */ @@ -191,6 +194,14 @@ public class SysUser extends BaseEntity { this.deptId = deptId; } + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") public String getNickName() { return nickName;