新增重置用户密码功能

pull/805/head
Zheng Jie 2023-07-06 14:24:37 +08:00
parent c20bd42276
commit e0777d8681
4 changed files with 30 additions and 0 deletions

View File

@ -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);
}

View File

@ -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){

View File

@ -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);
}

View File

@ -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) {