|
@@ -4,6 +4,7 @@ import com.gis.admin.entity.po.SysRoleEntity;
|
|
|
import com.gis.common.base.aop.WebControllerLog;
|
|
|
import com.gis.common.base.entity.dto.PageDto;
|
|
|
import com.gis.common.base.entity.po.LogEntity;
|
|
|
+import com.gis.common.base.exception.BaseRuntimeException;
|
|
|
import com.gis.common.base.mapper.IBaseMapper;
|
|
|
import com.gis.common.base.service.LogService;
|
|
|
import com.gis.common.base.service.impl.IBaseServiceImpl;
|
|
@@ -79,6 +80,16 @@ public class SysUserServiceImpl extends IBaseServiceImpl<SysUserEntity, Long> im
|
|
|
entity.setUpdateTime(LocalDateTime.now());
|
|
|
this.update(entity);
|
|
|
|
|
|
+ // 更新密码
|
|
|
+ String oldPassword = param.getOldPassword();
|
|
|
+ String newPassword = param.getNewPassword();
|
|
|
+ if (oldPassword !=null && newPassword != null) {
|
|
|
+ PasswordDto dto = new PasswordDto();
|
|
|
+ dto.setOldPassword(oldPassword);
|
|
|
+ dto.setNewPassword(newPassword);
|
|
|
+ updatePassword(dto);
|
|
|
+ }
|
|
|
+
|
|
|
// 每次修改,删除用户角色表信息,重新添加
|
|
|
sysRoleService.deleteUserRoleByUserId(id);
|
|
|
}
|
|
@@ -119,6 +130,22 @@ public class SysUserServiceImpl extends IBaseServiceImpl<SysUserEntity, Long> im
|
|
|
return Result.success(page);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void updatePassword(PasswordDto param) {
|
|
|
+ SysUserEntity user = this.findByUserName(JwtUtil.getUsername(getToken()));
|
|
|
+
|
|
|
+ // 验证原密码
|
|
|
+ Boolean isBoolean = PasswordUtils.decrypt(user.getPassword(), param.getOldPassword(), PasswordUtils.getStaticSalt());
|
|
|
+ if (!isBoolean) {
|
|
|
+ log.error("原始密码错误");
|
|
|
+ throw new BaseRuntimeException("原始密码错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ user.setPassword(PasswordUtils.encrypt(user.getUserName(), param.getNewPassword(), PasswordUtils.getStaticSalt()));
|
|
|
+ user.setUpdateTime(LocalDateTime.now());
|
|
|
+ this.update(user);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Result updatePwd(PasswordDto param) {
|
|
|
SysUserEntity user = this.findByUserName(JwtUtil.getUsername(getToken()));
|
|
@@ -207,5 +234,20 @@ public class SysUserServiceImpl extends IBaseServiceImpl<SysUserEntity, Long> im
|
|
|
return Result.success(sysRoleService.findAll(condition));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result<SysUserEntity> detail(Long id) {
|
|
|
+// SysUserEntity user = this.findById(id);
|
|
|
+//
|
|
|
+// if (user == null) {
|
|
|
+// log.error("用户不存在: {}", id);
|
|
|
+// return Result.failure("用户不存在");
|
|
|
+// }
|
|
|
+
|
|
|
+ SysUserEntity user = entityMapper.detailMapper(id);
|
|
|
+
|
|
|
+
|
|
|
+ return Result.success(user);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|