Search in sources :

Example 1 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class RoleResource method checkRole.

/**
 * 检查角色是否有用户信息
 *
 * @return
 */
private void checkRole(Long roleId, String roleName) {
    List<UserDo> userDoList = userService.findListByRoleId(roleId);
    ArgumentAssert.notEmpty(userDoList, () -> new BizException("操作失败!用户:" + CollUtil.convertToString(userDoList, UserDo.F_USERNAME, StringUtil.COMMA) + "所属要操作的角色:" + roleName));
}
Also used : UserDo(com.albedo.java.modules.sys.domain.UserDo) BizException(com.albedo.java.common.core.exception.BizException)

Example 2 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class RoleServiceImpl method verification.

public void verification(Set<Long> ids) {
    List<UserDo> userDoList = userRepository.findListByRoleIds(ids);
    ArgumentAssert.notEmpty(userDoList, () -> new BizException("所选角色存在用户关联,请解除关联再试!"));
}
Also used : UserDo(com.albedo.java.modules.sys.domain.UserDo) BizException(com.albedo.java.common.core.exception.BizException)

Example 3 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class UserServiceImpl method save.

@Override
public void save(@Valid UserExcelVo userExcelVo) {
    UserDto user = new UserDto();
    BeanUtils.copyProperties(userExcelVo, user);
    DeptDo deptDo = deptService.getOne(Wrappers.<DeptDo>query().lambda().eq(DeptDo::getName, userExcelVo.getDeptName()));
    if (deptDo != null) {
        user.setDeptId(deptDo.getId());
    }
    RoleDo roleDo = roleService.getOne(Wrappers.<RoleDo>query().lambda().eq(RoleDo::getName, userExcelVo.getRoleName()));
    ArgumentAssert.notNull(roleDo, () -> new BizException("无法获取角色" + userExcelVo.getRoleName() + "信息"));
    user.setRoleIdList(Lists.newArrayList(roleDo.getId()));
    saveOrUpdate(user);
}
Also used : UserDto(com.albedo.java.modules.sys.domain.dto.UserDto) BizException(com.albedo.java.common.core.exception.BizException) DeptDo(com.albedo.java.modules.sys.domain.DeptDo) UserRoleDo(com.albedo.java.modules.sys.domain.UserRoleDo) RoleDo(com.albedo.java.modules.sys.domain.RoleDo)

Example 4 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class DeptServiceImpl method checkDept.

/**
 * 检查角色是否有用户信息
 *
 * @return
 */
private void checkDept(Long deptId, String deptName) {
    List<UserDo> userDoList = userRepository.selectList(Wrappers.<UserDo>lambdaQuery().eq(UserDo::getDeptId, deptId));
    ArgumentAssert.notEmpty(userDoList, "操作失败!用户:" + CollUtil.convertToString(userDoList, UserDo.F_USERNAME, StringUtil.COMMA) + "所属要操作的部门:" + deptName);
    List<RoleDo> roleDoList = roleRepository.findListByDeptId(deptId);
    ArgumentAssert.notEmpty(roleDoList, () -> new BizException("操作失败!角色:" + CollUtil.convertToString(roleDoList, RoleDo.F_NAME, StringUtil.COMMA) + "的权限信息属于要操作的部门:" + deptName));
}
Also used : UserDo(com.albedo.java.modules.sys.domain.UserDo) BizException(com.albedo.java.common.core.exception.BizException) RoleDo(com.albedo.java.modules.sys.domain.RoleDo)

Example 5 with BizException

use of com.albedo.java.common.core.exception.BizException in project albedo by somowhere.

the class MenuServiceImpl method removeByIds.

@Override
public void removeByIds(Set<Long> ids) {
    ids.forEach(id -> {
        SysCacheUtil.delMenuCaches(id);
        // 查询父节点为当前节点的节点
        List<MenuDo> menuDoList = this.list(Wrappers.<MenuDo>query().lambda().eq(MenuDo::getParentId, id));
        ArgumentAssert.notEmpty(menuDoList, () -> new BizException("菜单含有下级不能删除"));
        roleMenuRepository.delete(Wrappers.<RoleMenuDo>query().lambda().eq(RoleMenuDo::getMenuId, id));
        // 删除当前菜单及其子菜单
        this.removeById(id);
    });
}
Also used : MenuDo(com.albedo.java.modules.sys.domain.MenuDo) RoleMenuDo(com.albedo.java.modules.sys.domain.RoleMenuDo) BizException(com.albedo.java.common.core.exception.BizException)

Aggregations

BizException (com.albedo.java.common.core.exception.BizException)22 UserDo (com.albedo.java.modules.sys.domain.UserDo)3 SneakyThrows (lombok.SneakyThrows)3 RoleDo (com.albedo.java.modules.sys.domain.RoleDo)2 AlipayClient (com.alipay.api.AlipayClient)2 DefaultAlipayClient (com.alipay.api.DefaultAlipayClient)2 IORuntimeException (cn.hutool.core.io.IORuntimeException)1 TableColumnDo (com.albedo.java.modules.gen.domain.TableColumnDo)1 TableDo (com.albedo.java.modules.gen.domain.TableDo)1 SchemeDto (com.albedo.java.modules.gen.domain.dto.SchemeDto)1 TableDto (com.albedo.java.modules.gen.domain.dto.TableDto)1 TemplateVo (com.albedo.java.modules.gen.domain.vo.TemplateVo)1 GenConfig (com.albedo.java.modules.gen.domain.xml.GenConfig)1 Job (com.albedo.java.modules.quartz.domain.Job)1 DictCacheKeyBuilder (com.albedo.java.modules.sys.cache.DictCacheKeyBuilder)1 DeptDo (com.albedo.java.modules.sys.domain.DeptDo)1 DictDo (com.albedo.java.modules.sys.domain.DictDo)1 LogOperateDo (com.albedo.java.modules.sys.domain.LogOperateDo)1 MenuDo (com.albedo.java.modules.sys.domain.MenuDo)1 RoleMenuDo (com.albedo.java.modules.sys.domain.RoleMenuDo)1