当前位置:网站首页>An API agile development tool is introduced

An API agile development tool is introduced

2020-12-08 12:28:57 Taro source code


The original

As simple as possible , Complete as many requirements as possible . By way of agreement Achieving a unified standard . Say goodbye to overtime , Refuse to repeat work , Keep away from moving bricks

characteristic

  1. For rapid development API Interface . No more definition of Controller,Service,Dao,Mybatis,xml,Entity,VO And so on .
  2. Visual interface , Automatically encapsulate input parameters to executable scripts , Support all relational databases SQL Execute statement , Non relational MONGODB Query statement . Welcome to expand
  3. Based solely on springboot2.x As springboot Project stater Way integration , No invasive , New and old projects can be quickly integrated
  4. Just write a line of code to complete most of the business requirements development , Use difficulty level ( test or Operation and maintenance ) You can also participate in the development of
  5. Online dynamic compilation , No need to restart , Immediate effect , Multiple data source operations
  6. version control , Historical comparison , Rollback and other functions
  7. Remote one click publishing to online environment
  8. on-line POSTMAN debugging , preservation POSTMAN Automatic generation of information or tripartite documents , History call record store , Plasticizing
  9. Code hinting ,SQL Tips , Grammar tip
  10. User management control , Security control , And historical behavior records
  11. After many project verifications , Traditional business development , Server side efficiency can be improved 3-5 times , Front and rear end joint debugging improves efficiency 1 times , Test efficiency 2 Times promotion

Traditional development steps :

  1. Add a table
  2. Create a solid object , Mapping this table
  3. establish API Enter the reference VO
  4. establish API The ginseng VO
  5. establish Controller
  6. establish Service
  7. establish Dao
  8. establish Mapper, xml perhaps JPA
  9. stay mysql client , perhaps mongo Write and execute script statements in the client , Copy it into the code
  10. Restart again and again , Self test the interface
  11. To write API file
  12. Complete a function point development

Use tools like mybatis plus,jpa, perhaps idea Of Easy code,MybatisCodeHelperPro Can generate some related code based on single table operation with one key , But for business scenarios , Maybe like to be more flexible , Code execution is more efficient in some ways , And a project in development , It's never just a single table operation

On the market , Provides APIJSON and GraphQL Wait for solutions , These two tools are relatively flexible in operating databases , But it's difficult to operate , And high learning costs , And it's limited for the scene , If you want to implement simple business processing logic will be more complex

that , I have a hope , It can look like mybatis xml, image metabase BI, equally , Can operate the native database query and operation statement directly , And there can be springboot Of restful This industry standard interface definition / And how to define parameters , And in a unified way , Omit three layers MVC The definition of , And it can do some logical processing on the data , To meet diversified business needs . It's better to be in the form of a plug-in , Can be well integrated into existing projects , It will not affect the existing business logic processing

This is one of the tools I'm going to introduce #Rocket API#

Different from the first two types of design, the difference is that :

  1. be based on springboot Development . Including the registration of the interface , Parameter acquisition , Input and output message conversion , It's all based on springboot The ecological environment , Can be integrated into without invasion springboot In the project , If you have based on springboot The global exception handling is realized , Return values are encapsulated uniformly , Authority control, etc , Never mind , It's all under your control
  2. Refer to mybatis How to define the parameters of , The difference is that the default is greater than the configuration logic , The injection of implementation parameters comes directly from request parameters , The tradition is omitted MVC Entity class , Method ,VO Wait for the definition
  3. Internal functions are provided by default , Can be very simple to achieve Multiple tables / The increase of multi database / Delete / Change / check , export , Import , Upload , download , Paging query and other functions
  4. Provides the basis for Groovy Grammar analysis of , Can achieve Groovy Some logical processing of
  5. Provides a call to springboot bean Object method and other arbitrary java Defined static class , Methods and objects , This means that I can call publicly defined classes , Or as previously defined in the project service,dao, and utils
  6. Because it's based on groovy Dynamic parsing , So the code changes , Or online problems can be handled without restarting the service , It also can complete function development and problem handling without upgrading code , This will be a big improvement in development efficiency
  7. Traditional business development , It's not just server-side development , And the corresponding document generation , Front and rear butt joint , And Test Coordination .“Rocket API” Provides POSTMAN The operation page of , Can set the request value of the parameter , Request type , Save the response, etc , Give the front end real data docking , Rather than class yapi, perhaps swagger And the fake data that can't be used . Based on these real request parameters and return values , Provides external interface capabilities , The test team can use this to do the smoke test of the interface , And one click generation of documents

Show me

1 Minutes to develop an interface

Interface function logic page

Interface function self test page

Document and presentation address :#Rocket API#

Integration mode :

1. Add dependency

<dependency>
    <groupId>com.github.alenfive</groupId>
    <artifactId>rocket-api-boot-starter</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

2. Data source configuration

@Component
public class DefaultDataSourceManager extends DataSourceManager {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @PostConstruct
    public void init() {
        Map<String,DataSourceDialect> dialects = new HashMap<>();
        dialects.put("mysql",new SqlDataSource(jdbcTemplate,true));
        super.setDialectMap(dialects);
    }
}

3. New table script view :

https://gitee.com/alenfive/rocket-api-doc/wikis/pages?sort_id=2670007&doc_id=859283

Start project , Access address : http://localhost:8080/interface-ui

This article is from WeChat official account. - Taro Road source code (javayuanma) , author : Click to follow ????

The source and reprint of the original text are detailed in the text , If there is any infringement , Please contact the yunjia_community@tencent.com Delete .

Original publication time : 2020-12-06

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[Taro source code]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201208122832800u.html