|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.supervision.controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.net.NetUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.supervision.constant.UserTokenConstant;
|
|
|
|
@ -20,10 +21,12 @@ import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
@Api(tags = "用户管理")
|
|
|
|
@ -38,8 +41,17 @@ public class UserController {
|
|
|
|
|
|
|
|
|
|
private final UserManageService userManageService;
|
|
|
|
|
|
|
|
|
|
private final UserResourceCheck userResourceCheck;
|
|
|
|
|
private final UserResourceCheck userResourceCheck;
|
|
|
|
|
|
|
|
|
|
@Value("${ws.nginx-ip:}")
|
|
|
|
|
private String wsIp;
|
|
|
|
|
@Value("${ws.nginx-port:}")
|
|
|
|
|
private String wsPort;
|
|
|
|
|
|
|
|
|
|
@Value("${spring.profiles.active}")
|
|
|
|
|
private String active;
|
|
|
|
|
@Value("${server.port}")
|
|
|
|
|
private String port;
|
|
|
|
|
|
|
|
|
|
@ApiOperation("登录")
|
|
|
|
|
@PostMapping("login")
|
|
|
|
@ -69,7 +81,7 @@ public class UserController {
|
|
|
|
|
|
|
|
|
|
@ApiOperation("查看资源是否有剩余")
|
|
|
|
|
@GetMapping("resourceIsFree")
|
|
|
|
|
public boolean resourceIsFree(){
|
|
|
|
|
public boolean resourceIsFree() {
|
|
|
|
|
return userResourceCheck.achieveDiagnoseResource();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -77,16 +89,32 @@ public class UserController {
|
|
|
|
|
@PutMapping("updateUserInfo")
|
|
|
|
|
public boolean updateUserInfo(@RequestBody UserInfoReqVo userInfo) {
|
|
|
|
|
|
|
|
|
|
return userManageService.updateUserInfo(userInfo);
|
|
|
|
|
return userManageService.updateUserInfo(userInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("查看账号信息")
|
|
|
|
|
@GetMapping("getUserAccountInfo")
|
|
|
|
|
public UserInfoResVo getUserAccountInfo() {
|
|
|
|
|
|
|
|
|
|
User user = UserUtil.getUser();
|
|
|
|
|
return userManageService.getUserAccountInfo(user.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取本机IP地址,用来给websocket使用")
|
|
|
|
|
@GetMapping("queryWebSocketUrl")
|
|
|
|
|
public String queryWebSocketUrl() {
|
|
|
|
|
String template = "wss://{}:{}/virtual-patient-websocket/";
|
|
|
|
|
// 如果是本地开发环境,则获取本机IP地址
|
|
|
|
|
if ("dev".equals(active)) {
|
|
|
|
|
String localhostStr = NetUtil.getLocalhostStr();
|
|
|
|
|
return StrUtil.format(template, localhostStr, port);
|
|
|
|
|
} else {
|
|
|
|
|
if (StrUtil.isNotBlank(wsIp) && StrUtil.isNotBlank(wsPort)) {
|
|
|
|
|
return StrUtil.format(template, wsIp, wsPort);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new BusinessException("未获取到ws的nginx地址,请确认配置文件是否配置");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|