Skip to content

RahulSinghRawatDev/SpringMVC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SpringMVCTutorial

I have implemented the following dependencies in the pom.xml file

1.spring-boot-starter-web

2.spring-boot-starter-data-jpa

3.mysql-connector-java

4.spring-boot-starter-security

5.JsonWebToken

6.spring-boot-starter-tomcat

7.jackson-core

8.jackson-dataformat-xml

9.spring-boot-starter-test

10.modelmapper

Project contains Restful api as follows:-

1. Sign Up Api

Request : -

post url :- localhost:8080/mobile-app-ws/users

headers :- 1.Content-Type : application/json 2.Accept : application/json

Body :-

 {	"firstName":"Rahul",	"lastName":"Developer",	"email": "rahul.rawat.er@gmail.com",	"password":"password",	"addresses":[	{	"city":"new delhi",	"country":"india",	"streetName":"L-92 Saket",	"postalCode":"110017",	"type":"home"	},	{	"city":"Gurgaon",	"country":"india",	"streetName":"697 Udyog vihar phase-5",	"postalCode":"220012",	"type":"office"	}	] } 

Response : -

 { "userId": "rEYiibm6LuOgY51XAoLIPBYgInZsiY", "firstName": "Rahul", "lastName": "Developer", "email": "rahul.rawat.er@gmail.com", "addresses": [ { "addressId": "LpeUNmExQf697U2qulnqOA6CVhJbb5", "city": "new delhi", "country": "india", "streetName": "L-92 Saket", "postalCode": "110017", "type": "home" }, { "addressId": "T2l4IalpjI3imKxQYP562RuFrW2j1v", "city": "Gurgaon", "country": "india", "streetName": "697 Udyog vihar phase-5", "postalCode": "220012", "type": "office" } ] } 

2. Login Api

Request : -

post url :- localhost:8080/mobile-app-ws/users/login

headers :- 1.Content-Type : application/json 2.Accept : application/json

Body :-

 { 
"email": "rahul.rawat.er@gmail.com", "password":"password" 

}

Response : -

in header you will get Authorization token and UserId such as

 Authorization →Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJyYWh1bC5yYXdhdC5lckBnbWFpbC5jb20iLCJleHAiOjE1Njg4MjU1MDZ9.gyfre0idjQscKqd8zctUteAlODh1VuJQl3v3FzQNt_4TS1CDLy6Ic94NRgOE0Cpi8mH7PAxha6cSwUtRIdX5Yw UserID →rEYiibm6LuOgY51XAoLIPBYgInZsiY 

3. User Data Api

Request : -

Get url :- localhost:8080/mobile-app-ws/users/rEYiibm6LuOgY51XAoLIPBYgInZsiY

headers :- 1.Authorization : Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJyYWh1bC5yYXdhdC5lckBnbWFpbC5jb20iLCJleHAiOjE1Njg4MjU1MDZ9.gyfre0idjQscKqd8zctUteAlODh1VuJQl3v3FzQNt_4TS1CDLy6Ic94NRgOE0Cpi8mH7PAxha6cSwUtRIdX5Yw ( Authorization token which you gt from login api) 2.Content-Type : application/json 3.Accept : application/json

Response : -

 { "userId": "rEYiibm6LuOgY51XAoLIPBYgInZsiY", "firstName": "Rahul", "lastName": "Developer", "email": "rahul.rawat.er@gmail.com", "addresses": [ { "addressId": "LpeUNmExQf697U2qulnqOA6CVhJbb5", "city": "new delhi", "country": "india", "streetName": "L-92 Saket", "postalCode": "110017", "type": "home" }, { "addressId": "T2l4IalpjI3imKxQYP562RuFrW2j1v", "city": "Gurgaon", "country": "india", "streetName": "697 Udyog vihar phase-5", "postalCode": "220012", "type": "office" } ] } 

4. Update User Details Api

Request : -

put url :- localhost:8080/mobile-app-ws/users/login

headers :- 1.Content-Type : application/json 2.Accept : application/json 3.Authorization : Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJyYWh1bC5yYXdhdC5lckBnbWFpbC5jb20iLCJleHAiOjE1Njg4MjU1MDZ9.gyfre0idjQscKqd8zctUteAlODh1VuJQl3v3FzQNt_4TS1CDLy6Ic94NRgOE0Cpi8mH7PAxha6cSwUtRIdX5Yw ( Authorization token which you gt from login api)

Body :-

 { 
"firstName":"rahul", "lastName":"hello" 

}

Response : -

Here our code will only update first name and the last name for more you can easily change inside the code

 { "userId": "rEYiibm6LuOgY51XAoLIPBYgInZsiY", "firstName": "rahul", "lastName": "hello", "email": "rahul.rawat.er@gmail.com", "addresses": [ { "addressId": "LpeUNmExQf697U2qulnqOA6CVhJbb5", "city": "new delhi", "country": "india", "streetName": "L-92 Saket", "postalCode": "110017", "type": "home" }, { "addressId": "T2l4IalpjI3imKxQYP562RuFrW2j1v", "city": "Gurgaon", "country": "india", "streetName": "697 Udyog vihar phase-5", "postalCode": "220012", "type": "office" } ] } 

5. Get list of all users with pagination

Request : -

Get url :- localhost:8080/mobile-app-ws/users?page=0&limit=8

headers :- 1.Content-Type : application/json 2.Accept : application/json 3.Authorization : Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJyYWh1bC5yYXdhdC5lckBnbWFpbC5jb20iLCJleHAiOjE1Njg4MjU1MDZ9.gyfre0idjQscKqd8zctUteAlODh1VuJQl3v3FzQNt_4TS1CDLy6Ic94NRgOE0Cpi8mH7PAxha6cSwUtRIdX5Yw ( Authorization token which you gt from login api)

Response : -

 { "operationName": "Delete", "operationResult": "Success" } 

6. Update User Details Api

Request : -

put url :- localhost:8080/mobile-app-ws/users/login

headers :- 1.Content-Type : application/json 2.Accept : application/json 3.Authorization : Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJyYWh1bC5yYXdhdC5lckBnbWFpbC5jb20iLCJleHAiOjE1Njg4MjU1MDZ9.gyfre0idjQscKqd8zctUteAlODh1VuJQl3v3FzQNt_4TS1CDLy6Ic94NRgOE0Cpi8mH7PAxha6cSwUtRIdX5Yw ( Authorization token which you gt from login api)

Response : -

 [ { "userId": "THHKpsoyTkmJUmIwqsVdiM8xE8TUjL", "firstName": "rahul", "lastName": "androiddev", "email": "rahulrocksmgps@gmail.com", "addresses": [ { "addressId": "K5w52lgv4ogUmbzv0WQQYoZPa87vW9", "city": "Gurgaon", "country": "india", "streetName": "697 Udyog vihar phase-5", "postalCode": "220012", "type": "office" }, { "addressId": "2Cbs8EibDgfZQdghrPaw7N3rMoEURm", "city": "new delhi", "country": "india", "streetName": "147/15 sec-1 pushp vihar", "postalCode": "110017", "type": "home" } ] }, { "userId": "TJAOFv0vTRKEqAsn4Az5PiADBMHSP5", "firstName": "Rahul", "lastName": "Developer", "email": "rahul.rawat.er@gmail.com", "addresses": [ { "addressId": "xiMOoUK1w4fzX0SIlemq6yLsmNQVFB", "city": "Gurgaon", "country": "india", "streetName": "697 Udyog vihar phase-5", "postalCode": "220012", "type": "office" }, { "addressId": "TISQo46rYQOnZTMSPpi2eoR5IX0e8F", "city": "new delhi", "country": "india", "streetName": "L-92 Saket", "postalCode": "110017", "type": "home" } ] } ] 

7. Get list of partiular user addresses Api

Request : -

get url :- localhost:8080/mobile-app-ws/users/rEYiibm6LuOgY51XAoLIPBYgInZsiY/addresses

headers :- 1.Content-Type : application/json 2.Accept : application/json 3.Authorization : Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJyYWh1bC5yYXdhdC5lckBnbWFpbC5jb20iLCJleHAiOjE1Njg4MjU1MDZ9.gyfre0idjQscKqd8zctUteAlODh1VuJQl3v3FzQNt_4TS1CDLy6Ic94NRgOE0Cpi8mH7PAxha6cSwUtRIdX5Yw ( Authorization token which you gt from login api)

Response : -

 [ { "addressId": "xiMOoUK1w4fzX0SIlemq6yLsmNQVFB", "city": "Gurgaon", "country": "india", "streetName": "697 Udyog vihar phase-5", "postalCode": "220012", "type": "office" }, { "addressId": "TISQo46rYQOnZTMSPpi2eoR5IX0e8F", "city": "new delhi", "country": "india", "streetName": "L-92 Saket", "postalCode": "110017", "type": "home" } ] 

8. Get particlar Address detail from partiular addresses id Api

Request : -

get url :- localhost:8080/mobile-app-ws/users/TJAOFv0vTRKEqAsn4Az5PiADBMHSP5/addresses/xiMOoUK1w4fzX0SIlemq6yLsmNQVFB

headers :- 1.Content-Type : application/json 2.Accept : application/json 3.Authorization : Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJyYWh1bC5yYXdhdC5lckBnbWFpbC5jb20iLCJleHAiOjE1Njg4MjU1MDZ9.gyfre0idjQscKqd8zctUteAlODh1VuJQl3v3FzQNt_4TS1CDLy6Ic94NRgOE0Cpi8mH7PAxha6cSwUtRIdX5Yw ( Authorization token which you gt from login api)

Response : -

 { "addressId": "xiMOoUK1w4fzX0SIlemq6yLsmNQVFB", "city": "Gurgaon", "country": "india", "streetName": "697 Udyog vihar phase-5", "postalCode": "220012", "type": "office" } 

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •