[Developer] #424 default protected object lookup mapping

This commit is contained in:
devmrko
2026-06-23 14:49:40 +09:00
parent e5ba9aedd7
commit be4f337802
5 changed files with 81 additions and 8 deletions

View File

@@ -13,4 +13,8 @@ public record DatabaseObjectOption(
public String label() {
return owner + "." + objectName + " (" + objectType + ")";
}
public String defaultOrdsPath() {
return owner.toLowerCase() + "/" + objectName.toLowerCase();
}
}

View File

@@ -51,14 +51,15 @@ public class ProtectedObjectService {
@Transactional
public void createObject(ProtectedObjectCreateCommand command) {
ProtectedObjectCreateCommand normalized = normalizeCreateCommand(command);
long objectId = mapper.nextObjectId();
mapper.insertObject(objectId, command);
Set<String> sensitive = splitCsv(command.sensitiveColumns());
for (String column : splitCsv(command.columns())) {
mapper.insertObject(objectId, normalized);
Set<String> sensitive = splitCsv(normalized.sensitiveColumns());
for (String column : splitCsv(normalized.columns())) {
mapper.insertColumn(mapper.nextColumnId(), objectId, column, sensitive.contains(column) ? "Y" : "N");
}
auditService.record(new AuditEvent("PROTECTED_OBJECT_CREATED", null, objectId, "SUCCESS", null, null,
command.objectName()));
normalized.objectName()));
}
@Transactional
@@ -92,6 +93,20 @@ public class ProtectedObjectService {
return schemaPath + "/" + objectName.toLowerCase(Locale.ROOT);
}
private ProtectedObjectCreateCommand normalizeCreateCommand(ProtectedObjectCreateCommand command) {
String owner = command.owner().trim().toUpperCase(Locale.ROOT);
String objectName = command.objectName().trim().toUpperCase(Locale.ROOT);
String ordsPath = command.ordsPath();
if (ordsPath == null || ordsPath.isBlank()) {
ordsPath = defaultOrdsPath(owner, objectName);
}
String columns = command.columns();
if (columns == null || columns.isBlank()) {
columns = String.join(",", mapper.findDatabaseColumns(owner, objectName));
}
return new ProtectedObjectCreateCommand(owner, objectName, ordsPath.trim(), columns, command.sensitiveColumns());
}
@Transactional
public void disableObject(long objectId) {
int updated = mapper.disableObject(objectId);

View File

@@ -21,6 +21,7 @@ public class ProtectedObjectController {
@GetMapping("/objects")
public String objects(Model model) {
model.addAttribute("objects", protectedObjectService.findEnabled());
model.addAttribute("dbObjects", protectedObjectService.findDatabaseObjects());
return "objects";
}