diff --git a/src/main/java/com/homihq/db2rest/mybatis/DB2RestRenderingStrategy.java b/src/main/java/com/homihq/db2rest/mybatis/DB2RestRenderingStrategy.java index 2c1902d7..e93bca8d 100644 --- a/src/main/java/com/homihq/db2rest/mybatis/DB2RestRenderingStrategy.java +++ b/src/main/java/com/homihq/db2rest/mybatis/DB2RestRenderingStrategy.java @@ -9,13 +9,13 @@ public class DB2RestRenderingStrategy extends SpringNamedParameterRenderingStrat @Override public String getRecordBasedInsertBinding(BindableColumn column, String prefix, String parameterName) { - log.info("Here - 1"); + return super.getRecordBasedInsertBinding(column, parameterName); } @Override public String getRecordBasedInsertBinding(BindableColumn column, String parameterName) { - log.info("Here - 2"); + return super.getRecordBasedInsertBinding(column, parameterName); } } diff --git a/src/main/java/com/homihq/db2rest/rest/create/CreateController.java b/src/main/java/com/homihq/db2rest/rest/create/CreateController.java index 48d6fce6..47dd9a29 100644 --- a/src/main/java/com/homihq/db2rest/rest/create/CreateController.java +++ b/src/main/java/com/homihq/db2rest/rest/create/CreateController.java @@ -1,5 +1,7 @@ package com.homihq.db2rest.rest.create; +import com.homihq.db2rest.rest.create.dto.CreateBulkResponse; +import com.homihq.db2rest.rest.create.dto.CreateResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; @@ -14,21 +16,24 @@ public class CreateController { private final CreateService createService; @PostMapping ("/{tableName}") - public void save(@PathVariable String tableName, - @RequestHeader(name = "Content-Profile") String schemaName, - @RequestBody Map data) { - + public CreateResponse save(@PathVariable String tableName, + @RequestHeader(name = "Content-Profile") String schemaName, + @RequestBody Map data) { + int rows = createService.save(schemaName, tableName, data); + + return new CreateResponse(rows); } @PostMapping ( "/{tableName}/bulk") - public void saveBulk(@PathVariable String tableName, - @RequestHeader(name = "Content-Profile") String schemaName, - @RequestBody List> data) { - log.info("data -> {}", data); - + public CreateBulkResponse saveBulk(@PathVariable String tableName, + @RequestHeader(name = "Content-Profile") String schemaName, + @RequestBody List> data) { + int [] rows = createService.saveBulk(schemaName, tableName,data); + + return new CreateBulkResponse(rows); } } diff --git a/src/main/java/com/homihq/db2rest/rest/create/CreateService.java b/src/main/java/com/homihq/db2rest/rest/create/CreateService.java index 35a86d2d..031d2c7d 100644 --- a/src/main/java/com/homihq/db2rest/rest/create/CreateService.java +++ b/src/main/java/com/homihq/db2rest/rest/create/CreateService.java @@ -33,7 +33,7 @@ public class CreateService { private final DB2RestRenderingStrategy db2RestRenderingStrategy = new DB2RestRenderingStrategy(); @Transactional - public void save(String schemaName, String tableName, Map data) { + public int save(String schemaName, String tableName, Map data) { db2RestConfigProperties.verifySchema(schemaName); SqlTable table = SqlTable.of(tableName); @@ -53,10 +53,12 @@ public void save(String schemaName, String tableName, Map data) { log.debug("Inserted - {} row(s)", rows); + return rows; + } @Transactional - public void saveBulk(String schemaName, String tableName, List> dataList) { + public int[] saveBulk(String schemaName, String tableName, List> dataList) { if(Objects.isNull(dataList) || dataList.isEmpty()) throw new RuntimeException("No data provided"); SqlTable table = SqlTable.of(tableName); @@ -83,6 +85,8 @@ public void saveBulk(String schemaName, String tableName, List