CodingAir cloud service development platform is online! Address: [http://codingair.com] (http://codingair.com)

Welcome everyone to give us a free trial! (Test account: 823143047@qq.com (my mailbox) Password: 123456, you can also register yourself!)

Background introduction

CodingAir cloud service development platform is awkward?

  1. If you only allow you to write a java function to implement an http interface with certain business logic and complexity, can you do that?
  2. Have you always felt that it is a nightmare to write an interface document after writing the logic implementation? Because the interface documentation and code implementation you write are separate! In this case, writing the interface file is really redundant!
  3. Old drivers who are troubled by frequent changes in the table structure, remember the series of cumbersome operations caused by adding/changing fields each time? (XMl configuration change, DTO change, DAO change, SERVICE change, VO change ….)

Another wheel?

wrong! [CodingAir Cloud Service Development Platform] (http://codingair.com) is not a wheel, not a new framework. It just helps you solve the above three pain points, reducing the development and deployment cycle to the shortest, familiar with you. Java language, a series of toolkits you have used, streamline the development of http interface to the extreme!

Your 80% choice!

[CodingAir Cloud Service Development Platform] (http://codingair.com) does not solve all the scenarios of business development. It does not want to solve all business scenarios. You should recall carefully that 80% of the so-called business logic you wrote is not Except for CRUD, only if /else/ for ?

If yes, welcome to the car! [CodingAir Cloud Service Development Platform] (http://codingair.com) is the 80% best choice you are looking for!

Prerequisite knowledge

  1. Certain java programming knowledge
  2. Certain sql operation knowledge

Quick Start

1. Create Interface & Document

Add an interface, fill in the interface name, interface path and other information, and submit it for saving.

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Create Interface Document Tutorial_1.png)

Interface settings, enter the [interface settings] tab bar, set the request and response parameter format

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Create Interface Document Tutorial_2.png)

Set request and response body

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Create Interface Documentation Tutorial _3.png)

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Create Interface Documentation Tutorial _4.png)

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Create Interface Documentation Tutorial _6.png)

2. Open the browser access interface!

You can directly click the /user/info url link in the interface document to open the browser tab access interface. The fixed host is: https://api.zhouzhipeng.com, and the suffix is ​​spliced ​​to the url you defined. can.

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Create Interface Documentation Tutorial _7.png)

3. Custom interface logic (marked!)

You will find that the return data of the interface you wrote now https://api.zhouzhipeng.com/user/info is fixed, so how do you make it "moving"? Enter the [code implementation] tab bar

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Code Implementation Tutorial_1.png)

Don’t worry about the specific logic of the code that appears in front of you, as detailed later. Simple and rude, we first change the name and age of the return value, as shown below:

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Code Implementation Tutorial_2.png)

Then access the interface url (if it has been opened, remember to refresh the browser):

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Code Implementation Tutorial _3.png)

Or you can directly click on the "Run" button in the [Code Implementation] column to view the results returned by the interface:

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Code Implementation Tutorial _4.png)

The above is just a simple logic customization. The reality is that we have to operate multiple database tables frequently. The guest officer should follow the next section. [Build a model]

4. Create a model (marked!)

First enter the [Model] page, the model is exclusive to each project, all interfaces under a project can operate the model. You can understand that the model is a table in the database.

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Model Operation Tutorial_1.png)

** ! Be sure to follow the order of operation 1, 2, 3, etc.

Add fields to the model and fill in the field information. Click on the red arrow "+" button in the picture!

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Model Operation Tutorial_2.png)

The last step: Don’t forget to click the [Save All] button! ! !

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Model Operation Tutorial_3.png)

In order to facilitate the query of the interface, we add some test data to the model:

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Model Operation Tutorial_4.png)

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Model Operation Tutorial_5.png)

Please follow the steps shown to add, you can add two more. (The data is added in time to save it, don’t worry ~~)

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Model Operation Tutorial_6.png)

Ok, the guest officer, with the model, use it quickly, see the next section for details!

5. Use the model in the interface (marked!)

The following operations may be very different from your traditional programming habits. It will challenge your mvc three-layered thinking, simplifying it, and breaking it first!

Let us directly restore the essence of programming! Operating data!

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial _1-1.png)

In order to prevent you from manually typing the code, please post the return code block below.

 Return Maps.of("list",sql(S(
            /*
            Select * from person
             */
        )));

Click the [Run] button below!

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial_2.png)

Things are not over yet! Do you remember the request parameters of the interface you have filled out?

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial _3.png)

Let’s try to use the parameters in the code:

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial _4.png)

return partial code reference:

 Return Maps.of("list",sql(S(
            /*
            Select * from person
            Where userId='${userId}'
             */
        ),params));

Then let’s run it:

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial _5.png)

Amount? Why don’t you have data? Open the [Display Parameters] switch in the above figure to see:

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial _6.png)

If your memory is good enough, you should be able to find that there are no users with a user id of "123" when adding model test data. It doesn’t matter, we try to change the entry to "1", then click the [Run] button to try:

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial _7.png)

Of course you can also change to "2" or other useId you just added in the model. Finally, you can also click the [Access in Browser] link:

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial _8.png)

What? Who said that it can only be accessed in the form of GET? ? On Postman! !

![](https://zhouzhipeng.com/wp-content/uploads/2018/08/Interface Operation Model Tutorial _9.png)

You are right, all interfaces created through [CodingAir Cloud Service Development Platform] (http://codingair.com) support both GET and POST request methods. The post form request body is standard. Json, the get form parameter name is fixed to _, and the parameter value is the value of the json string after url encoding.

Is it feeling amazing? ! You can tell you clearly that all of this is not magic, everything is created based on your favorite – JAVA!

Want to know some of the details and features? Please go down and look at the [Programming Guide]!

Programming Guide

  Available maven dependencies: [CodingAir Cloud Service Development Platform – available maven dependencies] (https://zhouzhipeng.com/lambda-available-maven-dependencies.html)
 
 
Commonly used tool class CommonUtils: [CodingAir cloud service development platform – CommonUtils] (https://zhouzhipeng.com/lambda-platform-commonutils.html)

1. What if Java can have multiple lines of strings? !

You may have noticed in the [Quick Start] section that you can use the Java standard multi-line comments to write when returning the json format response body or writing sql!

Under normal circumstances, java is a multi-line form that does not support standard strings, and [CodingAir Cloud Service Development Platform] (http://codingair.com/) will be implemented in a more elegant way – multi-line comments.

Use the S function

Last modified: 2019年3月29日

Author

Comments

鹏哥棒棒哒 :cowboy:

Author

还有很多要完善和改进的地方

Write a Reply or Comment

Your email address will not be published.