Skip to content
Snippets Groups Projects
Commit 3281aa13 authored by fz2907's avatar fz2907
Browse files

Updated the example controller.

parent 9fb93d03
No related branches found
No related tags found
3 merge requests!27Sprint 1 done,!7Changed DB port from 3306 to 3307. So it will not interrupt with your own local MySQL,!4Updated the example controller model class
......@@ -32,7 +32,7 @@ public class ExampleController {
public ResponseModel getExample() {
logger.info("You reached the getExample() function.");
return ResponseModel.generateResponse(
return new ResponseModel(
"This this a example String response",
HttpStatus.OK,
"Some Json Object Later");
......@@ -45,7 +45,7 @@ public class ExampleController {
*/
@GetMapping("/{userId}")
public ResponseModel getExampleWithInput(@PathVariable long userId){
return ResponseModel.generateResponse(
return new ResponseModel(
"This this a example String response",
HttpStatus.OK,
"You GET this function with id = "+ userId);
......@@ -58,7 +58,7 @@ public class ExampleController {
*/
@GetMapping("/detail/{userId}")
public ResponseModel getExampleDetailWithInput(@PathVariable long userId){
return ResponseModel.generateResponse(
return new ResponseModel(
"This this a example String response",
HttpStatus.OK,
"You GET this function with detail id: "+ userId);
......@@ -71,7 +71,7 @@ public class ExampleController {
@RequestMapping("/getUser")
public ResponseModel getExampleUser(){
ExampleModel user = new ExampleModel(233, "example-user");
return ResponseModel.generateResponse(
return new ResponseModel(
"There is your example user info",
HttpStatus.OK,
user);
......@@ -85,7 +85,7 @@ public class ExampleController {
@PostMapping("/newUser")
public ResponseModel handlePost(@RequestBody ExampleModel newUser){
logger.info("You reached the handlePost() function.");
return ResponseModel.generateResponse(
return new ResponseModel(
"I received your new user data, check it in data section",
HttpStatus.OK,
newUser);
......@@ -99,7 +99,7 @@ public class ExampleController {
@DeleteMapping("/logout/{userId}")
public ResponseModel logout(@PathVariable long userId){
logger.warn("You reached the logout() function.");
return ResponseModel.generateResponse(
return new ResponseModel(
"I received your logout request",
HttpStatus.OK,
null);
......
......@@ -11,14 +11,6 @@ public class ResponseModel {
String message;
HttpStatus status;
Object data;
public static ResponseModel generateResponse(String message, HttpStatus status, Object data) {
ResponseModel responseModel = new ResponseModel();
//Map<String, Object> map = new HashMap<>();
responseModel.message = message;
responseModel.status = status;
responseModel.data = data;
return responseModel;
}
public ResponseModel(){
message = "";
......@@ -26,6 +18,12 @@ public class ResponseModel {
data = null;
}
public ResponseModel(String message, HttpStatus status, Object data){
this.message = message;
this.status = status;
this.data = data;
}
public void setMessage(String message){
this.message = message;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment