forked from wangziqi/gongxue-base
feat: batch resolve public bank conflicts
This commit is contained in:
@@ -59,12 +59,12 @@ pages/student/profile/index 个人中心、会员、订单、签到、激
|
||||
pages/tenant-admin/workbench/index 租户后台工作台
|
||||
pages/tenant-admin/dashboard/index 数据看板
|
||||
pages/tenant-admin/students/index 学生与班级
|
||||
pages/tenant-admin/content/index 内容入口、导入任务、字段模板、异步轮询、复检、公共题库采纳/同步/冲突处理
|
||||
pages/tenant-admin/content/index 内容入口、导入任务、字段模板、异步轮询、复检、公共题库采纳/同步/单条和批量冲突处理
|
||||
pages/tenant-admin/marketing/index 优惠券、激活码、CRM、分佣摘要
|
||||
pages/tenant-admin/settings/index 品牌、域名、支付、登录、角色模板
|
||||
```
|
||||
|
||||
当前后台页面已经从只读联调推进到第一批运营写操作。题库内容页已接入公共题库采纳、公共题库同步、同步冲突查看、单条采纳平台版本/保留本地版本、导入任务详情、异步任务轮询、导入问题查看、模板预览/下载、导入后复检详情,以及 JSON/CSV/Excel 的 H5 选择文件或粘贴内容、后端预览、字段别名覆盖和同步/异步执行导入第一版;营销、设置和学生页仍以扫描和轻量操作为主。真正权限以后端 permission keys 为准,前端菜单隐藏只做体验优化。
|
||||
当前后台页面已经从只读联调推进到第一批运营写操作。题库内容页已接入公共题库采纳、公共题库同步、同步冲突查看、单条/批量采纳平台版本或保留本地版本、导入任务详情、异步任务轮询、导入问题查看、模板预览/下载、导入后复检详情,以及 JSON/CSV/Excel 的 H5 选择文件或粘贴内容、后端预览、字段别名覆盖和同步/异步执行导入第一版;营销、设置和学生页仍以扫描和轻量操作为主。真正权限以后端 permission keys 为准,前端菜单隐藏只做体验优化。
|
||||
|
||||
## 当前平台后台页面
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
loadPublicQuestionBanks,
|
||||
previewContentImport,
|
||||
resolvePublicQuestionBankConflict,
|
||||
resolvePublicQuestionBankConflicts,
|
||||
runImportPostCheck,
|
||||
syncPublicQuestionBank,
|
||||
type ContentEntryAdminItem,
|
||||
@@ -516,6 +517,43 @@ export default function TenantContentPage() {
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveVisibleConflicts(resolution: 'accept_platform' | 'keep_local') {
|
||||
const adoptionId = conflicts?.adoptionId;
|
||||
const sourceQuestionIds = conflictItems(conflicts)
|
||||
.map(item => item.sourceQuestionId || '')
|
||||
.filter(Boolean)
|
||||
.slice(0, 50);
|
||||
if (!adoptionId || !sourceQuestionIds.length) {
|
||||
setError('当前没有可批量处理的冲突。');
|
||||
return;
|
||||
}
|
||||
const ok = await confirm(
|
||||
resolution === 'accept_platform' ? '批量采纳平台版本' : '批量保留租户版本',
|
||||
resolution === 'accept_platform'
|
||||
? `确认批量用平台公共题库的新版本覆盖 ${sourceQuestionIds.length} 道租户副本?系统会逐条写入审计。`
|
||||
: `确认批量保留 ${sourceQuestionIds.length} 道租户本地版本?后续同步不再反复提示同一版本。`,
|
||||
);
|
||||
if (!ok) return;
|
||||
setBusy(`resolve-batch:${resolution}`);
|
||||
setError('');
|
||||
try {
|
||||
await resolvePublicQuestionBankConflicts({
|
||||
adoptionId,
|
||||
sourceQuestionIds,
|
||||
resolution,
|
||||
limit: sourceQuestionIds.length,
|
||||
});
|
||||
const payload = await loadPublicQuestionBankConflicts(adoptionId);
|
||||
setConflicts(payload.item || null);
|
||||
Taro.showToast({ title: '批量处理完成', icon: 'success' });
|
||||
reload();
|
||||
} catch (nextError) {
|
||||
setError(nextError instanceof Error ? nextError.message : '批量冲突处理失败');
|
||||
} finally {
|
||||
setBusy('');
|
||||
}
|
||||
}
|
||||
|
||||
const postCheckSummary = postCheck?.importPostCheck && typeof postCheck.importPostCheck === 'object'
|
||||
? postCheck.importPostCheck as Record<string, unknown>
|
||||
: postCheck;
|
||||
@@ -711,6 +749,12 @@ export default function TenantContentPage() {
|
||||
<Text className='admin-row-main'>状态 {String(conflicts.status || conflicts.syncStatus || '-')}</Text>
|
||||
<Text className='admin-row-meta'>冲突数 {String(conflicts.conflictCount || 0)} · 最近同步 {String(conflicts.lastSyncedAt || '')}</Text>
|
||||
<Text className='admin-row-meta'>采纳平台会覆盖为平台新版;保留本地会记录本次冲突已处理。</Text>
|
||||
{conflictItems(conflicts).length ? (
|
||||
<View className='admin-row-actions'>
|
||||
<Button className='admin-mini-button primary' loading={busy === 'resolve-batch:accept_platform'} onClick={() => resolveVisibleConflicts('accept_platform')}>全部采纳平台</Button>
|
||||
<Button className='admin-mini-button' loading={busy === 'resolve-batch:keep_local'} onClick={() => resolveVisibleConflicts('keep_local')}>全部保留本地</Button>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
{conflictItems(conflicts).slice(0, 20).map((item, index) => (
|
||||
<View className='admin-row' key={`${item.sourceQuestionId || index}-${item.targetQuestionId || ''}`}>
|
||||
|
||||
@@ -318,6 +318,18 @@ export async function resolvePublicQuestionBankConflict(input: { adoptionId: str
|
||||
});
|
||||
}
|
||||
|
||||
export async function resolvePublicQuestionBankConflicts(input: {
|
||||
adoptionId: string;
|
||||
sourceQuestionIds: string[];
|
||||
resolution: 'accept_platform' | 'keep_local';
|
||||
limit?: number;
|
||||
}) {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/tenant-content/public-question-banks/conflicts/resolve-batch', {
|
||||
method: 'POST',
|
||||
body: input,
|
||||
});
|
||||
}
|
||||
|
||||
export async function runImportPostCheck(jobId: string) {
|
||||
return apiRequest<{ item?: Record<string, unknown> }>('/api/tenant-content/imports/post-check', {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user