Skip to content

Commit

Permalink
join to be part of post to avoid challenges of request params and add…
Browse files Browse the repository at this point in the history
…ress security.
  • Loading branch information
grabdoc committed Feb 7, 2024
1 parent 2ba8122 commit 0d0eb38
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ public class ReadControllerV2 {

private final ReadServiceV2 readServiceV2;


@GetMapping(value = "/V2/{tableName}" , produces = "application/json")
public Object find(@PathVariable String tableName,
@RequestParam(name = "fields", required = false, defaultValue = "*") String fields,
@RequestParam(name = "filter", required = false, defaultValue = "") String filter,
@RequestParam(name = "sort", required = false, defaultValue = "") List<String> sorts,
@RequestParam(name = "limit", required = false, defaultValue = "-1") int limit,
@RequestParam(name = "offset", required = false, defaultValue = "-1") long offset) {
@RequestParam(name = "offset", required = false, defaultValue = "-1") long offset
) {

log.info("fields - {}", fields);
log.info("filter - {}", filter);
Expand All @@ -37,7 +39,8 @@ public Object find(@PathVariable String tableName,
.filter(filter)
.sorts(sorts)
.limit(limit)
.offset(offset).build();
.offset(offset)
.build();


return readServiceV2.find(readContextV2);
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/homihq/db2rest/rest/read/v2/dto/JoinDetail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.homihq.db2rest.rest.read.v2.dto;

import java.util.List;


public class JoinDetail {

private String table;

private List<String> columnNames;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ReadContextV2 {
List<String> sorts;
int limit;
long offset;
List<String> joins;


/* Processed attributes */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.homihq.db2rest.rest.read.v2.processor;

import com.homihq.db2rest.rest.read.v2.dto.ReadContextV2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Objects;

@Component
@Slf4j
@Order(4)
public class JoinProcessor implements ReadPreProcessor{
@Override
public void process(ReadContextV2 readContextV2) {
if(Objects.nonNull(readContextV2.getJoins()) && !readContextV2.getJoins().isEmpty()) {
for(String join : readContextV2.getJoins()) {
log.info("Join - {}", join);

}
}
}
}

0 comments on commit 0d0eb38

Please sign in to comment.