parent
6418ed3173
commit
cdef7d18ad
17 changed files with 710 additions and 416 deletions
@ -0,0 +1,27 @@ |
|||||||
|
package org.springblade.system.service; |
||||||
|
|
||||||
|
import org.springblade.system.pojo.entity.User; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
*/ |
||||||
|
public interface IUserExtService { |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据角色别名查询所有用户 |
||||||
|
* |
||||||
|
* @param roleAlias 角色别名 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public List<User> listAllByRole(String roleAlias); |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据角色ids查询所有用户 |
||||||
|
* |
||||||
|
* @param roleIds 角色ids |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
public List<User> listAllByRoleIds(String roleIds); |
||||||
|
} |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
package org.springblade.system.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||||
|
import jakarta.annotation.Resource; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.Func; |
||||||
|
import org.springblade.system.pojo.entity.Role; |
||||||
|
import org.springblade.system.pojo.entity.User; |
||||||
|
import org.springblade.system.service.IRoleService; |
||||||
|
import org.springblade.system.service.IUserExtService; |
||||||
|
import org.springblade.system.service.IUserSearchService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Service |
||||||
|
@Data |
||||||
|
@Slf4j |
||||||
|
public class UserExtServiceImpl implements IUserExtService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private IRoleService roleService; |
||||||
|
@Resource |
||||||
|
private IUserSearchService userSearchService; |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<User> listAllByRole(String roleAlias) { |
||||||
|
if (StringUtils.isBlank(roleAlias)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
QueryWrapper<Role> qw = new QueryWrapper<Role>().eq("ROLE_ALIAS", roleAlias); |
||||||
|
Role role = roleService.getOne(qw); |
||||||
|
if (role == null) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return userSearchService.listByRole(List.of(role.getId())); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<User> listAllByRoleIds(String roleIds) { |
||||||
|
return userSearchService.listByRole(Func.toLongList(roleIds)); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue