This commit is contained in:
2023-12-03 16:27:51 +08:00
parent 95ea00e643
commit e16914967a
30 changed files with 802 additions and 117 deletions

View File

@@ -24,7 +24,7 @@ interface IGroupService : IService<Group> {
fun update(groupUpdateParam: GroupUpdateParam): GroupVo?
fun changeStatus(groupChangeStatusParam: GroupChangeStatusParam): Boolean
fun status(groupUpdateStatusParam: GroupUpdateStatusParam): Boolean
fun deleteOne(id: Long)

View File

@@ -24,7 +24,7 @@ interface IRoleService : IService<Role> {
fun update(roleUpdateParam: RoleUpdateParam): RoleVo?
fun changeStatus(roleChangeStatusParam: RoleChangeStatusParam): Boolean
fun status(roleUpdateStatusParam: RoleUpdateStatusParam): Boolean
fun deleteOne(id: Long)

View File

@@ -30,7 +30,7 @@ interface IUserService : IService<User> {
fun update(userUpdateParam: UserUpdateParam): UserWithRoleInfoVo?
fun changePassword(userChangePasswordParam: UserChangePasswordParam)
fun password(userUpdatePasswordParam: UserUpdatePasswordParam)
fun deleteOne(id: Long)

View File

@@ -117,10 +117,10 @@ class GroupServiceImpl(
return GroupConverter.groupToGroupVo(group)
}
override fun changeStatus(groupChangeStatusParam: GroupChangeStatusParam): Boolean {
updateById(GroupConverter.groupChangeStatusParamToGroup(groupChangeStatusParam)).let {
if (it && !groupChangeStatusParam.enable) {
groupChangeStatusParam.id?.let { id -> offlineUser(id) }
override fun status(groupUpdateStatusParam: GroupUpdateStatusParam): Boolean {
updateById(GroupConverter.groupUpdateStatusParamToGroup(groupUpdateStatusParam)).let {
if (it && !groupUpdateStatusParam.enable) {
groupUpdateStatusParam.id?.let { id -> offlineUser(id) }
}
return it

View File

@@ -124,10 +124,10 @@ class RoleServiceImpl(
return RoleConverter.roleToRoleVo(role)
}
override fun changeStatus(roleChangeStatusParam: RoleChangeStatusParam): Boolean {
updateById(RoleConverter.roleChangeStatusParamToRole(roleChangeStatusParam)).let {
if (it && !roleChangeStatusParam.enable) {
roleChangeStatusParam.id?.let { id -> offlineUser(id) }
override fun status(roleUpdateStatusParam: RoleUpdateStatusParam): Boolean {
updateById(RoleConverter.roleUpdateStatusParamToRole(roleUpdateStatusParam)).let {
if (it && !roleUpdateStatusParam.enable) {
roleUpdateStatusParam.id?.let { id -> offlineUser(id) }
}
return it

View File

@@ -201,25 +201,25 @@ class UserServiceImpl(
return UserConverter.userToUserWithRoleInfoVo(user)
}
override fun changePassword(userChangePasswordParam: UserChangePasswordParam) {
if (WebUtil.getLoginUserId() != 0L && userChangePasswordParam.id == 0L) {
override fun password(userUpdatePasswordParam: UserUpdatePasswordParam) {
if (WebUtil.getLoginUserId() != 0L && userUpdatePasswordParam.id == 0L) {
throw AccessDeniedException("Access denied")
}
val user = baseMapper.selectById(userChangePasswordParam.id)
val user = baseMapper.selectById(userUpdatePasswordParam.id)
user?.let {
val wrapper = KtUpdateWrapper(User())
wrapper.eq(User::id, user.id)
.set(User::password, passwordEncoder.encode(userChangePasswordParam.password))
.set(User::password, passwordEncoder.encode(userUpdatePasswordParam.password))
.set(
User::credentialsExpiration,
if (user.id != 0L) userChangePasswordParam.credentialsExpiration else null
if (user.id != 0L) userUpdatePasswordParam.credentialsExpiration else null
)
.set(User::updateTime, LocalDateTime.now(ZoneOffset.UTC))
this.update(wrapper)
userChangePasswordParam.id?.let { WebUtil.offlineUser(redisUtil, it) }
userUpdatePasswordParam.id?.let { WebUtil.offlineUser(redisUtil, it) }
} ?: let {
throw NoRecordFoundException()
}