use of com.hb0730.boot.admin.project.system.role.model.entity.RoleEntity in project boot-admin by hb0730.
the class RoleServiceImpl method save.
@Override
@Transactional(rollbackFor = Exception.class)
public boolean save(@Nonnull RoleExtDTO dto) {
RoleEntity entity = dto.convertTo();
boolean result = super.save(entity);
Long id = entity.getId();
List<Long> deptIds = dto.getDeptIds();
if (!CollectionUtils.isEmpty(deptIds) && Objects.nonNull(id)) {
roleDeptService.saveRoleDepts(id, deptIds);
}
return result;
}
use of com.hb0730.boot.admin.project.system.role.model.entity.RoleEntity in project boot-admin by hb0730.
the class RoleServiceImpl method updateById.
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateById(@Nonnull Long id, @Nonnull RoleExtDTO dto) {
RoleEntity entity = dto.convertTo();
entity.setId(id);
boolean result = this.updateById(entity);
updateRoleDepts(id, dto.getDeptIds());
return result;
}
use of com.hb0730.boot.admin.project.system.role.model.entity.RoleEntity in project boot-admin by hb0730.
the class UserInfoServiceImpl method loadUserByUsername.
@Override
public UserDTO loadUserByUsername(String username) {
UserAccountEntity accountEntity = accountService.findUserAccountByUsername(username);
if (null == accountEntity) {
return null;
}
Long userId = accountEntity.getUserId();
UserInfoEntity entity = super.getById(userId);
UserDTO user = BeanUtil.toBean(entity, UserDTO.class);
assert user != null;
user.setUsername(accountEntity.getUsername());
user.setPassword(accountEntity.getPassword());
// 用户角色
Collection<Long> roleIds = userRoleService.findRoleByUserId(userId);
if (CollectionUtils.isEmpty(roleIds)) {
return user;
}
List<RoleEntity> roles = roleService.findEnabledRoleByIds(roleIds);
if (CollectionUtils.isEmpty(roles)) {
return user;
}
Map<Long, String> roleMap = roles.parallelStream().collect(Collectors.toMap(RoleEntity::getId, RoleEntity::getCode));
user.setRoleIds(roleMap.keySet());
user.setRole(roleMap.values());
// 权限
Map<Long, List<Long>> permission = rolePermissionService.findPermissionIdByRoleId(roleIds);
if (CollectionUtils.isEmpty(permission)) {
return user;
}
Set<Long> permissionIds = permission.values().stream().flatMap(List::stream).collect(Collectors.toSet());
List<PermissionEntity> permissionEntities = permissionService.findEnabledPermissionByIds(permissionIds);
if (CollectionUtils.isEmpty(permissionEntities)) {
return user;
}
Map<Long, String> permissionMap = permissionEntities.parallelStream().collect(Collectors.toMap(PermissionEntity::getId, PermissionEntity::getPermission));
user.setPermission(permissionMap.values());
user.setPermissionIds(permissionMap.keySet());
// 岗位
List<Long> postIds = userPostService.findPostIdByUserIds(Collections.singletonList(userId));
user.setPostIds(postIds);
return user;
}
use of com.hb0730.boot.admin.project.system.role.model.entity.RoleEntity in project boot-admin by hb0730.
the class RoleServiceImpl method updateById.
@Override
public boolean updateById(RoleEntity entity) {
RoleEntity e1 = super.getById(entity);
BeanUtil.copyProperties(entity, e1);
return super.updateById(e1);
}
Aggregations