|
@@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
|
|
import com.genersoft.iot.vmp.conf.security.JwtUtils;
|
|
|
import com.genersoft.iot.vmp.conf.security.SecurityUtils;
|
|
|
import com.genersoft.iot.vmp.conf.security.dto.LoginUser;
|
|
|
+import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd.KeepaliveNotifyMessageHandler;
|
|
|
import com.genersoft.iot.vmp.service.IRoleService;
|
|
|
import com.genersoft.iot.vmp.service.IUserService;
|
|
|
import com.genersoft.iot.vmp.storager.dao.dto.Role;
|
|
@@ -15,6 +16,8 @@ import com.github.pagehelper.PageInfo;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
|
import org.springframework.util.DigestUtils;
|
|
@@ -31,7 +34,7 @@ import java.util.List;
|
|
|
@RestController
|
|
|
@RequestMapping("/api/user")
|
|
|
public class UserController {
|
|
|
-
|
|
|
+ private Logger logger = LoggerFactory.getLogger(UserController.class);
|
|
|
@Autowired
|
|
|
private AuthenticationManager authenticationManager;
|
|
|
|
|
@@ -52,6 +55,7 @@ public class UserController {
|
|
|
LoginUser user;
|
|
|
try {
|
|
|
user = SecurityUtils.login(username, password, authenticationManager);
|
|
|
+ logger.info("[用户管理] - [登录] - [{} - {} -{}] - 登录成功", user.getId(), user.getUsername(), user.getRole().getId());
|
|
|
} catch (AuthenticationException e) {
|
|
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage());
|
|
|
}
|
|
@@ -72,20 +76,24 @@ public class UserController {
|
|
|
@Parameter(name = "oldpassword", description = "旧密码(已md5加密的密码)", required = true)
|
|
|
@Parameter(name = "password", description = "新密码(未md5加密的密码)", required = true)
|
|
|
public void changePassword(@RequestParam String oldPassword, @RequestParam String password){
|
|
|
+ logger.info("[用户管理] 修改密码");
|
|
|
// 获取当前登录用户id
|
|
|
- LoginUser userInfo = SecurityUtils.getUserInfo();
|
|
|
- if (userInfo== null) {
|
|
|
+ LoginUser loginUser = SecurityUtils.getUserInfo();
|
|
|
+ if (loginUser== null) {
|
|
|
throw new ControllerException(ErrorCode.ERROR100);
|
|
|
}
|
|
|
- String username = userInfo.getUsername();
|
|
|
+ String username = loginUser.getUsername();
|
|
|
+ String passwordMd5 = loginUser.getPassword();
|
|
|
+ logger.info("[用户管理] ");
|
|
|
LoginUser user = null;
|
|
|
try {
|
|
|
user = SecurityUtils.login(username, oldPassword, authenticationManager);
|
|
|
if (user == null) {
|
|
|
throw new ControllerException(ErrorCode.ERROR100);
|
|
|
}
|
|
|
- int userId = SecurityUtils.getUserId();
|
|
|
- boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes()));
|
|
|
+// int userId = SecurityUtils.getUserId();
|
|
|
+ logger.info("[用户管理] 修改密码,用户id:" + user.getId() + ",用户名:" + username);
|
|
|
+ boolean result = userService.changePassword(user.getId(), DigestUtils.md5DigestAsHex(password.getBytes()));
|
|
|
if (!result) {
|
|
|
throw new ControllerException(ErrorCode.ERROR100);
|
|
|
}
|