-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from 3296Fall2020/tp-springBoot-sneaker-endpoint
Tp spring boot sneaker endpoint
- Loading branch information
Showing
6 changed files
with
113 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
sneaker-service/src/main/java/com/company/sneakerinvetory/sneaker/SneakerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.company.sneakerinvetory.sneaker; | ||
|
||
import com.company.sneakerinvetory.MySQLConnction.DatabaseOperation; | ||
import com.company.sneakerinvetory.login.LoginResponse; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
//curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data '{ "index": "1", "id" : "tester", "SneakerName" : "yeezy 350 v2", "Sku" : "fu9006", "size" : "11", "price" : "$350" }' "http://localhost:8080/editSneaker" | ||
@RestController | ||
public class SneakerController { | ||
|
||
@ResponseBody | ||
@RequestMapping(value = "/addSneaker", method = RequestMethod.POST) | ||
public LoginResponse handleAddSneaker(@RequestBody Sneaker sneaker){ | ||
DatabaseOperation operation = new DatabaseOperation(); | ||
operation.createConnect(); | ||
boolean valid = Sneaker.validateAddSneaker(sneaker); | ||
if (valid) { | ||
boolean createSneaker = operation.insertData(sneaker.getShoeName(), sneaker.getSku(), sneaker.getSize(), sneaker.getPrice(), sneaker.getid()); | ||
if (createSneaker) { | ||
return new LoginResponse("SessionID"); | ||
} | ||
} | ||
return new LoginResponse("NaN"); | ||
} | ||
|
||
@ResponseBody | ||
@RequestMapping(value = "/editSneaker", method = RequestMethod.POST) | ||
public LoginResponse handleEditSneaker(@RequestBody Sneaker sneaker){ | ||
DatabaseOperation operation = new DatabaseOperation(); | ||
operation.createConnect(); | ||
boolean valid = Sneaker.validateEditSneaker(sneaker); | ||
if (valid) { | ||
boolean createSneaker = operation.editForm(sneaker.getIndex(), sneaker.getShoeName(), sneaker.getSku(), sneaker.getSize(), sneaker.getPrice(), sneaker.getid()); | ||
if (createSneaker) { | ||
|
||
return new LoginResponse("SessionID"); | ||
} | ||
} | ||
return new LoginResponse("NaN"); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
sneaker-service/src/main/java/com/company/sneakerinvetory/sneaker/SneakerResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.company.sneakerinvetory.sneaker; | ||
|
||
public class SneakerResponse { | ||
|
||
} |