Skip to content

Commit

Permalink
#213 - refactored create controller
Browse files Browse the repository at this point in the history
  • Loading branch information
grabdoc committed Jan 30, 2024
1 parent 7e16d80 commit 6c057ea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/main/java/com/homihq/db2rest/rest/create/CreateController.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
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.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
@RequiredArgsConstructor
public class CreateController {
public class CreateController implements CreateRestApi {

private final CreateService createService;

@ResponseStatus(HttpStatus.CREATED)
@PostMapping ("/{tableName}")
public CreateResponse save(@PathVariable String tableName,
@RequestHeader(name = "Content-Profile") String schemaName,
@RequestBody Map<String,Object> data,
@RequestParam(name = "tsid", required = false) String tsid,
@RequestParam(name = "tsidType", required = false, defaultValue = "number") String tsidType) {
@Override
public CreateResponse save(String tableName,
String schemaName,
Map<String, Object> data,
String tsid,
String tsidType) {

int rows =
createService.save(schemaName, tableName, data, tsid, tsidType);
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/homihq/db2rest/rest/create/CreateRestApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.homihq.db2rest.rest.create;

import com.homihq.db2rest.rest.create.dto.CreateResponse;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

public interface CreateRestApi {
@ResponseStatus(HttpStatus.CREATED)
@PostMapping("/{tableName}")
CreateResponse save(@PathVariable String tableName,
@RequestHeader(name = "Content-Profile") String schemaName,
@RequestBody Map<String, Object> data,
@RequestParam(name = "tsid", required = false) String tsid,
@RequestParam(name = "tsidType", required = false, defaultValue = "number") String tsidType);
}

0 comments on commit 6c057ea

Please sign in to comment.