zuihou-admin-cloud 2.1 release, the new tenant model supports dynamic data sources

Update log Today:

Add:

1. Add Authentication Service (zuihou-oauth-server: Login responsible for obtaining all the permissions the user, resource, menus and other functions)
2. Refer SpringSecurity principle, adjusted login authentication services, such as refresh token associated with the interface logic
3. Referring to SpringSecurity principle, Add zuihou-security-starter module, authentication and authorization profile URI
4 new tenant model supports multiple data sources mode : dynamic changes in the data source, a data source a tenant a library
The multi-mode data related to source code and configuration, a button to switch adjusted to
6. the new multi-source mode data perfect support for distributed transactions (seata 1.0.0) 
7. the deleted when the new tenant, the tenant interfaces delete data and databases, and remove the tenant data source
8 . Add record online user functions & T people actively offline functionality

optimization:

1. rewrite rules and methods for token generation
2. optimize the user login logic, to decide whether to limit the user to repeat the log, according to the configuration multiport log.
3. Log into post an event log in.
4. Remove zuihou-shiro-starter and zuihou-user-starter module
5. Remove zuihou-zuul- * several modules module useless
6. optimization swagger configuration, the interface supports authentication parameters
7. adjustment profile: zuihou.database.bizDatabase -> zuihou.database.tenantDatabasePrefix
8. the enumerables dispersed in each service (/ enums) incorporated into the service Oauth tip after logging in, the front end of the disposable pull stored in the cache.
9. Log unified storage path: logging.file.path moved to src / main / filters / config-dev.properties  unified configuration
10. The tenant independent code modules associated permissions and services zuihou-tenant - **  module, for reducing code coupling, strengthen the independence of the system. (Conditional friends, can separate into a tenant service module)
11. The pattern of non-tenant, the tenant to separate field mode, SCHEMA / tenant data source region pattern database script.
12. The system-related background tenant simplified interface logic (zuihou-admin-ui)
13. abolished disposed before transaction statement Controller layer configuration, using annotation configuration transaction, the transaction control to adjust to the service layer to control the transaction by the annotation, the reason data is compatible with multi-source mode.
14. SuperCacheServiceImpl related methods plus transaction comment.
15. SuperCacheServiceImpl caching related operations @Cache method of removing annotations, using cacheChanel mode, preventing this call subclass, the cache can not be used bugs
16. A split context interceptor, the tenant information, the MDC isolated interceptor TenantContextHandlerInterceptor (Package tenant Related request header), MdcHandlerInterceptor (log package variables associated thread)
17. Related operation log optimization, implemented in accordance with different conditions as in example bean
configuration simplifies 18. distributed transaction service order and demo 
static method 19. SpringUtils increased release event class
20. A waste IgnoreTokenConfig, adjusted to a profile mode: IgnoreTokenProperties

repair:

1. Repair UserQuery constructor report of NPE bug   # FIX I1BXPW
2. Personal repair center Modify the bug    # FIX I1CIEN
3. perfect tenant module-related functions, and fixes a bug mentally handicapped

 

Upgrade Guide:

1. Update zuihou-admin-cloud, to be dependent on updated, according to IDEA prompt, delete zuihou-zuul-base, zuihou- zuul-authentication, zuihou-zuul-ratelimit modules
2. To update zuihou-commons (the project after the central warehouse has been released, if not want to see the source code, you can not control), to be dependent on updated, according to IDEA prompt, delete zuihou-user-starter, zuihou- shiro-starter modules
3. compile the project
4. re-import the database script ( the larger the database changes, be sure to re-run, when executed, watching: docs / sql / script shows .md import scripts based on their own circumstances)
5. nacos re-import the configuration file (configuration file changes a lot, a lot of deleted consolidated configuration)
6. start project

Tenant model:

Tenant model description advantage Shortcoming Distributed Transaction
NONE (non-tenant model)  No tenants Simple, suitable for stand-alone systems The system lacks the convenience of tenants stand by
COLUMN (field mode) Tenants share a database, a table to add a field to distinguish in service   Simple, uncomplicated, no development of perception  Data isolation, poor, poor security, data backup and recovery difficult stand by
SCHEMA (independent schema)  Each tenant a separate database (schema), the implementation of sql, increase dynamic schema before the table name Simple, no perception development, data isolation is good The configuration file must be configured root account database does not support complex nested sql sql and custom functions A bug
DATASOURCE (independent data sources)  Each is independently a tenant database (data source), executing code, dynamic switching data source It can be deployed independently database, data isolation is good, high scalability, glitch affecting Relatively complex, developers need to pay attention switched affairs issues during data source, you need more database stand by

Summary:


Based on `SpringCloud (Hoxton.SR1)` + `SpringBoot (2.2.5.RELEASE)` the SaaS service micro-scaffold, with user management, resource rights management, unified gateway authentication, Xss anti-cross-site attacks, automatic code generation, multi-storage systems, distributed transactions, and other regular tasks distributed modules, multi-service system to support parallel development, multi-service support parallel development, can be used as scaffolding to develop back-end services. Code is simple and clear structure, is very suitable for learning. The core technology employed Nacos, Fegin, Ribbon, Zuul, Hystrix, JWT Token, Mybatis, SpringBoot, Seata, Nacos, Sentinel, RabbitMQ, FastDFS other main framework and middleware.

Hope and strive to create a set from  SaaS basic framework  -  distributed micro-services architecture  -  Automated deployment  -  system monitoring  solutions. The project aims to achieve basic skills, not related to specific operations.
 

Function Point presentation:

Registration and service call:

Service registration and call Eureka implemented based on using Feign in Spring Cloud, we can do it using an HTTP request remote services can call the local method and the same coding experience, developers fully perceive this is not a remote method, more aware this is not a HTTP request.

 Authentication Service:

Permission to schedule the service to enhance the way by JWT verification, to ensure internal security services.

Load Balancing:

The service keeps the rest proxy and gateway control, in addition to the usual frequently used node.js, nginx, Spring Cloud series zuul and ribbon, can help us carry out normal gateway control and load balancing. Which extend and learn from foreign expansion project based on JWT's Zuul limit to limit the current flow plug-respect.

 Fuse mechanism:

Since taking the distribution of services, in order to avoid service calls between the "avalanche", we adopted Hystrix as fuses, to avoid the "avalanche" between services.

monitor:

Use Spring Boot Admin to monitor the operating status of each individual Service; using the turbine to view state and calling frequency interface in real time; to see the call chain between the various services through Zipkin and so on.

data permission:

Based Mybatis DataScopeInterceptor use of interceptors to achieve a simple data permissions

No sense of SaaS solutions:

Use Mybatis interceptors to achieve the interception of all SQL, modify the default Schema, in order to achieve the purpose of multi-tenant data isolation.

Secondary cache:

Using J2Cache cache operation, using a first level cache memory (the Caffeine), second-level cache use Redis. Because a large number of L2 cache reads may result in the bottleneck of the network system, the target is to reduce the number of reads L1 to L2. The frame buffer is mainly used in a clustered environment. It can also be used stand-alone, to avoid the impact of the back-end business application cache after the restart due to a cold start.

Elegant Bean conversion:

Dozer assembly employed to optimize the conversion of the DTO, DO, PO object, etc.

Front and rear end unified form validation:

Strict form validation usually takes the front + back-end and to verify, but the traditional project are only done once before and after the end of each test, the late rule change, they have to end at the same time before and after the modification. Therefore, on the basis of the package on the hibernate-validator zuihou-validator-starter starting-dependent, provides a common interface, access rules can be verified form, then the front end of the rear end of the returned usage rule, if after the rule change, only the rear end modifications.

Anti-cross-site scripting attacks (XSS):

  •      To filter all requests in the form parameter through the filter
  •      To filter all application / json type parameter Json deserializer implemented by

The current user information Injector:

 By injection annotations achieve user identity

Online API:

Since the primary function of certain swagger-ui support friendly enough, so the use of domestic open-source knife4j, and produced a stater, convenient springboot users.

Code generator:

Mybatis-plus-generator based on the custom code generator set, by configuring the annotation database fields, generated automatically enumerated classes, dictionary data annotation, SaveDTO, UpdateDTO, validation rules form annotations, annotation Swagger like.

Timing task scheduler:

Enhancements were based xxl-jobs. (Example: send task specified time, and a scheduler performing combined projects, multiple data sources)

Speaking Eureka registry page:

Please switch branches View

Large file / break / slice Resume:

Front-end webupload.js, the back-end uses NIO to achieve a break after large files fragmented resume, start Eureka, Zuul, File Services, directly open docs / chunkUploadDemo / demo.html can be tested. After testing, the local limit maximum stack memory 128M start File Services, within five minutes can be successfully uploaded 4.6G + large files, the official service will be affected user consuming bandwidth and server bandwidth, long time.

Distributed Transaction:

Ali integrated distributed transaction middleware: seata, with  high efficiency  and business  0 intrusive  way to solve the problems facing distributed transaction scenario of micro-services.

Gray Release:
    
In order to solve the frequent update service line, version rollback, fast iterative, collaborative development within the company, this project uses load balancing strategy is implemented to modify the gray ribbon of release.     

Automatic injection associated data:

To solve cross table, cross-database, cross-service properties of individual objects or paged data attributes echo of the pain associated data, support for static data attribute (data dictionary), dynamic data is automatically injected into the primary key.

Item code address

project gitee github Remark
Micro Services https://gitee.com/zuihou111/zuihou-admin-cloud https://github.com/zuihou/zuihou-admin-cloud SpringCloud version of the back-end code
Single project https://gitee.com/zuihou111/zuihou-admin-boot https://github.com/zuihou/zuihou-admin-boot SpringBoot version of the back-end code
Tenant Background https://gitee.com/zuihou111/zuihou-ui https://github.com/zuihou/zuihou-ui | To use front-end customer
Development & Operations background https://gitee.com/zuihou111/zuihou-admin-ui https://github.com/zuihou/zuihou-admin-ui The company developed in-house & Operations & operation and maintenance personnel
Code generator https://gitee.com/zuihou111/zuihou-generator https://github.com/zuihou/zuihou-generator Developers use
Core Kit https://gitee.com/zuihou111/zuihou-commons https://github.com/zuihou/zuihou-commons Core Kit

Demo (demo account does not have write permissions can only query)

project Demo Address Administrator account Ordinary Account
Tenant Background http://tangyh.top:10000/zuihou-ui zuihou / zuihou test/zuiou
Development & Operations background http://tangyh.top:180/zuihou-admin-ui demoAdmin / zuihou no

Guess you like

Origin www.oschina.net/news/114690/zuihou-admin-cloud-2-1-released
Recommended