{"id":43524452,"url":"https://github.com/wangzihaogithub/mybatis-intercept","last_synced_at":"2026-02-03T14:37:05.993Z","repository":{"id":65507802,"uuid":"561641643","full_name":"wangzihaogithub/mybatis-intercept","owner":"wangzihaogithub","description":"Mybatis拦截器 （可以用于租户隔离）","archived":false,"fork":false,"pushed_at":"2025-08-22T14:56:11.000Z","size":166,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-22T16:50:13.052Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wangzihaogithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-04T06:30:14.000Z","updated_at":"2025-08-22T14:56:15.000Z","dependencies_parsed_at":"2024-01-23T13:26:11.647Z","dependency_job_id":"eca2e6cd-0f85-44e9-9abf-def68a58ad1c","html_url":"https://github.com/wangzihaogithub/mybatis-intercept","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/wangzihaogithub/mybatis-intercept","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangzihaogithub%2Fmybatis-intercept","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangzihaogithub%2Fmybatis-intercept/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangzihaogithub%2Fmybatis-intercept/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangzihaogithub%2Fmybatis-intercept/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wangzihaogithub","download_url":"https://codeload.github.com/wangzihaogithub/mybatis-intercept/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangzihaogithub%2Fmybatis-intercept/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29047566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T10:09:22.136Z","status":"ssl_error","status_checked_at":"2026-02-03T10:09:16.814Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-03T14:37:05.760Z","updated_at":"2026-02-03T14:37:05.964Z","avatar_url":"https://github.com/wangzihaogithub.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mybatis-intercept\n\n#### 介绍\nMybatis拦截器 （可以用于租户隔离）\n\n1. InjectColumnValuesInsertSQLInterceptor.class = 自动给（insert语句, replace语句）加字段\n\n2. InjectColumnValuesUpdateSQLInterceptor.class = 自动给（update语句）加字段属性值， 如果值为空\n\n3. InjectConditionSQLInterceptor.class = 自动给（select语句, update语句, delete语句, insert from语句）加条件\n\n4. InjectMapperParametersInterceptor.class = 给 mapper.xml 加全局内置属性（可以在 mapper.xml 里直接访问这些属性）\n\n\n#### 软件架构\n软件架构说明\n\n\n#### 安装教程\n\n1.  添加maven依赖, 在pom.xml中加入 [![Maven Central](https://img.shields.io/maven-central/v/com.github.wangzihaogithub/mybatis-intercept.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:com.github.wangzihaogithub%20AND%20a:mybatis-intercept)\n\n\n        \u003c!-- https://mvnrepository.com/artifact/com.github.wangzihaogithub/mybatis-intercept --\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003ecom.github.wangzihaogithub\u003c/groupId\u003e\n            \u003cartifactId\u003emybatis-intercept\u003c/artifactId\u003e\n            \u003cversion\u003e1.0.17\u003c/version\u003e\n        \u003c/dependency\u003e\n        \n2.  配置 mybatis-config.xml\n\n`\n\n\n        \u003c?xml version=\"1.0\" encoding=\"UTF-8\" ?\u003e\n        \u003c!DOCTYPE configuration\n                PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\"\n                \"http://mybatis.org/dtd/mybatis-3-config.dtd\"\u003e\n        \u003cconfiguration\u003e\n             \u003cplugins\u003e\n                \u003c!-- 最后执行 --\u003e\n                \u003cplugin interceptor=\"com.ig.util.IGForceMasterJadeSQLInterceptor\"/\u003e\n        \n                \u003cplugin interceptor=\"com.github.pagehelper.PageInterceptor\"\u003e\n                    \u003cproperty name=\"helperDialect\" value=\"mysql\"/\u003e\n                    \u003cproperty name=\"params\" value=\"count=countSql\"/\u003e\n                \u003c/plugin\u003e\n        \n                \u003cplugin interceptor=\"com.github.mybatisintercept.InjectColumnValuesInsertSQLInterceptor\"\u003e\n                    \u003cproperty name=\"InjectColumnValuesInsertSQLInterceptor.skipTableNames\" value=\"biz_remark_content,tenant_position_share,biz_position_open_tenant\"/\u003e\n                    \u003cproperty name=\"InjectColumnValuesInsertSQLInterceptor.valueProvider\" value=\"com.ig.service.framework.AccessUser#getInsertAccessValue\"/\u003e\n                    \u003cproperty name=\"InjectColumnValuesInsertSQLInterceptor.columnMappings\" value=\"tenant_id=tenantId\"/\u003e\n                \u003c/plugin\u003e\n        \n                \u003cplugin interceptor=\"com.github.mybatisintercept.InjectColumnValuesUpdateSQLInterceptor\"\u003e\n                    \u003cproperty name=\"InjectColumnValuesUpdateSQLInterceptor.skipTableNames\" value=\"${ig.mybatisintercept.skip-table-names}\"/\u003e\n                    \u003cproperty name=\"InjectColumnValuesUpdateSQLInterceptor.valueProvider\" value=\"com.github.securityfilter.util.AccessUserUtil#getAccessUserValue\"/\u003e\n                    \u003cproperty name=\"InjectColumnValuesUpdateSQLInterceptor.columnMappings\" value=\"tenantId\"/\u003e\n                \u003c/plugin\u003e\n        \n                \u003c!-- 最先执行 --\u003e\n                \u003cplugin interceptor=\"com.github.mybatisintercept.InjectConditionSQLInterceptor\"\u003e\n                    \u003cproperty name=\"InjectConditionSQLInterceptor.skipTableNames\" value=\"${ig.mybatisintercept.skip-table-names}\"/\u003e\n                    \u003cproperty name=\"InjectConditionSQLInterceptor.valueProvider\" value=\"com.github.securityfilter.util.AccessUserUtil#getAccessUserValue\"/\u003e\n                    \u003cproperty name=\"InjectConditionSQLInterceptor.conditionExpression\" value=\"\n                    tenant_id = ${tenantId};\n        \n                    tenant_id in (\n                        SELECT share_tenant_id from biz_position_open_tenant WHERE position_tenant_id = ${tenantId} and delete_flag = false and biz_position_id = ${unionPositionId}\n                        UNION\n                        SELECT position_tenant_id from biz_position_open_tenant WHERE share_tenant_id = ${tenantId} and delete_flag = false and biz_position_id = ${unionPositionId}\n                        UNION\n                        select ${tenantId}\n                    );\n        \n                    tenant_id in (\n                        select source_tenant_id from pipeline_talent_corresponding_relation where pipeline_id = ${unionPipelineId} and target_tenant_id = ${tenantId}\n                        UNION\n                        select target_tenant_id from pipeline_talent_corresponding_relation where pipeline_id = ${unionPipelineId} and source_tenant_id = ${tenantId}\n                        UNION\n                        select ${tenantId}\n                    );\n        \n                    tenant_id in (\n                        select source_tenant_id from pipeline_talent_corresponding_relation where join_id = ${unionJoinId} and target_tenant_id = ${tenantId}\n                        UNION\n                        select target_tenant_id from pipeline_talent_corresponding_relation where join_id = ${unionJoinId} and source_tenant_id = ${tenantId}\n                        UNION\n                        select ${tenantId}\n                    );\n        \n                    tenant_id = ${tenantId} or id in (\n                        SELECT pm_uid from biz_position_pm WHERE position_id = ${unionPositionId} and delete_flag = false\n                    );\n        \n                    tenant_id = ${tenantId} or id in (\n                        SELECT rec_user_id from pipeline WHERE id = ${unionPipelineId}\n                        UNION\n                        SELECT pm_uid from biz_position_pm WHERE position_id = (SELECT biz_position_id from pipeline WHERE id = ${unionPipelineId} AND delete_flag = false) and delete_flag = false\n                        UNION\n                        SELECT create_uid from pipeline_operate_log WHERE pipeline_id = ${unionPipelineId}\n                        UNION\n                        SELECT owner_id from talent WHERE id in (select talent_id from pipeline WHERE id =${unionPipelineId})\n                        UNION\n                        SELECT bd_uid from biz_corp WHERE id in (select biz_corp_id from pipeline WHERE id =${unionPipelineId})\n                    );\n        \n                    tenant_id = ${tenantId} or id in (\n                        SELECT consultant_id from talent_position_join WHERE id = ${unionJoinId}\n                        UNION\n                        SELECT pm_uid from biz_position_pm WHERE position_id = (SELECT biz_position_id from talent_position_join WHERE id = ${unionJoinId} AND delete_flag = false) and delete_flag = false\n                    );\n                    \"/\u003e\n                    \u003cproperty name=\"InjectConditionSQLInterceptor.existInjectConditionStrategyEnum\" value=\"RULE_TABLE_MATCH_THEN_SKIP_SQL\"/\u003e\n                \u003c/plugin\u003e\n\n                \u003cplugin interceptor=\"com.github.mybatisintercept.InjectMapperParametersInterceptor\"\u003e\n                    \u003cproperty name=\"InjectMapperParametersInterceptor.attrNames\" value=\"id,tenantId,com.ig.service.framework.AccessUser\"/\u003e\n                    \u003cproperty name=\"InjectMapperParametersInterceptor.valueProvider\" value=\"com.github.securityfilter.util.AccessUserUtil#getAccessUserValue\"/\u003e\n                    \u003cproperty name=\"InjectMapperParametersInterceptor.metaName\" value=\"_meta\"/\u003e\n                \u003c/plugin\u003e\n            \u003c/plugins\u003e\n        \u003c/configuration\u003e\n        \n        \n\n\n        如果是springboot项目，需要在application.yaml里加上\n            \n        mybatis.config-location: classpath:mybatis-config.xml\n\n\n`\n\n    \n\n#### 使用说明\n\n1.  xxxx\n2.  xxxx\n3.  xxxx\n\n#### 参与贡献\n\n1.  Fork 本仓库\n2.  新建 Feat_xxx 分支\n3.  提交代码\n4.  新建 Pull Request\n\n\n#### 特技\n\n1.  使用 Readme\\_XXX.md 来支持不同的语言，例如 Readme\\_en.md, Readme\\_zh.md\n2.  Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)\n3.  你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目\n4.  [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目，是综合评定出的优秀开源项目\n5.  Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)\n6.  Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangzihaogithub%2Fmybatis-intercept","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwangzihaogithub%2Fmybatis-intercept","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangzihaogithub%2Fmybatis-intercept/lists"}