mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-25 06:27:50 +08:00
登录后用户信息增加服务ID
This commit is contained in:
parent
ba58eff4be
commit
4ad9f83ee9
@ -2,6 +2,8 @@ package com.genersoft.iot.vmp.conf.security.dto;
|
|||||||
|
|
||||||
import com.genersoft.iot.vmp.storager.dao.dto.Role;
|
import com.genersoft.iot.vmp.storager.dao.dto.Role;
|
||||||
import com.genersoft.iot.vmp.storager.dao.dto.User;
|
import com.genersoft.iot.vmp.storager.dao.dto.User;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.springframework.security.core.CredentialsContainer;
|
import org.springframework.security.core.CredentialsContainer;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.SpringSecurityCoreVersion;
|
import org.springframework.security.core.SpringSecurityCoreVersion;
|
||||||
@ -19,8 +21,13 @@ public class LoginUser implements UserDetails, CredentialsContainer {
|
|||||||
*/
|
*/
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
private String serverId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录时间
|
* 登录时间
|
||||||
@ -104,11 +111,4 @@ public class LoginUser implements UserDetails, CredentialsContainer {
|
|||||||
return user.getPushKey();
|
return user.getPushKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAccessToken() {
|
|
||||||
return accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccessToken(String accessToken) {
|
|
||||||
this.accessToken = accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,7 @@ import oshi.hardware.HardwareAbstractionLayer;
|
|||||||
import oshi.hardware.NetworkIF;
|
import oshi.hardware.NetworkIF;
|
||||||
import oshi.software.os.OperatingSystem;
|
import oshi.software.os.OperatingSystem;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -81,6 +82,7 @@ public class ServerController {
|
|||||||
@Value("${server.port}")
|
@Value("${server.port}")
|
||||||
private int serverPort;
|
private int serverPort;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRedisCatchStorage redisCatchStorage;
|
private IRedisCatchStorage redisCatchStorage;
|
||||||
|
|
||||||
@ -275,7 +277,7 @@ public class ServerController {
|
|||||||
@GetMapping(value = "/info")
|
@GetMapping(value = "/info")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Operation(summary = "获取系统信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
@Operation(summary = "获取系统信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||||
public Map<String, Map<String, String>> getInfo() {
|
public Map<String, Map<String, String>> getInfo(HttpServletRequest request) {
|
||||||
Map<String, Map<String, String>> result = new LinkedHashMap<>();
|
Map<String, Map<String, String>> result = new LinkedHashMap<>();
|
||||||
Map<String, String> hardwareMap = new LinkedHashMap<>();
|
Map<String, String> hardwareMap = new LinkedHashMap<>();
|
||||||
result.put("硬件信息", hardwareMap);
|
result.put("硬件信息", hardwareMap);
|
||||||
@ -323,6 +325,11 @@ public class ServerController {
|
|||||||
platformMap.put("GIT版本", version.getGIT_Revision_SHORT());
|
platformMap.put("GIT版本", version.getGIT_Revision_SHORT());
|
||||||
platformMap.put("DOCKER环境", new File("/.dockerenv").exists()?"是":"否");
|
platformMap.put("DOCKER环境", new File("/.dockerenv").exists()?"是":"否");
|
||||||
|
|
||||||
|
Map<String, String> docmap = new LinkedHashMap<>();
|
||||||
|
result.put("文档地址", docmap);
|
||||||
|
docmap.put("部署文档", String.format("%s://%s:%s/doc.html", request.getScheme(), request.getServerName(), request.getServerPort()));
|
||||||
|
docmap.put("接口文档", "https://doc.wvp-pro.cn");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.genersoft.iot.vmp.vmanager.user;
|
package com.genersoft.iot.vmp.vmanager.user;
|
||||||
|
|
||||||
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
||||||
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
|
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
|
||||||
@ -42,6 +43,9 @@ public class UserController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IRoleService roleService;
|
private IRoleService roleService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSetting userSetting;
|
||||||
|
|
||||||
@GetMapping("/login")
|
@GetMapping("/login")
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
@Operation(summary = "登录", description = "登录成功后返回AccessToken, 可以从返回值获取到也可以从响应头中获取到," +
|
@Operation(summary = "登录", description = "登录成功后返回AccessToken, 可以从返回值获取到也可以从响应头中获取到," +
|
||||||
@ -62,6 +66,7 @@ public class UserController {
|
|||||||
String jwt = JwtUtils.createToken(username);
|
String jwt = JwtUtils.createToken(username);
|
||||||
response.setHeader(JwtUtils.getHeader(), jwt);
|
response.setHeader(JwtUtils.getHeader(), jwt);
|
||||||
user.setAccessToken(jwt);
|
user.setAccessToken(jwt);
|
||||||
|
user.setServerId(userSetting.getServerId());
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user