feat(aihr): complete company message R1-R3

This commit is contained in:
2026-07-24 23:25:15 +08:00
parent 5d864a1444
commit 342f84a9de
37 changed files with 2479 additions and 42 deletions
+75 -1
View File
@@ -170,6 +170,8 @@ FROM (
UNION ALL SELECT 'aihr_broadcast_version'
UNION ALL SELECT 'aihr_broadcast_target_rule'
UNION ALL SELECT 'aihr_broadcast_target_recipient'
UNION ALL SELECT 'aihr_broadcast_attachment'
UNION ALL SELECT 'aihr_direct_feedback'
UNION ALL SELECT 'aihr_personal_space'
UNION ALL SELECT 'aihr_personal_item'
UNION ALL SELECT 'aihr_personal_fragment'
@@ -472,6 +474,75 @@ REMOTE
[[ "$broadcast_target_recipient_unique_index" = "0|tenant_id,message_id,recipient_key|0" ]] \
|| fail "remote broadcast target-recipient unique index invalid: expected unique full columns tenant_id,message_id,recipient_key; got ${broadcast_target_recipient_unique_index:-missing}"
local direct_feedback_contract
direct_feedback_contract="$(ssh -o BatchMode=yes -o ConnectTimeout=10 "$remote_ssh" bash -s -- "$remote_db" <<'REMOTE'
set -euo pipefail
db="$1"
mysql --batch --skip-column-names --connect-timeout=5 "$db" <<'SQL'
SELECT CONCAT(
COUNT(DISTINCT c.column_name), '|',
MIN(s.non_unique), '|',
COALESCE(GROUP_CONCAT(DISTINCT s.column_name ORDER BY s.seq_in_index), ''), '|',
SUM(s.sub_part IS NOT NULL)
)
FROM information_schema.columns c
LEFT JOIN information_schema.statistics s
ON s.table_schema = c.table_schema
AND s.table_name = c.table_name
AND s.index_name = 'uk_aihr_direct_feedback_submit'
WHERE c.table_schema = DATABASE()
AND c.table_name = 'aihr_direct_feedback'
AND c.column_name IN ('tenant_id','channel_code','sender_user_id','anonymous_flag','content','status','submit_request_key','submit_request_hash','reply_content','replied_by','replied_time');
SQL
REMOTE
)" || fail "remote direct-feedback schema check failed: $remote_ssh:$remote_db"
[[ "$direct_feedback_contract" = "11|0|tenant_id,sender_user_id,submit_request_key|0" ]] \
|| fail "remote direct-feedback contract invalid: expected 11 business columns and unique tenant_id,sender_user_id,submit_request_key; got ${direct_feedback_contract:-missing}"
local direct_role_count
direct_role_count="$(ssh -o BatchMode=yes -o ConnectTimeout=10 "$remote_ssh" bash -s -- "$remote_db" <<'REMOTE'
set -euo pipefail
db="$1"
mysql --batch --skip-column-names --connect-timeout=5 "$db" <<'SQL'
SELECT COUNT(DISTINCT role_key)
FROM sys_role
WHERE tenant_id = '000000'
AND del_flag = '0'
AND role_key IN ('direct_president','direct_finance','direct_hr','direct_audit','direct_operations');
SQL
REMOTE
)" || fail "remote direct-feedback role check failed: $remote_ssh:$remote_db"
[[ "$direct_role_count" = "5" ]] \
|| fail "remote direct-feedback roles incomplete: expected 5/5; got ${direct_role_count:-0}/5"
local broadcast_attachment_contract
broadcast_attachment_contract="$(ssh -o BatchMode=yes -o ConnectTimeout=10 "$remote_ssh" bash -s -- "$remote_db" <<'REMOTE'
set -euo pipefail
db="$1"
mysql --batch --skip-column-names --connect-timeout=5 "$db" <<'SQL'
SELECT CONCAT(
(SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'aihr_broadcast_attachment'
AND column_name IN ('tenant_id','message_id','oss_id','file_name','file_size','content_type','status','extracted_text','summary','error_message','uploaded_by')),
'|',
(SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 'aihr_broadcast_message'
AND column_name = 'attachment_id'),
'|',
COALESCE((SELECT GROUP_CONCAT(column_name ORDER BY seq_in_index)
FROM information_schema.statistics
WHERE table_schema = DATABASE()
AND table_name = 'aihr_broadcast_message'
AND index_name = 'idx_aihr_broadcast_message_attachment'), '')
);
SQL
REMOTE
)" || fail "remote broadcast-attachment schema check failed: $remote_ssh:$remote_db"
[[ "$broadcast_attachment_contract" = "11|1|tenant_id,attachment_id" ]] \
|| fail "remote broadcast-attachment contract invalid: expected 11 attachment columns and indexed message attachment_id; got ${broadcast_attachment_contract:-missing}"
local missing_work_assistant_columns
missing_work_assistant_columns="$(ssh -o BatchMode=yes -o ConnectTimeout=10 "$remote_ssh" bash -s -- "$remote_db" <<'REMOTE'
set -euo pipefail
@@ -500,7 +571,7 @@ REMOTE
[[ -z "$missing_work_assistant_columns" ]] \
|| fail "remote work-assistant schema missing required columns: $(printf '%s' "$missing_work_assistant_columns" | tr '\n' ', ' | sed 's/, $//')"
echo "remote_schema=62/62 $remote_ssh:$remote_db"
echo "remote_schema=64/64 $remote_ssh:$remote_db"
echo "remote_work_report_idempotency=3/3 $remote_ssh:$remote_db"
echo "remote_knowledge_category_columns=7/7 $remote_ssh:$remote_db"
echo "remote_broadcast_publish_audit_columns=3/3 $remote_ssh:$remote_db"
@@ -511,6 +582,9 @@ REMOTE
echo "remote_broadcast_target_table_contract=16/16 $remote_ssh:$remote_db"
echo "remote_broadcast_target_rule_uniqueness=4/4 $remote_ssh:$remote_db"
echo "remote_broadcast_target_recipient_uniqueness=3/3 $remote_ssh:$remote_db"
echo "remote_direct_feedback_contract=11/11 $remote_ssh:$remote_db"
echo "remote_direct_feedback_roles=5/5 $remote_ssh:$remote_db"
echo "remote_broadcast_attachment_contract=12/12 $remote_ssh:$remote_db"
echo "remote_broadcast_question_context=1/1 $remote_ssh:$remote_db"
echo "remote_work_assistant_columns=8/8 $remote_ssh:$remote_db"
echo "remote_personal_oss_configuration=true $remote_ssh:$remote_db"