Giter Site home page Giter Site logo

doudou20188 / mybatisplus_tenantidmanager Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.17 MB

springboot + mybatisPlus 多租户的样例,仅提供实现思路方法,项目比较小,没有其他冗余代码,如果帮助到您了,不吝惜您的小手点点赞!

Java 4.00% CSS 3.21% JavaScript 89.43% HTML 3.36%

mybatisplus_tenantidmanager's Introduction

这是一个小样例子,可以拉下来单独启动,需要执行DB的SQL配置

1.项目启动

启动1 启动2 都是可以的,第一种是配置的默认跳转页 -> DefaultView.java

2.具体配置多租户

  • 2.1 TenantIdManager 设置当前系统登陆租户ID

  • 2.2 MybatisPlusConfig 配置多租户拦截器

  • 2.3 com.example.book_crud.controller.BookController.queryAll 设置租户ID,查询验证 ==> Preparing: SELECT id, type, name, description FROM tbl_book WHERE tenant_id = 233 是看到拼接了,实际CRUD都会拼接,特殊不拼接,需要额外设置拦截处理,XML应该是没有拦截的,这个待验证。

  • 2.4 com.example.book_crud.controller.BookController.findByName 常规手动写XML查询也会进行拦截处理,已验证 ==> Preparing: SELECT id, type, name, description FROM tbl_book WHERE name = ? AND tenant_id = 233

  • 2.4 关于多租户不需要拦截表的配置待补充TODO 可以选择配置或者注解模式

3.实现参考

https://www.hxstrive.com/subject/mybatis_plus.htm?id=311 https://baomidou.com/pages/aef2f2/#tenantlineinnerinterceptor

mybatisplus_tenantidmanager's People

Contributors

siquan-wen avatar doudou20188 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.