Search in sources :

Example 1 with SysRole

use of vip.mate.system.entity.SysRole in project matecloud by matevip.

the class SysRoleController method allList.

/**
 * 所有角色列表
 *
 * @return List
 */
@PreAuth
@Log(value = "所有角色列表")
@GetMapping("/all-list")
@ApiOperation(value = "所有角色列表")
public Result<?> allList() {
    // 设置一个未授权的角色信息,提供给前端使用
    SysRole sysRole = new SysRole();
    sysRole.setId(NumberUtil.parseLong(SystemConstant.ROLE_DEFAULT_ID));
    sysRole.setRoleName(SystemConstant.ROLE_DEFAULT_VALUE);
    // 查询所有角色列表
    List<SysRole> list = sysRoleService.list();
    // 增加未授权角色信息
    list.add(sysRole);
    // 业务返回
    return Result.data(list);
}
Also used : SysRole(vip.mate.system.entity.SysRole) PreAuth(vip.mate.core.auth.annotation.PreAuth) Log(vip.mate.core.log.annotation.Log) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with SysRole

use of vip.mate.system.entity.SysRole in project matecloud by matevip.

the class SysRoleServiceImpl method set.

@Override
@Transactional(rollbackFor = Exception.class)
public boolean set(SysRole sysRole) {
    this.saveOrUpdate(sysRole);
    if (ObjectUtil.isNotEmpty(sysRole.getMenu())) {
        List<SysRolePermission> collect = sysRole.getMenu().stream().map(s -> {
            SysRolePermission sysRolePermission = new SysRolePermission();
            sysRolePermission.setMenuId(Long.valueOf(s));
            sysRolePermission.setRoleId(sysRole.getId());
            return sysRolePermission;
        }).collect(Collectors.toList());
        // 根据角色ID删除所有菜单值
        sysRolePermissionService.remove(Wrappers.<SysRolePermission>lambdaQuery().eq(SysRolePermission::getRoleId, sysRole.getId()));
        // 重新写入角色对应的权限值
        sysRolePermissionService.saveBatch(collect);
    }
    return Boolean.TRUE;
}
Also used : ISysUserService(vip.mate.system.service.ISysUserService) SysUser(vip.mate.system.entity.SysUser) Arrays(java.util.Arrays) ObjectUtil(cn.hutool.core.util.ObjectUtil) ISysRolePermissionService(vip.mate.system.service.ISysRolePermissionService) Autowired(org.springframework.beans.factory.annotation.Autowired) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SysRolePermission(vip.mate.system.entity.SysRolePermission) Service(org.springframework.stereotype.Service) Map(java.util.Map) ISysRoleService(vip.mate.system.service.ISysRoleService) SysRolePOI(vip.mate.system.poi.SysRolePOI) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) Search(vip.mate.core.database.entity.Search) SysRoleVO(vip.mate.system.vo.SysRoleVO) SysRole(vip.mate.system.entity.SysRole) PageUtil(vip.mate.core.database.util.PageUtil) Collectors(java.util.stream.Collectors) StrUtil(cn.hutool.core.util.StrUtil) List(java.util.List) SysRoleMapper(vip.mate.system.mapper.SysRoleMapper) Lazy(org.springframework.context.annotation.Lazy) IPage(com.baomidou.mybatisplus.core.metadata.IPage) BeanUtils(org.springframework.beans.BeanUtils) Transactional(org.springframework.transaction.annotation.Transactional) SysRolePermission(vip.mate.system.entity.SysRolePermission) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with SysRole

use of vip.mate.system.entity.SysRole in project matecloud by matevip.

the class SysRoleServiceImpl method export.

@Override
public List<SysRolePOI> export() {
    LambdaQueryWrapper<SysRole> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(SysRole::getIsDeleted, 0);
    List<SysRole> sysRoles = this.baseMapper.selectList(queryWrapper);
    return sysRoles.stream().map(sysRole -> {
        SysRolePOI sysRolePOI = new SysRolePOI();
        BeanUtils.copyProperties(sysRole, sysRolePOI);
        return sysRolePOI;
    }).collect(Collectors.toList());
}
Also used : ISysUserService(vip.mate.system.service.ISysUserService) SysUser(vip.mate.system.entity.SysUser) Arrays(java.util.Arrays) ObjectUtil(cn.hutool.core.util.ObjectUtil) ISysRolePermissionService(vip.mate.system.service.ISysRolePermissionService) Autowired(org.springframework.beans.factory.annotation.Autowired) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SysRolePermission(vip.mate.system.entity.SysRolePermission) Service(org.springframework.stereotype.Service) Map(java.util.Map) ISysRoleService(vip.mate.system.service.ISysRoleService) SysRolePOI(vip.mate.system.poi.SysRolePOI) ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) Search(vip.mate.core.database.entity.Search) SysRoleVO(vip.mate.system.vo.SysRoleVO) SysRole(vip.mate.system.entity.SysRole) PageUtil(vip.mate.core.database.util.PageUtil) Collectors(java.util.stream.Collectors) StrUtil(cn.hutool.core.util.StrUtil) List(java.util.List) SysRoleMapper(vip.mate.system.mapper.SysRoleMapper) Lazy(org.springframework.context.annotation.Lazy) IPage(com.baomidou.mybatisplus.core.metadata.IPage) BeanUtils(org.springframework.beans.BeanUtils) Transactional(org.springframework.transaction.annotation.Transactional) SysRole(vip.mate.system.entity.SysRole) SysRolePOI(vip.mate.system.poi.SysRolePOI) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

SysRole (vip.mate.system.entity.SysRole)3 ObjectUtil (cn.hutool.core.util.ObjectUtil)2 StrUtil (cn.hutool.core.util.StrUtil)2 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 IPage (com.baomidou.mybatisplus.core.metadata.IPage)2 Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)2 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 BeanUtils (org.springframework.beans.BeanUtils)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Lazy (org.springframework.context.annotation.Lazy)2 Service (org.springframework.stereotype.Service)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Search (vip.mate.core.database.entity.Search)2 PageUtil (vip.mate.core.database.util.PageUtil)2 SysRolePermission (vip.mate.system.entity.SysRolePermission)2 SysUser (vip.mate.system.entity.SysUser)2