From 1538aadb1417d0e1808a18d87793ee45bbb78473 Mon Sep 17 00:00:00 2001 From: devmrko Date: Wed, 22 Jul 2026 14:18:54 +0900 Subject: [PATCH] feat(backoffice): migrate remaining menus to Smilegate tables --- sql/adb/71_sg_identity_administration.sql | 24 +++++++++++++++++++ .../service/VectorKnowledgeService.java | 20 ++++++++-------- .../resources/mapper/BearerTokenMapper.xml | 23 ++++++++---------- src/main/resources/mapper/SettingMapper.xml | 4 ++-- 4 files changed, 46 insertions(+), 25 deletions(-) diff --git a/sql/adb/71_sg_identity_administration.sql b/sql/adb/71_sg_identity_administration.sql index 7190087..a872794 100644 --- a/sql/adb/71_sg_identity_administration.sql +++ b/sql/adb/71_sg_identity_administration.sql @@ -156,6 +156,26 @@ begin updated_at timestamp default systimestamp not null, constraint sg_masking_rule_enabled_ck check (enabled_yn in (''Y'', ''N'')) )'); + create_if_missing('create table sg_access_bearer_token ( + key_id number primary key, user_id number not null, key_prefix varchar2(100) not null, + key_hash varchar2(256) not null unique, expires_at timestamp not null, revoked_at timestamp, + description varchar2(500), created_at timestamp default systimestamp not null, + constraint sg_access_bearer_token_user_fk foreign key (user_id) references sg_app_user(user_id) + )'); + create_if_missing('create table sg_backoffice_setting ( + setting_key varchar2(200) primary key, setting_value varchar2(4000), + updated_at timestamp default systimestamp not null + )'); + create_if_missing('create table sg_vector_document_chunk ( + chunk_id number primary key, document_id varchar2(200) not null, chunk_no number not null, + content clob not null, embedding vector(1536, float32), created_at timestamp default systimestamp not null + )'); + create_if_missing('create table sg_vector_document_tag ( + chunk_id number not null, tech_tag varchar2(200) not null, + constraint sg_vector_document_tag_pk primary key (chunk_id, tech_tag), + constraint sg_vector_document_tag_chunk_fk foreign key (chunk_id) references sg_vector_document_chunk(chunk_id) + )'); + create_if_missing('create sequence sg_vector_chunk_seq start with 1 increment by 1 nocache'); create_if_missing('create table sg_column_masking_rule ( column_id number primary key, rule_id number not null, @@ -244,6 +264,10 @@ create or replace view cb_column_masking_rule as select column_id, rule_id, updated_at from sg_column_masking_rule; create or replace view cb_user_masking_rule as select user_id, column_id, decision, active_yn, updated_at from sg_user_masking_rule; +create or replace view cb_ords_probe_audit as +select audit_id, event_type, key_id, object_id, status, row_count, error_code, message, created_at from sg_audit_event; +create or replace view cb_backoffice_setting as +select setting_key, setting_value, updated_at from sg_backoffice_setting; -- PoC administrator access: both demo operators can manage and query every -- Smilegate game-data object registered in SGMP_POC. diff --git a/src/main/java/com/cloudhandson/vpdbackoffice/service/VectorKnowledgeService.java b/src/main/java/com/cloudhandson/vpdbackoffice/service/VectorKnowledgeService.java index 240bb03..dc5135e 100644 --- a/src/main/java/com/cloudhandson/vpdbackoffice/service/VectorKnowledgeService.java +++ b/src/main/java/com/cloudhandson/vpdbackoffice/service/VectorKnowledgeService.java @@ -56,9 +56,9 @@ public class VectorKnowledgeService { } public VectorKnowledgeSummary summary() { - int documents = count("SELECT COUNT(DISTINCT document_id) FROM cb_vector_document_chunk"); - int chunks = count("SELECT COUNT(*) FROM cb_vector_document_chunk"); - int tags = count("SELECT COUNT(*) FROM cb_vector_document_tag"); + int documents = count("SELECT COUNT(DISTINCT document_id) FROM sg_vector_document_chunk"); + int chunks = count("SELECT COUNT(*) FROM sg_vector_document_chunk"); + int tags = count("SELECT COUNT(*) FROM sg_vector_document_tag"); boolean registered = protectedObjectService.findEnabled().stream() .anyMatch(object -> VECTOR_OBJECT.equalsIgnoreCase(object.objectName())); return new VectorKnowledgeSummary( @@ -107,13 +107,13 @@ public class VectorKnowledgeService { String embeddingJson = json(embedding); long chunkId = nextChunkId++; jdbcTemplate.update(""" - INSERT INTO cb_vector_document_chunk + INSERT INTO sg_vector_document_chunk (chunk_id, document_id, chunk_no, title, chunk_text, source_uri, embedding) VALUES (?, ?, ?, ?, ?, ?, TO_VECTOR(?)) """, chunkId, documentId, chunk.chunkNo(), title, chunk.text(), sourceUri, embeddingJson); for (String tag : tags) { jdbcTemplate.update(""" - INSERT INTO cb_vector_document_tag (chunk_id, tech_tag) + INSERT INTO sg_vector_document_tag (chunk_id, tech_tag) VALUES (?, ?) """, chunkId, tag); tagCount++; @@ -143,18 +143,18 @@ public class VectorKnowledgeService { private void replaceDocument(String documentId) { jdbcTemplate.update(""" - DELETE FROM cb_vector_document_tag + DELETE FROM sg_vector_document_tag WHERE chunk_id IN ( - SELECT chunk_id FROM cb_vector_document_chunk WHERE document_id = ? + SELECT chunk_id FROM sg_vector_document_chunk WHERE document_id = ? ) """, documentId); - jdbcTemplate.update("DELETE FROM cb_vector_document_chunk WHERE document_id = ?", documentId); + jdbcTemplate.update("DELETE FROM sg_vector_document_chunk WHERE document_id = ?", documentId); } private long nextChunkId(int chunkCount) { try { Long sequenceValue = jdbcTemplate.queryForObject( - "SELECT cb_vector_chunk_seq.NEXTVAL FROM dual", Long.class); + "SELECT sg_vector_chunk_seq.NEXTVAL FROM dual", Long.class); if (sequenceValue != null) { return sequenceValue; } @@ -163,7 +163,7 @@ public class VectorKnowledgeService { // fallback keeps the demonstration usable; the setup SQL creates it. } Long max = jdbcTemplate.queryForObject( - "SELECT NVL(MAX(chunk_id), 28000) FROM cb_vector_document_chunk", Long.class); + "SELECT NVL(MAX(chunk_id), 28000) FROM sg_vector_document_chunk", Long.class); return (max == null ? 28000 : max) + 1; } diff --git a/src/main/resources/mapper/BearerTokenMapper.xml b/src/main/resources/mapper/BearerTokenMapper.xml index 523e981..a1661d4 100644 --- a/src/main/resources/mapper/BearerTokenMapper.xml +++ b/src/main/resources/mapper/BearerTokenMapper.xml @@ -3,47 +3,44 @@ "https://mybatis.org/dtd/mybatis-3-mapper.dtd"> - INSERT INTO hmm_access_bearer_tokens ( - key_id, employee_id, key_prefix, key_hash, expires_at, revoked_at, description + INSERT INTO sg_access_bearer_token ( + key_id, user_id, key_prefix, key_hash, expires_at, revoked_at, description ) VALUES ( #{keyId,jdbcType=NUMERIC}, #{userId,jdbcType=NUMERIC}, @@ -56,7 +53,7 @@ - UPDATE hmm_access_bearer_tokens + UPDATE sg_access_bearer_token SET revoked_at = #{revokedAt,jdbcType=TIMESTAMP}, description = CASE WHEN #{reason,jdbcType=VARCHAR} IS NULL THEN description diff --git a/src/main/resources/mapper/SettingMapper.xml b/src/main/resources/mapper/SettingMapper.xml index fe422a0..e32aeb1 100644 --- a/src/main/resources/mapper/SettingMapper.xml +++ b/src/main/resources/mapper/SettingMapper.xml @@ -4,12 +4,12 @@ - MERGE INTO cb_backoffice_setting dst + MERGE INTO sg_backoffice_setting dst USING ( SELECT #{settingKey,jdbcType=VARCHAR} setting_key, #{settingValue,jdbcType=VARCHAR} setting_value