feat(backoffice): migrate remaining menus to Smilegate tables
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,47 +3,44 @@
|
||||
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cloudhandson.vpdbackoffice.mapper.BearerTokenMapper">
|
||||
<select id="findAll" resultType="com.cloudhandson.vpdbackoffice.domain.token.BearerTokenRecord">
|
||||
SELECT k.key_id, k.employee_id AS user_id, u.full_name AS username,
|
||||
SELECT k.key_id, k.user_id, u.user_name AS username,
|
||||
CAST(NULL AS VARCHAR2(100)) AS stakeholder_user_id,
|
||||
CAST(NULL AS VARCHAR2(100)) AS stakeholder_role, CAST(NULL AS VARCHAR2(100)) AS stakeholder_channel,
|
||||
k.key_prefix, k.key_hash,
|
||||
k.expires_at, k.revoked_at, k.description
|
||||
FROM hmm_access_bearer_tokens k
|
||||
JOIN hmm_hr_employees u ON u.employee_id = k.employee_id
|
||||
FROM sg_access_bearer_token k JOIN sg_app_user u ON u.user_id = k.user_id
|
||||
WHERE #{includeInactive} = 1
|
||||
OR (k.revoked_at IS NULL AND k.expires_at > SYSTIMESTAMP)
|
||||
ORDER BY k.key_id DESC
|
||||
</select>
|
||||
|
||||
<select id="findById" resultType="com.cloudhandson.vpdbackoffice.domain.token.BearerTokenRecord">
|
||||
SELECT k.key_id, k.employee_id AS user_id, u.full_name AS username,
|
||||
SELECT k.key_id, k.user_id, u.user_name AS username,
|
||||
CAST(NULL AS VARCHAR2(100)) AS stakeholder_user_id,
|
||||
CAST(NULL AS VARCHAR2(100)) AS stakeholder_role, CAST(NULL AS VARCHAR2(100)) AS stakeholder_channel,
|
||||
k.key_prefix, k.key_hash,
|
||||
k.expires_at, k.revoked_at, k.description
|
||||
FROM hmm_access_bearer_tokens k
|
||||
JOIN hmm_hr_employees u ON u.employee_id = k.employee_id
|
||||
FROM sg_access_bearer_token k JOIN sg_app_user u ON u.user_id = k.user_id
|
||||
WHERE k.key_id = #{keyId}
|
||||
</select>
|
||||
|
||||
<select id="findByHash" resultType="com.cloudhandson.vpdbackoffice.domain.token.BearerTokenRecord">
|
||||
SELECT k.key_id, k.employee_id AS user_id, u.full_name AS username,
|
||||
SELECT k.key_id, k.user_id, u.user_name AS username,
|
||||
CAST(NULL AS VARCHAR2(100)) AS stakeholder_user_id,
|
||||
CAST(NULL AS VARCHAR2(100)) AS stakeholder_role, CAST(NULL AS VARCHAR2(100)) AS stakeholder_channel,
|
||||
k.key_prefix, k.key_hash,
|
||||
k.expires_at, k.revoked_at, k.description
|
||||
FROM hmm_access_bearer_tokens k
|
||||
JOIN hmm_hr_employees u ON u.employee_id = k.employee_id
|
||||
FROM sg_access_bearer_token k JOIN sg_app_user u ON u.user_id = k.user_id
|
||||
WHERE k.key_hash = #{keyHash,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="nextKeyId" resultType="long">
|
||||
SELECT NVL(MAX(key_id), 0) + 1 FROM hmm_access_bearer_tokens
|
||||
SELECT NVL(MAX(key_id), 0) + 1 FROM sg_access_bearer_token
|
||||
</select>
|
||||
|
||||
<insert id="insertToken" parameterType="com.cloudhandson.vpdbackoffice.domain.token.BearerTokenRecord">
|
||||
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 @@
|
||||
</insert>
|
||||
|
||||
<update id="revokeToken">
|
||||
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
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
<mapper namespace="com.cloudhandson.vpdbackoffice.mapper.SettingMapper">
|
||||
<select id="findByKey" resultType="com.cloudhandson.vpdbackoffice.domain.setting.BackofficeSetting">
|
||||
SELECT setting_key, setting_value
|
||||
FROM cb_backoffice_setting
|
||||
FROM sg_backoffice_setting
|
||||
WHERE setting_key = #{settingKey,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<update id="upsert">
|
||||
MERGE INTO cb_backoffice_setting dst
|
||||
MERGE INTO sg_backoffice_setting dst
|
||||
USING (
|
||||
SELECT #{settingKey,jdbcType=VARCHAR} setting_key,
|
||||
#{settingValue,jdbcType=VARCHAR} setting_value
|
||||
|
||||
Reference in New Issue
Block a user