Restful the SAM interface development

1.SAM end API interface

Fixed Account online account authentication module

img

img

Reference profile configuration template project calls Relations

img

1.1API specification

API request address specification:

The use of 26 lowercase letters in English, using the "_" connection between English words.

Example: GET Request

http://server_ip:port/sam-boot/api/macc/account/get/{uuid}?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

API parameters and Request Return parameter specification:

Ø are transmitted using Json Object Format

Ø hump method using field names.

Ø field is named with the correct English words, and try to express the meaning of this field is correct.

Example: new network request, POST request (note the red field values ​​are hump method)

2. API development

2.1 Rest implement (Web)

2.1.1 Spring-cxf.xml configuration

url is determined according to the interface module for the Fixed Account, so that the interface in the sam-macc

Wherein address = "/ macc" indicates that the server address path

img

2.1.2 AccountRest class implementation

img

2.1.3 Spring-Dubbo.xml configuration

Call common.dubbo.provider defined good way to pass data over from the SAM

img

2.2 AccountService class implements (Service)

2.2.1 Packaging BeanPo

For FixedAccount entity bean SAM does not require the filter to the properties of

img

2.2.2 AccountService class implementation

2.1.2 facilitate business logic Rest call, returns a response

img

2.3 common module defining services (DAO)

2.3.1 define service interfaces

Dubbo distributed principle to provide services

img

img

2.3.2 Data Register Service xml configuration

img

2.3.3 implement 2.21provider interface services

img

2.3.4 New Dao operating in sql

img

3.API test

Use Postman test, install software on their own Baidu

After opening the Postman can import the following links:

https://www.getpostman.com/collections/065a4e6acc8c04e43fbe

Note: additions and modifications should be added to submit the form FixAccountPo objects

img

3.1 Queries

http://server_ip:port/sam-boot/api/macc/account/get/{uuid}?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

http://localhost:8081/sam_boot_war_exploded/api/macc/account/get/iIemrWuXvlfghehCLUyygKkaERuhjYcR?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

img

3.2 increase

http://server_ip:port/sam-boot/api/macc/account/create/{tenantName}/{userName}/{groupId}?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

http://localhost:8081/sam_boot_war_exploded/api/macc/account/create/super_tenant/admin/186?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

img

img

Require synchronization account, you can add

img

img

3.3 Delete

http://server_ip:port/sam-boot/api/macc/account/delete/{uuid}?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

http://localhost:8081/sam_boot_war_exploded/api/macc/account/delete/81540331814175274503276383691486?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

img

img

3.4 Modify

http://server_ip:port/sam-boot/api/macc/account/update/{tenantName}/{userName}/{groupId}?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

http://localhost:8081/sam_boot_war_exploded/api/macc/account/update/super_tenant/admin/186?access_token=token_for_test_ABCDEFG&ishttps=false&tenantId=1

img

Guess you like

Origin www.cnblogs.com/binjz/p/12501374.html