Based on the rapid development of Spring Boot scaffolding tyboot published

tyboot

Introduction

tyboot is a server-based scaffolding springboot, the rapid development of service-oriented monomer, service needs micro scheme can be seen another project tycloud (also perfected)

Feature

1. simplify the development process underlying business 
    a. For single-table queries, do not write sql. List, paging, do not write. 
    mapper b.dao layer just an empty interface, most businesses do not need to write any code (unless the complex report queries) in the mapper does not need xml file of mapper. 
    c.baseService a large number of generic method for using a single form object CRUD in the service layer does not need to write code, lists and pagination queries need only one line of code. 
    D. advocate single-table operation. Do not advocate the use of complex sql solve complex business problems. 
2. Reduce the cost of learning. Newcomers get started quickly, the basics of newcomers to cross the border, you can quickly enter the state of business development. 
3. Common components are integrated. redis, mq, events, mongodb etc. 
4. achieve common business model. Business model out of the box, it can greatly reduce the project development cycle. GM plans to achieve business model has 
  orders for systems, system virtual account, payment gateway, dynamic forms, reporting system, common reservation system, offers customized strategies, 
  basic data (verification code dictionaries, inside information, location information, the information stored in common file , and the operation record count) 
the third-party systems commonly integrated. SMS (Ali big fish), storage (seven cattle, Ali OSS), pay (micro-channel public platform, Alipay)

Technology stack

 1. SpringBoot 2.1.6.RELEASE
 2. MyBatis-Plus 3.x
 3. mybatis-spring-boot-starter 1.2.0
 5. Kaptcha 2.3.2
 6. jackson-databind 2.9.7
 7. springfox-swagger2 2.2.2
 8. HikariCP 2.7.9

Project structure

tyboot 
  ├─tyboot-API 
  │ ├─tyboot-API-the Boot sample project, to achieve a data dictionary, rights management, other projects of common basic functions 
  ├─tyboot-component ------ Components 
  │ ├─tyboot-component- activemq ------ integrated ActiveMQ 
  │ ├─tyboot-Component-AMQP ---------- AMQP easy integration of spring 
  │ ├─tyboot-component-cache --------- cache, for further implementation and redis package, location, pipeline, zset implement paging queries, distributed lock 
  │ ├─tyboot-component-emq ----------- integrated mqtt service EMQ 
  │ ├─tyboot -component-event --------- use spring mechanism to achieve events based on event handling mechanism rest interface 
  │ ├─tyboot-component-mongo --------- integrated mongo 
  │ ├─tyboot- component-opendata ------ integrated with popular third-party open interfaces, seven cows, fish Ali, Tencent im, Aurora push 
  │ └─tyboot-component-validation ---- parameters check 
  ├─tyboot-core-- --------- core package, example project will generally refer to
  │ ├─tyboot-core-auth --------------- user authentication, session sharing 
  │ ├─tyboot-core-foundation --------- common tools library, within the context of a thread package; Bean, File, transfer list tree structure, encryption and decryption and the like. . . . . 
  │ ├─tyboot-core-rdbms -------------- integrated mybatis, mybatisplus, simplifying packaging and servic orm General Procedure 
  │ └─tyboot-core-restful -------- ---- restful style of interface package, the integrated interface documents, uniform exception handling, request interceptor processing, and returns data encapsulation, encapsulation context 
  └─tyboot-prototype ------ common business model, the specific business scenario for encapsulation achieve 
      ├─tyboot-prototype-account ------ virtual account system 
      ├─tyboot-prototype-order -------- universal order system 
      └─tyboot-prototype-trade -------- simple payment channels to achieve, Alipay, micro letter
 	    

Directory conventions:

Example: 
tyboot-API-Privilege ---------------- following directory structure of the directory items agreed 
  	    org.typroject.api.privilege. 
  	                            Controller Interface directory ------- 
  	                            face. ------------ business layer 
  	                                Model VO -------- 
  	                                ORM .--------- data operation 
  	                                    dao ------ mapper interfaces directory 
  	                                    entity-- -po directory 
  	                                service ------ achieve business class

Promise

snake

1.entity BaseEntity need to inherit 
    the corresponding data table can not do without common fields 
 
     SEQUENCE_NBR bigint 20 primary physical key 
     REC_USER_ID varchar 32's last update ID 
     REC_DATE datetime Last update time 
     
2. Using a mybatisplus, it is not necessary to introduce the sample project mapper.xml, baseMapper the method sufficient. 
  Unless you want to perform complex queries can be introduced xml file yourself 
3. Under normal circumstances dao layer mapper interface is just a sub-empty interface, unless you want to write sql, xml or introduced, which will be written in the code.

service

1. inherited baseService
  public class LocationInfoService extends BaseService<LocationInfoModel,LocationInfo,LocationInfoMapper> 
  {}
The method 2.service not overloaded, as it will only according to the method name acquisition method instance through reflection. 
3.service layer only implementation class, abandoned the previous interfaces, do not bother. 
4. The operation of the single form of the object may not need to write the methods in the service, no need to introduce Mapper, sufficiently generic method used, 
  the paging list of queries and query only one line of code, for example:
  • Paging:
        public Page<DictionarieModel> queryDictPage(Page page, String agencyCode ,
                                                       String buType,
                                                       String dictAlias,
                                                       @Condition(Operator.like) String dictName,
                                                       String dictCode) throws Exception
            {
                return this.queryForPage(page,"排序字段",false,agencyCode,buType,dictAlias,dictName,dictCode);
            }
      Needs and the corresponding model attribute name in the same name as a parameter query. 
      Params parameter list passed baseService.queryForPage the need methods and front (queryDictPage) parameters of the same order, 
      the underlying pre-analytical method for automatically parameter name and value of the empty judgment, and then converted to the database field names for building assembled condition device. 
      Notes @Condition used to define conditional operator, the conditional operator See Operator realized, all logic and relational query is 
      currently not planning to implement or relationships.         
  • List :( agreement with the same parameters Paging)
      public List<DictionarieModel> queryDictList(String agencyCode ,
                                                     String buType,
                                                     String dictAlias,
                                                      @Condition(Operator.like)String dictName,
                                                     String dictCode) throws Exception
          {
              return this.queryForList("排序字段",false,agencyCode,buType,dictAlias,dictName,dictCode);
          }

controller

1. unified return value, the return value unified for all interfaces ResponseModel package. 
2. custom annotation @TycloudOperation used to define the interface of the access level ApiLevel, authentication control needAuth

About Cache

1. Single Form object cache, cache a single table lists have been integrated into baseService method can be updated with the object refresh or delete the cache, you can view the notes to select the method to use. 
2. Other buffer scene directly rediTemplate recommended operating 
3.tyboot-component-cache module provides paging query based redis zset; and calculating location query; redis pipeline using

Using the code generator

1. Using the code generator mybatisplus provided, see the example project.

Best Practices

1. tyboot-core and tyboot-component in the component package packaged and released to maven PW nexus unified management, 
  and business development project after project cited various examples, such examples of project business are a lot cleaner, faster package you can be upgraded at any time tyboot referenced version.

Next Steps

Improve the basic module 1. 
3. improve common business model 
4. integrated web end

Guess you like

Origin www.oschina.net/news/108323/tyboot-released