fix: 审核通过时发送 names[]/urls[] 数组,列表正确显示多名称多地址

This commit is contained in:
mediabot-pt
2026-06-30 14:09:40 +08:00
parent 266669e96b
commit 9be2d0313a
4 changed files with 14 additions and 12 deletions

View File

@@ -277,12 +277,14 @@ public class AdminController {
HttpServletRequest request) {
checkAdmin(request);
Long reviewerId = (Long) request.getAttribute("accountId");
String name = body != null ? (String) body.get("name") : null;
String baseUrl = body != null ? (String) body.get("baseUrl") : null;
@SuppressWarnings("unchecked")
List<String> names = body != null ? (List<String>) body.get("names") : null;
@SuppressWarnings("unchecked")
List<String> urls = body != null ? (List<String>) body.get("urls") : null;
String siteType = body != null ? (String) body.get("siteType") : null;
String status = body != null ? (String) body.get("status") : null;
String notes = body != null ? (String) body.get("notes") : null;
siteService.approveChange(id, reviewerId, name, baseUrl, siteType, status, notes);
siteService.approveChange(id, reviewerId, names, urls, siteType, status, notes);
log.info("Change approved: id={}, reviewer={}", id, reviewerId);
return ApiResponse.success();
}

View File

@@ -52,8 +52,8 @@ public interface SiteService {
/** 待审核变更列表 */
List<SiteChangeDTO> listPendingChanges();
/** 审核通过 → 写入 sites 表(支持审核时编辑 name/baseUrl/siteType/status/notes) */
Site approveChange(Long changeId, Long reviewerId, String name, String baseUrl,
/** 审核通过 → 写入 sites 表(支持审核时编辑 names/urls/...) */
Site approveChange(Long changeId, Long reviewerId, List<String> names, List<String> urls,
String siteType, String status, String notes);
/** 拒绝变更 */

View File

@@ -236,7 +236,7 @@ public class SiteServiceImpl implements SiteService {
}
@Override
public Site approveChange(Long changeId, Long reviewerId, String reviewerName, String reviewerBaseUrl,
public Site approveChange(Long changeId, Long reviewerId, List<String> reviewerNames, List<String> reviewerUrls,
String reviewerSiteType, String reviewerStatus, String reviewerNotes) {
SiteChange entry = changeMapper.selectById(changeId);
if (entry == null) throw new IllegalArgumentException("变更记录不存在");
@@ -251,9 +251,9 @@ public class SiteServiceImpl implements SiteService {
// 优先使用审核者编辑的数据,否则用原始提交数据
@SuppressWarnings("unchecked")
List<String> names = reviewerName != null ? List.of(reviewerName)
List<String> names = (reviewerNames != null && !reviewerNames.isEmpty()) ? reviewerNames
: (List<String>) raw.getOrDefault("names", List.of());
List<String> urls = reviewerBaseUrl != null ? List.of(reviewerBaseUrl)
List<String> urls = (reviewerUrls != null && !reviewerUrls.isEmpty()) ? reviewerUrls
: (List<String>) raw.getOrDefault("urls", List.of());
String notes = reviewerNotes != null ? reviewerNotes : (String) raw.getOrDefault("notes", "");

View File

@@ -105,13 +105,13 @@ const handleApprove = (row) => {
}
const confirmApprove = async () => {
const name = approveForm.namesText.split('\n').map(s => s.trim()).filter(Boolean)[0] || ''
const baseUrl = approveForm.urlsText.split('\n').map(s => s.trim()).filter(Boolean)[0] || ''
if (!name || !baseUrl) { ElMessage.warning('名称和地址不能为空'); return }
const names = approveForm.namesText.split('\n').map(s => s.trim()).filter(Boolean)
const urls = approveForm.urlsText.split('\n').map(s => s.trim()).filter(Boolean)
if (names.length === 0 || urls.length === 0) { ElMessage.warning('名称和地址不能为空'); return }
saving.value = true
try {
await api.sites.approveChange(approveForm.id, {
name, baseUrl,
names, urls,
siteType: approveForm.siteType || 'unknown',
status: approveForm.status,
notes: approveForm.notes || null,