租户条件从常量类配置方式修改为nacos上拉取配置
| | |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_TOO_MANY_FAILS); |
| | | } |
| | | |
| | | //超级管理员配置文件配置账号密码,实现登录, 默认租户id为000000 |
| | | if(tenantId.equals(this.tenantId)){ |
| | | //超级管理员配置文件配置账号密码,实现登录, 默认租户id和超管为配置出来的 |
| | | if(tenantId.equals(this.tenantId) && userName.equals(username)){ |
| | | if (!this.userName.equals(username) && !password.equalsIgnoreCase(this.password)) { |
| | | setFailCount(tenantId, username, count,strategy.getLockingTime()); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | |
| | | if (tenant == null || tenant.getId() == null) { |
| | | throw new UserDeniedAuthorizationException(TokenUtil.USER_HAS_NO_TENANT); |
| | | } |
| | | if (StringUtil.equalsIgnoreCase(tenant.getTenantId(), BladeConstant.ADMIN_TENANT_ID)) { |
| | | if (StringUtil.equalsIgnoreCase(tenant.getTenantId(), nacosConfigCache.getAdminUserInfo().getTenantId())) { |
| | | return false; |
| | | } |
| | | if (getTenantProperties().getLicense()) { |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.system.cache.DictCache; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.entity.Dept; |
| | | import com.vci.ubcs.system.enums.DictEnum; |
| | | import com.vci.ubcs.system.service.IDeptService; |
| | |
| | | public class DeptController extends BladeController { |
| | | |
| | | private final IDeptService deptService; |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | @ApiOperation(value = "列表", notes = "传入dept") |
| | | public R<List<DeptVO>> list(@ApiIgnore @RequestParam Map<String, Object> dept, BladeUser bladeUser) { |
| | | QueryWrapper<Dept> queryWrapper = Condition.getQueryWrapper(dept, Dept.class); |
| | | List<Dept> list = deptService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Dept::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | List<Dept> list = deptService.list((!bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())) ? queryWrapper.lambda().eq(Dept::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(DeptWrapper.build().listNodeVO(list)); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.cache.SysCache; |
| | | import com.vci.ubcs.system.entity.Role; |
| | | import com.vci.ubcs.system.service.IRoleService; |
| | |
| | | public class RoleController extends BladeController { |
| | | |
| | | private final IRoleService roleService; |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | public R<IPage<RoleVO>> list(@ApiIgnore @RequestParam Map<String, Object> role, BladeUser bladeUser, Query query) { |
| | | QueryWrapper<Role> queryWrapper = Condition.getQueryWrapper(role, Role.class); |
| | | IPage<Role> page = roleService.page(Condition.getPage(query), |
| | | (!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | (!bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())) ? queryWrapper.lambda().eq(Role::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(RoleWrapper.build().pageNodeVO(page)); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.entity.Tenant; |
| | | import com.vci.ubcs.system.entity.TenantPackage; |
| | | import com.vci.ubcs.system.service.ITenantPackageService; |
| | |
| | | |
| | | private final ITenantPackageService tenantPackageService; |
| | | |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<Tenant>> list(@ApiIgnore @RequestParam Map<String, Object> tenant, Query query, BladeUser bladeUser) { |
| | | QueryWrapper<Tenant> queryWrapper = Condition.getQueryWrapper(tenant, Tenant.class); |
| | | IPage<Tenant> pages = tenantService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Tenant::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | IPage<Tenant> pages = tenantService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())) ? queryWrapper.lambda().eq(Tenant::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(pages); |
| | | } |
| | | |
| | |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<List<Tenant>> select(Tenant tenant, BladeUser bladeUser) { |
| | | QueryWrapper<Tenant> queryWrapper = Condition.getQueryWrapper(tenant); |
| | | List<Tenant> list = tenantService.list((!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(Tenant::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | List<Tenant> list = tenantService.list((!bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())) ? queryWrapper.lambda().eq(Tenant::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(list); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.cache.SysCache; |
| | | import com.vci.ubcs.system.dto.MenuDTO; |
| | | import com.vci.ubcs.system.entity.*; |
| | |
| | | private final ITopMenuSettingService topMenuSettingService; |
| | | private final static String PARENT_ID = "parentId"; |
| | | private final static Integer MENU_CATEGORY = 1; |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | @Override |
| | | public List<MenuVO> lazyList(Long parentId, Map<String, Object> param) { |
| | |
| | | |
| | | @Override |
| | | public List<TreeNode> grantTree(BladeUser user) { |
| | | List<TreeNode> menuTree = user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId())); |
| | | List<TreeNode> menuTree = user.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? baseMapper.grantTree() : baseMapper.grantTreeByRole(Func.toLongList(user.getRoleId())); |
| | | return ForestNodeMerger.merge(tenantPackageTree(menuTree, user.getTenantId())); |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeNode> grantTopTree(BladeUser user) { |
| | | List<TreeNode> menuTree = user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantTopTree() : baseMapper.grantTopTreeByRole(Func.toLongList(user.getRoleId())); |
| | | List<TreeNode> menuTree = user.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? baseMapper.grantTopTree() : baseMapper.grantTopTreeByRole(Func.toLongList(user.getRoleId())); |
| | | return ForestNodeMerger.merge(tenantPackageTree(menuTree, user.getTenantId())); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<TreeNode> grantDataScopeTree(BladeUser user) { |
| | | return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantDataScopeTree() : baseMapper.grantDataScopeTreeByRole(Func.toLongList(user.getRoleId()))); |
| | | return ForestNodeMerger.merge(user.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? baseMapper.grantDataScopeTree() : baseMapper.grantDataScopeTreeByRole(Func.toLongList(user.getRoleId()))); |
| | | } |
| | | |
| | | @Override |
| | | public List<TreeNode> grantApiScopeTree(BladeUser user) { |
| | | return ForestNodeMerger.merge(user.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? baseMapper.grantApiScopeTree() : baseMapper.grantApiScopeTreeByRole(Func.toLongList(user.getRoleId()))); |
| | | return ForestNodeMerger.merge(user.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? baseMapper.grantApiScopeTree() : baseMapper.grantApiScopeTreeByRole(Func.toLongList(user.getRoleId()))); |
| | | } |
| | | |
| | | @Override |
| | |
| | | List<String> tenantIds = this.list(Wrappers.<Tenant>query().lambda().in(Tenant::getId, ids)) |
| | | .stream().map(tenant -> Func.toStr(tenant.getTenantId())).distinct().collect(Collectors.toList()); |
| | | CacheUtil.clear(SYS_CACHE, tenantIds); |
| | | if (tenantIds.contains(BladeConstant.ADMIN_TENANT_ID)) { |
| | | if (tenantIds.contains(nacosConfigCache.getAdminUserInfo().getTenantId())) { |
| | | throw new ServiceException("不可删除管理租户!"); |
| | | } |
| | | boolean tenantTemp = this.deleteLogic(ids); |
| | |
| | | </select> |
| | | |
| | | <select id="grantTree" resultMap="treeNodeResultMap"> |
| | | select id, parent_id, name as title, id as "value", id as "key" from pl_sys_menu where is_deleted = 0 order by sort |
| | | select |
| | | id, |
| | | parent_id, |
| | | name as title, |
| | | id as "value", |
| | | id as "key" |
| | | from pl_sys_menu where is_deleted = 0 order by sort |
| | | </select> |
| | | |
| | | <select id="grantTreeByRole" resultMap="treeNodeResultMap"> |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import com.vci.ubcs.system.user.excel.UserExcel; |
| | | import com.vci.ubcs.system.user.excel.UserImporter; |
| | |
| | | |
| | | private final IUserService userService; |
| | | private final BladeRedis bladeRedis; |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | /** |
| | | * 查询单条 |
| | |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<UserVO>> list(@ApiIgnore @RequestParam Map<String, Object> user, Query query, BladeUser bladeUser) { |
| | | QueryWrapper<User> queryWrapper = Condition.getQueryWrapper(user, User.class); |
| | | IPage<User> pages = userService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)) ? queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | IPage<User> pages = userService.page(Condition.getPage(query), (!bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId())) ? queryWrapper.lambda().eq(User::getTenantId, bladeUser.getTenantId()) : queryWrapper); |
| | | return R.data(UserWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "列表", notes = "传入account和realName") |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R<IPage<UserVO>> page(@ApiIgnore User user, Query query, Long deptId, BladeUser bladeUser) { |
| | | IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (bladeUser.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : bladeUser.getTenantId())); |
| | | IPage<User> pages = userService.selectUserPage(Condition.getPage(query), user, deptId, (bladeUser.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? StringPool.EMPTY : bladeUser.getTenantId())); |
| | | return R.data(UserWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean submit(User user) { |
| | | if (StringUtil.isBlank(user.getTenantId())) { |
| | | // user.setTenantId(BladeConstant.ADMIN_TENANT_ID); |
| | | // user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | // 默认设置为管理组下的用户 |
| | | user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | } |
| | |
| | | Boolean flag = true; |
| | | for (User user : users){ |
| | | if (StringUtil.isBlank(user.getTenantId())) { |
| | | user.setTenantId(BladeConstant.ADMIN_TENANT_ID); |
| | | user.setTenantId(nacosConfigCache.getAdminUserInfo().getTenantId()); |
| | | } |
| | | String tenantId = user.getTenantId(); |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | |
| | | @Override |
| | | public List<User> selectAllUser(User user, Long deptId){ |
| | | List<Long> deptIdList = SysCache.getDeptChildIds(deptId); |
| | | List<User> users = baseMapper.selectUserPage(user, deptIdList, (AuthUtil.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID) ? StringPool.EMPTY : AuthUtil.getTenantId())); |
| | | List<User> users = baseMapper.selectUserPage(user, deptIdList, (AuthUtil.getTenantId().equals(nacosConfigCache.getAdminUserInfo().getTenantId()) ? StringPool.EMPTY : AuthUtil.getTenantId())); |
| | | return users; |
| | | } |
| | | |