Skip to content

Commit

Permalink
Merge pull request #5 from 23-Samsung-Securities/feat/apartment
Browse files Browse the repository at this point in the history
feat: 수익률 API
  • Loading branch information
eojinny authored Dec 5, 2023
2 parents e64fe8c + 3433c7d commit c08dedc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ public BaseResponse<List<ProductDto.Response>> getProductLikeList(@PathVariable(
List<ProductDto.Response> productList = productService.findByType(type);
return BaseResponse.onSuccess(productList);
}
@GetMapping("/list/{type}/{roi}")
public BaseResponse<List<ProductDto.Response>> getProductRoiList(@PathVariable("type") String type,@PathVariable("roi") Double roi){
List<ProductDto.Response> productList = productService.findByRoiLessThan(type,roi);
return BaseResponse.onSuccess(productList);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ProductDto {
public static class Request{
private String price;

private String roi;
private Double roi;

public Product toEntity() {
return Product.builder()
Expand All @@ -32,7 +32,7 @@ public static class Response{
private String name;
private String price;

private String roi;
private Double roi;

public Response(Product product) {
this.name= product.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Product {
private String name;
private String price;

private String roi;
private Double roi;

private String type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

public interface ProductRepository extends JpaRepository<Product,Long> {
List<Product> findByType(String type);
List<Product> findByRoiLessThanAndType(double value,String type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ public List<ProductDto.Response> findByType(String type) {
.map(ProductDto.Response::new)
.collect(Collectors.toList());
}
public List<ProductDto.Response> findByRoiLessThan(String type, double value){
List<Product> products = productRepository.findByRoiLessThanAndType(value,type);
return products.stream()
.map(ProductDto.Response::new)
.collect(Collectors.toList());
}
}

0 comments on commit c08dedc

Please sign in to comment.