|
|
@@ -3,6 +3,8 @@ package space.anyi.BI.controller;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import space.anyi.BI.entity.LoginUserDetails;
|
|
|
import space.anyi.BI.entity.ResponseResult;
|
|
|
@@ -31,6 +33,8 @@ public class UserController {
|
|
|
private final static Logger log = LoggerFactory.getLogger(UserController.class);
|
|
|
@Resource
|
|
|
private UserService userService;
|
|
|
+ @Resource
|
|
|
+ private PasswordEncoder passwordEncoder;
|
|
|
|
|
|
@PostMapping("/login")
|
|
|
public ResponseResult login(@RequestBody User user){
|
|
|
@@ -85,6 +89,11 @@ public class UserController {
|
|
|
@ResponseBody
|
|
|
public ResponseResult updateUser(@RequestBody UserDTO userDTO){
|
|
|
User user = BeanCopyUtil.copyBean(userDTO, User.class);
|
|
|
+ if (StringUtils.hasText(user.getUserPassword())) {
|
|
|
+ user.setUserPassword(passwordEncoder.encode(user.getUserPassword()));
|
|
|
+ }else{
|
|
|
+ user.setUserPassword(passwordEncoder.encode("password"));
|
|
|
+ }
|
|
|
userService.updateById(user);
|
|
|
return ResponseResult.okResult();
|
|
|
}
|