131 lines
2.6 KiB
HTML
131 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>biz_key 私聊演示</title>
|
|
<style>
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
|
|
Helvetica, Arial, sans-serif;
|
|
background: #f5f7fa;
|
|
padding: 40px;
|
|
}
|
|
|
|
h1 {
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.container {
|
|
display: flex;
|
|
gap: 24px;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.card {
|
|
background: #fff;
|
|
border-radius: 8px;
|
|
padding: 16px;
|
|
width: 240px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
}
|
|
|
|
.card h2 {
|
|
font-size: 16px;
|
|
margin-bottom: 12px;
|
|
border-bottom: 1px solid #eee;
|
|
padding-bottom: 8px;
|
|
}
|
|
|
|
.user {
|
|
padding: 10px;
|
|
margin-bottom: 8px;
|
|
background: #f0f3f7;
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.arrow {
|
|
font-size: 32px;
|
|
margin: 0 8px;
|
|
align-self: center;
|
|
}
|
|
|
|
.biz {
|
|
background: #e8f3ff;
|
|
border: 1px dashed #409eff;
|
|
padding: 12px;
|
|
border-radius: 6px;
|
|
text-align: center;
|
|
font-weight: bold;
|
|
color: #409eff;
|
|
}
|
|
|
|
.db-row {
|
|
background: #f6ffed;
|
|
border: 1px solid #b7eb8f;
|
|
padding: 10px;
|
|
border-radius: 6px;
|
|
margin-bottom: 8px;
|
|
font-family: monospace;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.note {
|
|
margin-top: 24px;
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>biz_key 私聊唯一性演示</h1>
|
|
|
|
<div class="container">
|
|
<!-- 用户 -->
|
|
<div class="card">
|
|
<h2>用户</h2>
|
|
<div class="user">用户 A<br />user_id = 1</div>
|
|
<div class="user">用户 B<br />user_id = 2</div>
|
|
</div>
|
|
|
|
<div class="arrow">➡️</div>
|
|
|
|
<!-- biz_key -->
|
|
<div class="card">
|
|
<h2>biz_key 生成</h2>
|
|
<div class="biz">
|
|
min(1,2) _ max(1,2)<br />
|
|
= <br />
|
|
<strong>1_2</strong>
|
|
</div>
|
|
<div class="note">
|
|
不管 A→B 还是 B→A<br />
|
|
biz_key 都是一样的
|
|
</div>
|
|
</div>
|
|
|
|
<div class="arrow">➡️</div>
|
|
|
|
<!-- 数据库 -->
|
|
<div class="card">
|
|
<h2>数据库会话表</h2>
|
|
<div class="db-row">
|
|
id: 1001<br />
|
|
space_id: 100<br />
|
|
type: 私聊<br />
|
|
biz_key: 1_2
|
|
</div>
|
|
<div class="note">
|
|
唯一索引:<br />
|
|
(space_id, type, biz_key)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="note">
|
|
👉 结论:<br />
|
|
<strong>biz_key = “这是谁和谁的私聊”</strong><br />
|
|
<strong>id = “数据库给它的编号”</strong>
|
|
</div>
|
|
</body>
|
|
</html>
|