| | |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.tenant.helper.TenantHelper; |
| | | import org.dromara.system.domain.*; |
| | | import org.dromara.system.domain.bo.SysTenantBo; |
| | | import org.dromara.system.domain.vo.SysTenantVo; |
| | |
| | | lqw.eq(bo.getExpireTime() != null, SysTenant::getExpireTime, bo.getExpireTime()); |
| | | lqw.eq(bo.getAccountCount() != null, SysTenant::getAccountCount, bo.getAccountCount()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysTenant::getStatus, bo.getStatus()); |
| | | lqw.orderByAsc(SysTenant::getId); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean insertByBo(SysTenantBo bo) { |
| | | TenantHelper.enableIgnore(); |
| | | |
| | | SysTenant add = MapstructUtils.convert(bo, SysTenant.class); |
| | | |
| | | // 获取所有租户编号 |
| | |
| | | add.setTenantId(tenantId); |
| | | boolean flag = baseMapper.insert(add) > 0; |
| | | if (!flag) { |
| | | TenantHelper.disableIgnore(); |
| | | throw new ServiceException("创建租户失败"); |
| | | } |
| | | bo.setId(add.getId()); |
| | |
| | | SysDept dept = new SysDept(); |
| | | dept.setTenantId(tenantId); |
| | | dept.setDeptName(bo.getCompanyName()); |
| | | dept.setLeader(bo.getUsername()); |
| | | dept.setParentId(Constants.TOP_PARENT_ID); |
| | | dept.setAncestors(Constants.TOP_PARENT_ID.toString()); |
| | | deptMapper.insert(dept); |
| | |
| | | user.setPassword(BCrypt.hashpw(bo.getPassword())); |
| | | user.setDeptId(deptId); |
| | | userMapper.insert(user); |
| | | //新增系统用户后,默认当前用户为部门的负责人 |
| | | SysDept sd = new SysDept(); |
| | | sd.setLeader(user.getUserId()); |
| | | sd.setDeptId(deptId); |
| | | deptMapper.updateById(sd); |
| | | |
| | | // 用户和角色关联表 |
| | | SysUserRole userRole = new SysUserRole(); |
| | |
| | | config.setTenantId(tenantId); |
| | | } |
| | | configMapper.insertBatch(sysConfigList); |
| | | |
| | | TenantHelper.disableIgnore(); |
| | | return true; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean syncTenantPackage(String tenantId, String packageId) { |
| | | TenantHelper.enableIgnore(); |
| | | public Boolean syncTenantPackage(String tenantId, Long packageId) { |
| | | SysTenantPackage tenantPackage = tenantPackageMapper.selectById(packageId); |
| | | List<SysRole> roles = roleMapper.selectList( |
| | | new LambdaQueryWrapper<SysRole>().eq(SysRole::getTenantId, tenantId)); |
| | |
| | | roleMenuMapper.delete( |
| | | new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, roleIds).notIn(!menuIds.isEmpty(), SysRoleMenu::getMenuId, menuIds)); |
| | | } |
| | | TenantHelper.disableIgnore(); |
| | | return true; |
| | | } |
| | | } |