{"record":{"id":"62a06ecf04630a70","repo":"jeecgboot/JeecgBoot","slug":"msg","errorCode":null,"errorMessage":"您已是该租户成员{msg}","messagePattern":"您已是该租户成员(.+?)","errorType":"exception","errorClass":"JeecgBootBizTipException","httpStatus":null,"severity":"warning","filePath":"jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTenantServiceImpl.java","lineNumber":247,"sourceCode":"        SysTenant one = this.getOne(query);\n        //需要返回租户id(用于前台更新缓存),返回0则代表当前租户门牌号不存在\n        if(null == one){\n            return 0;\n        }else{\n            LambdaQueryWrapper<SysUserTenant> relationQuery = new LambdaQueryWrapper<>();\n            relationQuery.eq(SysUserTenant::getTenantId,one.getId());\n            relationQuery.eq(SysUserTenant::getUserId,userId);\n            SysUserTenant relation = userTenantMapper.selectOne(relationQuery);\n            if(relation != null){\n                String msg = \"\";\n                if(CommonConstant.USER_TENANT_UNDER_REVIEW.equals(relation.getStatus())){\n                    msg = \",状态:审核中\";\n                }else if(CommonConstant.USER_TENANT_REFUSE.equals(relation.getStatus())){\n                    throw new JeecgBootBizTipException(\"管理员已拒绝您加入租户,请联系租户管理员\");\n                }else if(CommonConstant.USER_TENANT_QUIT.equals(relation.getStatus())){\n                    msg = \",状态:已离职\";\n                }\n                throw new JeecgBootBizTipException(\"您已是该租户成员\"+msg);\n            }\n            //用户加入门牌号审核中状态\n            SysUserTenant tenant = new SysUserTenant();\n            tenant.setTenantId(one.getId());\n            tenant.setUserId(userId);\n            tenant.setStatus(CommonConstant.USER_TENANT_UNDER_REVIEW);\n            userTenantMapper.insert(tenant);\n\n            // QQYUN-4526【应用】组织加入通知\n            sendMsgForApplyJoinTenant(userId, one);\n            return tenant.getTenantId();\n        }\n    }\n\n    @Override\n    public Integer countCreateTenantNum(String userId) {\n        return this.userTenantMapper.countCreateTenantNum(userId);\n    }","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTenantServiceImpl.java#L229-L265","documentation":"Thrown in the same apply-to-join flow when an existing relation is found with status under-review (审核中) or quit (已离职). The msg variable is appended (',状态:审核中' or ',状态:已离职') so the user knows the precise existing state. Note the 'refuse' status is handled by a separate throw (error 207).","triggerScenarios":"Applying to join a tenant where the user already has a relation that is either pending review or marked as resigned/quit. The method builds msg then throws a single consolidated JeecgBootBizTipException.","commonSituations":"User already applied and is waiting for approval then clicks apply again; a former employee (quit status) tries to rejoin without admin resetting the relation.","solutions":["If status is under-review, wait for admin approval instead of re-applying.","If status is quit, ask the admin to reset the relation (delete the row or change status) so a fresh application can be created.","Frontend should disable the 'apply' button when a relation already exists for that tenant.","Admin reviews sys_user_tenant for the user/tenant pair and resolves the stale state."],"exampleFix":"// before (user keeps clicking apply)\nsysTenantService.applyJoinTenant(tenantId);\n\n// after (frontend guard)\nconst existing = await checkExistingRelation(tenantId);\nif (existing) {\n    notify(`您已是该组织成员，状态：${statusLabel(existing.status)}`);\n    return;\n}\nsysTenantService.applyJoinTenant(tenantId);","handlingStrategy":"validation","validationCode":"SysUserTenant rel = userTenantMapper.getUserTenantByTenantId(userId, tenantId);\nif (rel != null) {\n    return Result.ok(\"已有关系，状态：\" + statusLabel(rel.getStatus()));\n}","typeGuard":null,"tryCatchPattern":"try {\n    sysTenantService.applyJoinTenant(tenantId);\n} catch (JeecgBootBizTipException e) {\n    if (e.getMessage().contains(\"已是该租户成员\")) {\n        return Result.error(e.getMessage()); // show the appended status\n    }\n    throw e;\n}","preventionTips":["Check for an existing relation before allowing a new application.","Disable the apply button when a relation already exists.","Admin resolves stale under-review/quit relations."],"tags":["tenant","state-conflict","jeecg-boot"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}