Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
e0777d86
Commit
e0777d86
authored
Jul 06, 2023
by
Zheng Jie
Browse files
新增重置用户密码功能
parent
c20bd422
Changes
4
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java
View file @
e0777d86
...
...
@@ -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
);
}
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
View file @
e0777d86
...
...
@@ -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
){
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java
View file @
e0777d86
...
...
@@ -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
);
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
View file @
e0777d86
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment