Skip to content

Commit

Permalink
add product
Browse files Browse the repository at this point in the history
  • Loading branch information
Nacnano committed Jan 31, 2023
1 parent 289d13a commit bbd7e77
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
26 changes: 26 additions & 0 deletions backend/src/main/java/com/test/backend/api/ProductApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.test.backend.api;

import com.test.backend.business.ProductBusiness;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductApi {

private final ProductBusiness business;

public ProductApi(ProductBusiness business) {
this.business = business;
}


@GetMapping("/{id}")
public ResponseEntity<String> getProductById(@PathVariable("id") String id){
String response = business.getProductById(id);
return ResponseEntity.ok(response);
}
}
9 changes: 0 additions & 9 deletions backend/src/main/java/com/test/backend/api/TestApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ public TestResponse test() {
return response;
}

@GetMapping
@RequestMapping("/2")
public TestResponse test2(){
TestResponse response = new TestResponse();
response.setName("Nac2");
response.setFood("Pizza2");

return response;
}

@PostMapping
@RequestMapping("/register")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.test.backend.business;

import org.springframework.stereotype.Service;

@Service
public class ProductBusiness {

public String getProductById(String id){
// TODO: Get data from database
return id;
}
}

0 comments on commit bbd7e77

Please sign in to comment.