feat: NAS登录
This commit is contained in:
parent
cc3f07fbf1
commit
88c746f896
@ -111,28 +111,30 @@ public class SysLoginController {
|
||||
Set<String> roles = permissionService.getRolePermission(user);
|
||||
// 权限集合
|
||||
Set<String> 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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user