[agent-pipeline] pipe-20260328055039-5mki round-3

This commit is contained in:
DDD1542
2026-03-28 15:32:02 +09:00
parent 9ca163c5cd
commit 941cde1962
3 changed files with 49 additions and 15 deletions
@@ -44,10 +44,18 @@ public class DataAdvancedController {
@RequestAttribute("companyCode") String companyCode,
@PathVariable String tableName,
@RequestBody Map<String, Object> body) {
body.put("companyCode", companyCode);
body.put("tableName", tableName);
// Node.js는 복합키를 body에 직접 전송 (e.g. {user_id: 'x', dept_code: 'y'})
// DataService.deleteByCompositeKey는 params.get("keys")를 기대하므로 래핑
Map<String, Object> keys = new LinkedHashMap<>(body);
keys.remove("tableName");
keys.remove("companyCode");
Map<String, Object> params = new LinkedHashMap<>();
params.put("companyCode", companyCode);
params.put("tableName", tableName);
params.put("keys", keys);
try {
return ResponseEntity.ok(ApiResponse.success(dataAdvancedService.deleteByCondition(body)));
return ResponseEntity.ok(ApiResponse.success(dataAdvancedService.deleteByCondition(params)));
} catch (IllegalArgumentException e) {
return ResponseEntity.status(400).body(ApiResponse.error(e.getMessage()));
}
@@ -58,10 +66,18 @@ public class DataAdvancedController {
@RequestAttribute("companyCode") String companyCode,
@PathVariable String tableName,
@RequestBody Map<String, Object> body) {
body.put("companyCode", companyCode);
body.put("tableName", tableName);
// Node.js는 필터 조건을 body에 직접 전송
// DataService.deleteGroupRecords는 params.get("filters")를 기대하므로 래핑
Map<String, Object> filters = new LinkedHashMap<>(body);
filters.remove("tableName");
filters.remove("companyCode");
Map<String, Object> params = new LinkedHashMap<>();
params.put("companyCode", companyCode);
params.put("tableName", tableName);
params.put("filters", filters);
try {
return ResponseEntity.ok(ApiResponse.success(dataAdvancedService.deleteGroup(body)));
return ResponseEntity.ok(ApiResponse.success(dataAdvancedService.deleteGroup(params)));
} catch (IllegalArgumentException e) {
return ResponseEntity.status(400).body(ApiResponse.error(e.getMessage()));
}
@@ -85,7 +85,8 @@ public class DataController {
body.put("companyCode", companyCode);
body.put("tableName", tableName);
try {
return ResponseEntity.status(201).body(ApiResponse.success(dataService.createRecord(body)));
return ResponseEntity.status(201).body(
ApiResponse.success(dataService.createRecord(body), "레코드가 생성되었습니다."));
} catch (IllegalArgumentException e) {
return ResponseEntity.status(400).body(ApiResponse.error(e.getMessage()));
}
@@ -103,7 +104,7 @@ public class DataController {
try {
Map<String, Object> result = dataService.updateRecord(body);
if (result == null) return ResponseEntity.status(404).body(ApiResponse.error("레코드를 찾을 수 없거나 수정 권한이 없습니다."));
return ResponseEntity.ok(ApiResponse.success(result));
return ResponseEntity.ok(ApiResponse.success(result, "레코드가 수정되었습니다."));
} catch (IllegalArgumentException e) {
return ResponseEntity.status(400).body(ApiResponse.error(e.getMessage()));
}
@@ -121,7 +122,8 @@ public class DataController {
try {
Map<String, Object> result = dataService.deleteRecord(params);
if (result == null) return ResponseEntity.status(404).body(ApiResponse.error("레코드를 찾을 수 없습니다."));
return ResponseEntity.ok(ApiResponse.success(result));
// Node.js는 data 없이 message만 반환
return ResponseEntity.ok(ApiResponse.success(null, "레코드가 삭제되었습니다."));
} catch (IllegalArgumentException e) {
return ResponseEntity.status(400).body(ApiResponse.error(e.getMessage()));
}
@@ -96,8 +96,13 @@ public class DataService extends BaseService {
boolean hasCC = hasCompanyCodeColumn(tableName);
int page = toInt(params.get("page"), 1);
int limit = Math.min(toInt(params.get("limit"), 20), 1000);
int offset = (page - 1) * limit;
// Node.js는 size/limit 둘 다 사용 — size를 limit의 alias로 지원
Object limitVal = params.get("limit") != null ? params.get("limit") : params.get("size");
int limit = Math.min(toInt(limitVal, 20), 1000);
// offset 직접 지정 시 page 대신 사용 (Node.js limit/offset 방식 호환)
int offset = params.get("offset") != null && params.get("page") == null
? toInt(params.get("offset"), 0)
: (page - 1) * limit;
List<Object> args = new ArrayList<>();
StringBuilder where = new StringBuilder("1=1");
@@ -351,8 +356,11 @@ public class DataService extends BaseService {
public List<Map<String, Object>> getJoinData(Map<String, Object> params) {
String leftTable = (String) params.get("leftTable");
String rightTable = (String) params.get("rightTable");
String leftKey = (String) params.get("leftKey");
String rightKey = (String) params.get("rightKey");
// Node.js는 leftColumn/rightColumn, 내부 호출은 leftKey/rightKey — 둘 다 지원
String leftKey = params.get("leftKey") != null
? (String) params.get("leftKey") : (String) params.get("leftColumn");
String rightKey = params.get("rightKey") != null
? (String) params.get("rightKey") : (String) params.get("rightColumn");
validateTable(leftTable);
validateTable(rightTable);
@@ -363,14 +371,22 @@ public class DataService extends BaseService {
boolean hasCC = hasCompanyCodeColumn(leftTable);
List<Object> args = new ArrayList<>();
StringBuilder where = new StringBuilder("l.\"" + leftKey + "\" = r.\"" + rightKey + "\"");
String joinCond = "l.\"" + leftKey + "\" = r.\"" + rightKey + "\"";
StringBuilder where = new StringBuilder("1=1");
if (hasCC && companyCode != null && !companyCode.isEmpty()) {
where.append(" AND l.company_code = ?");
args.add(companyCode);
}
// leftValue: Node.js가 특정 값으로 필터링할 때 사용
String leftValue = (String) params.get("leftValue");
if (leftValue != null && !leftValue.isBlank()) {
where.append(" AND l.\"").append(leftKey).append("\" = ?");
args.add(leftValue);
}
String listSql = "SELECT l.*, r.* FROM \"" + leftTable + "\" l" +
" INNER JOIN \"" + rightTable + "\" r ON " + where;
" INNER JOIN \"" + rightTable + "\" r ON " + joinCond +
" WHERE " + where;
List<Map<String, Object>> rows = jdbcTemplate.queryForList(listSql, args.toArray());
// 중복 제거 (deduplication 설정이 있을 경우)