mirror of https://github.com/elunez/eladmin
新增重置用户密码功能
parent
c20bd42276
commit
e0777d8681
|
@ -127,4 +127,13 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
|
|||
@Query(value = "SELECT count(1) FROM sys_user u, sys_users_roles r WHERE " +
|
||||
"u.user_id = r.user_id AND r.role_id in ?1", nativeQuery = true)
|
||||
int countByRoles(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
* @param ids 、
|
||||
* @param pwd 、
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "update sys_user set password = ?2 where user_id in ?1",nativeQuery = true)
|
||||
void resetPwd(Set<Long> ids, String pwd);
|
||||
}
|
||||
|
|
|
@ -168,6 +168,14 @@ public class UserController {
|
|||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("重置密码")
|
||||
@PutMapping(value = "/resetPwd")
|
||||
public ResponseEntity<Object> resetPwd(@RequestBody Set<Long> ids) {
|
||||
String pwd = passwordEncoder.encode("123456");
|
||||
userService.resetPwd(ids, pwd);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("修改头像")
|
||||
@PostMapping(value = "/updateAvatar")
|
||||
public ResponseEntity<Object> updateUserAvatar(@RequestParam MultipartFile avatar){
|
||||
|
|
|
@ -123,4 +123,11 @@ public interface UserService {
|
|||
* @param resources /
|
||||
*/
|
||||
void updateCenter(User resources);
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
* @param ids 用户id
|
||||
* @param pwd 密码
|
||||
*/
|
||||
void resetPwd(Set<Long> ids, String pwd);
|
||||
}
|
||||
|
|
|
@ -196,6 +196,12 @@ public class UserServiceImpl implements UserService {
|
|||
flushCache(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void resetPwd(Set<Long> ids, String pwd) {
|
||||
userRepository.resetPwd(ids, pwd);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, String> updateAvatar(MultipartFile multipartFile) {
|
||||
|
|
Loading…
Reference in New Issue