Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hphy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
向怀芳
hphy
Commits
417f3190
Commit
417f3190
authored
Oct 21, 2022
by
向怀芳
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 新增修改密码,重置密码功能,密码过期提示功能
parent
d9c05846
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
128 additions
and
6 deletions
+128
-6
UserPwdProperties.java
...a/cn/sh/stc/sict/cloud/upms/config/UserPwdProperties.java
+39
-0
SysUserBaseController.java
...sict/cloud/upms/controller/web/SysUserBaseController.java
+63
-6
ChangePasswordDTO.java
...java/cn/sh/stc/sict/cloud/upms/dto/ChangePasswordDTO.java
+15
-0
SysUserBaseService.java
...cn/sh/stc/sict/cloud/upms/service/SysUserBaseService.java
+2
-0
SysUserBaseServiceImpl.java
.../sict/cloud/upms/service/impl/SysUserBaseServiceImpl.java
+9
-0
No files found.
smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/config/UserPwdProperties.java
0 → 100644
View file @
417f3190
package
cn
.
sh
.
stc
.
sict
.
cloud
.
upms
.
config
;
import
cn.hutool.core.date.DateUtil
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
/**
* 用户密码修改提示 配置属性
*/
@Data
@Component
@RefreshScope
@ConfigurationProperties
(
prefix
=
"user.pwd"
)
public
class
UserPwdProperties
{
/**
* 是否进行密码修改提示
*/
private
Boolean
limitFlag
;
/**
* 上次修改超过{{limitDays}}天,锁定用户
*/
private
Integer
limitDays
;
/**
* 上次修改超过{{tipsDays}}天,开始提示用户修改密码
*/
private
Integer
tipsDays
;
public
boolean
getTips
(
Date
lastPwdTime
)
{
long
offsetDays
=
DateUtil
.
betweenDay
(
lastPwdTime
,
DateUtil
.
date
(),
true
);
if
(
offsetDays
>
tipsDays
)
{
return
true
;
}
return
false
;
}
}
smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/controller/web/SysUserBaseController.java
View file @
417f3190
package
cn
.
sh
.
stc
.
sict
.
cloud
.
upms
.
controller
.
web
;
package
cn
.
sh
.
stc
.
sict
.
cloud
.
upms
.
controller
.
web
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.sh.stc.sict.cloud.common.core.constant.Constant
;
import
cn.sh.stc.sict.cloud.common.core.constant.Constant
;
import
cn.sh.stc.sict.cloud.common.core.constant.enums.BizCodeConstant
;
import
cn.sh.stc.sict.cloud.common.core.constant.enums.BizCodeConstant
;
import
cn.sh.stc.sict.cloud.common.core.util.NumberUtil
;
import
cn.sh.stc.sict.cloud.common.core.util.NumberUtil
;
import
cn.sh.stc.sict.cloud.common.log.annotation.SysLog
;
import
cn.sh.stc.sict.cloud.common.log.annotation.SysLog
;
import
cn.sh.stc.sict.cloud.common.security.service.SictUser
;
import
cn.sh.stc.sict.cloud.common.security.util.SecurityUtils
;
import
cn.sh.stc.sict.cloud.common.security.util.SecurityUtils
;
import
cn.sh.stc.sict.cloud.upms.config.UserPwdProperties
;
import
cn.sh.stc.sict.cloud.upms.dto.ChangePasswordDTO
;
import
cn.sh.stc.sict.cloud.upms.dto.CurrentUser
;
import
cn.sh.stc.sict.cloud.upms.dto.CurrentUser
;
import
cn.sh.stc.sict.cloud.upms.dto.UserDTO
;
import
cn.sh.stc.sict.cloud.upms.dto.UserDTO
;
import
cn.sh.stc.sict.cloud.upms.model.HpMenu
;
import
cn.sh.stc.sict.cloud.upms.model.HpMenu
;
...
@@ -53,10 +58,11 @@ public class SysUserBaseController {
...
@@ -53,10 +58,11 @@ public class SysUserBaseController {
* 3. 角色配置
* 3. 角色配置
* 4. 重置密码(加密处理)
* 4. 重置密码(加密处理)
*/
*/
private
SysUserBaseService
sysUserBaseService
;
private
final
SysUserBaseService
sysUserBaseService
;
private
HpRoleService
hpRoleService
;
private
final
HpRoleService
hpRoleService
;
private
HpUserRoleService
hpUserRoleService
;
private
final
HpUserRoleService
hpUserRoleService
;
private
HpMenuService
hpMenuService
;
private
final
HpMenuService
hpMenuService
;
private
final
UserPwdProperties
userPwdProperties
;
private
static
final
PasswordEncoder
ENCODER
=
new
BCryptPasswordEncoder
();
private
static
final
PasswordEncoder
ENCODER
=
new
BCryptPasswordEncoder
();
@ApiOperation
(
"分页查询 系统基础用户表"
)
@ApiOperation
(
"分页查询 系统基础用户表"
)
...
@@ -118,8 +124,11 @@ public class SysUserBaseController {
...
@@ -118,8 +124,11 @@ public class SysUserBaseController {
dto
.
setUser
(
user
);
dto
.
setUser
(
user
);
dto
.
setRoleList
(
roleList
);
dto
.
setRoleList
(
roleList
);
dto
.
setMenuList
(
menuList
);
dto
.
setMenuList
(
menuList
);
if
(
userPwdProperties
.
getLimitFlag
()
&&
ObjectUtil
.
isNotNull
(
user
.
getLastPwdTime
())
&&
userPwdProperties
.
getTips
(
user
.
getLastPwdTime
()))
{
return
new
R
(
dto
).
setBizCode
(
BizCodeConstant
.
USER_PWD_LIMIT
.
getCode
());
return
new
R
(
dto
).
setBizCode
(
BizCodeConstant
.
USER_PWD_LIMIT
.
getCode
());
}
else
{
return
new
R
(
dto
);
}
}
}
...
@@ -135,6 +144,54 @@ public class SysUserBaseController {
...
@@ -135,6 +144,54 @@ public class SysUserBaseController {
return
new
R
();
return
new
R
();
}
}
@SysLog
@ApiOperation
(
"修改用户密码"
)
@PutMapping
(
"/password"
)
public
R
<?>
changePassword
(
@RequestBody
ChangePasswordDTO
password
)
{
if
(
StrUtil
.
isBlank
(
password
.
getNewPassword
())
||
StrUtil
.
isBlank
(
password
.
getOldPassword
()))
{
return
new
R
<>().
error
(
"新密码或旧密码不能为空!"
);
}
if
(
StrUtil
.
equals
(
password
.
getNewPassword
(),
password
.
getOldPassword
()))
{
return
new
R
<>().
error
(
"新密码不能与旧密码相同!"
);
}
SictUser
user
=
SecurityUtils
.
getUser
();
SysUserBase
userBase
=
sysUserBaseService
.
getById
(
user
.
getId
());
if
(
userBase
==
null
)
{
return
new
R
<>().
error
(
"用户不存在!"
);
}
if
(!
ENCODER
.
matches
(
password
.
getOldPassword
(),
userBase
.
getPasswd
()))
{
return
new
R
<>().
error
(
"旧密码不正确!"
);
}
userBase
.
setPasswd
(
ENCODER
.
encode
(
password
.
getNewPassword
()));
userBase
.
setLastPwdTime
(
DateUtil
.
date
());
sysUserBaseService
.
updateById
(
userBase
);
sysUserBaseService
.
initRedisByUserName
(
userBase
.
getUserName
());
return
new
R
<>().
success
(
""
);
}
@SysLog
@ApiOperation
(
"重置密码"
)
@PutMapping
(
"/reset/password"
)
@PreAuthorize
(
"@pms.hasPermission('ROLE_admin')"
)
public
R
<?>
resetPassword
(
@RequestParam
(
"userId"
)
Long
userId
)
{
SysUserBase
user
=
sysUserBaseService
.
getById
(
userId
);
if
(
ObjectUtil
.
isNull
(
user
)
||
NumberUtil
.
isNullOrZero
(
user
.
getId
()))
{
return
new
R
<>().
error
(
"未找到用户信息!"
);
}
SysUserBase
update
=
new
SysUserBase
();
update
.
setId
(
userId
);
update
.
setPasswd
(
ENCODER
.
encode
(
Constant
.
DEFAULT_PASSWORD
));
update
.
setLastPwdTime
(
DateUtil
.
date
());
sysUserBaseService
.
updateById
(
update
);
sysUserBaseService
.
initRedisByUserName
(
user
.
getUserName
());
return
new
R
<>().
success
(
""
);
}
/**
/**
* 通过id删除系统基础用户表
* 通过id删除系统基础用户表
*
*
...
...
smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/dto/ChangePasswordDTO.java
0 → 100644
View file @
417f3190
package
cn
.
sh
.
stc
.
sict
.
cloud
.
upms
.
dto
;
import
lombok.Data
;
/**
* @author 75
* @Description
* @Date 2021/5/17 11:00
**/
@Data
public
class
ChangePasswordDTO
{
private
Long
userId
;
private
String
oldPassword
;
private
String
newPassword
;
}
smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/service/SysUserBaseService.java
View file @
417f3190
...
@@ -20,5 +20,7 @@ public interface SysUserBaseService extends IService<SysUserBase> {
...
@@ -20,5 +20,7 @@ public interface SysUserBaseService extends IService<SysUserBase> {
boolean
saveDto
(
UserDTO
dto
);
boolean
saveDto
(
UserDTO
dto
);
boolean
exist
(
SysUserBase
user
);
boolean
exist
(
SysUserBase
user
);
void
initRedisByUserName
(
String
userName
);
}
}
smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/service/impl/SysUserBaseServiceImpl.java
View file @
417f3190
...
@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
...
@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.sh.stc.sict.cloud.common.core.constant.Constant
;
import
cn.sh.stc.sict.cloud.common.core.constant.Constant
;
import
cn.sh.stc.sict.cloud.common.core.constant.RedisCacheConstant
;
import
cn.sh.stc.sict.cloud.common.core.constant.UserConstant
;
import
cn.sh.stc.sict.cloud.common.core.constant.UserConstant
;
import
cn.sh.stc.sict.cloud.common.core.constant.enums.LoginTypeEnum
;
import
cn.sh.stc.sict.cloud.common.core.constant.enums.LoginTypeEnum
;
import
cn.sh.stc.sict.cloud.common.core.dto.WDUserInfo
;
import
cn.sh.stc.sict.cloud.common.core.dto.WDUserInfo
;
...
@@ -28,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -28,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import
me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken
;
import
me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -45,6 +47,7 @@ public class SysUserBaseServiceImpl extends ServiceImpl<SysUserBaseMapper, SysUs
...
@@ -45,6 +47,7 @@ public class SysUserBaseServiceImpl extends ServiceImpl<SysUserBaseMapper, SysUs
private
HpUserRoleService
hpUserRoleService
;
private
HpUserRoleService
hpUserRoleService
;
private
HpRoleService
hpRoleService
;
private
HpRoleService
hpRoleService
;
private
static
final
PasswordEncoder
ENCODER
=
new
BCryptPasswordEncoder
();
private
static
final
PasswordEncoder
ENCODER
=
new
BCryptPasswordEncoder
();
private
final
StringRedisTemplate
stringRedisTemplate
;
@Override
@Override
public
UserInfo
getUserInfo
(
String
appId
,
String
username
)
{
public
UserInfo
getUserInfo
(
String
appId
,
String
username
)
{
...
@@ -138,6 +141,12 @@ public class SysUserBaseServiceImpl extends ServiceImpl<SysUserBaseMapper, SysUs
...
@@ -138,6 +141,12 @@ public class SysUserBaseServiceImpl extends ServiceImpl<SysUserBaseMapper, SysUs
return
this
.
count
(
wrapper
)
>
0
;
return
this
.
count
(
wrapper
)
>
0
;
}
}
@Override
public
void
initRedisByUserName
(
String
userName
)
{
String
key
=
RedisCacheConstant
.
USER_DETAILS
+
"::"
+
userName
+
":*"
;
stringRedisTemplate
.
delete
(
stringRedisTemplate
.
keys
(
key
));
}
private
UserInfo
getByPhone
(
String
phone
)
{
private
UserInfo
getByPhone
(
String
phone
)
{
LambdaQueryWrapper
<
SysUserBase
>
wrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
SysUserBase
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
SysUserBase:
:
getPhone
,
phone
);
wrapper
.
eq
(
SysUserBase:
:
getPhone
,
phone
);
...
...
Write
Preview
Markdown
is supported
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