fix: 审核通过时发送 names[]/urls[] 数组,列表正确显示多名称多地址
This commit is contained in:
@@ -277,12 +277,14 @@ public class AdminController {
|
|||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
checkAdmin(request);
|
checkAdmin(request);
|
||||||
Long reviewerId = (Long) request.getAttribute("accountId");
|
Long reviewerId = (Long) request.getAttribute("accountId");
|
||||||
String name = body != null ? (String) body.get("name") : null;
|
@SuppressWarnings("unchecked")
|
||||||
String baseUrl = body != null ? (String) body.get("baseUrl") : null;
|
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 siteType = body != null ? (String) body.get("siteType") : null;
|
||||||
String status = body != null ? (String) body.get("status") : null;
|
String status = body != null ? (String) body.get("status") : null;
|
||||||
String notes = body != null ? (String) body.get("notes") : 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);
|
log.info("Change approved: id={}, reviewer={}", id, reviewerId);
|
||||||
return ApiResponse.success();
|
return ApiResponse.success();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ public interface SiteService {
|
|||||||
/** 待审核变更列表 */
|
/** 待审核变更列表 */
|
||||||
List<SiteChangeDTO> listPendingChanges();
|
List<SiteChangeDTO> listPendingChanges();
|
||||||
|
|
||||||
/** 审核通过 → 写入 sites 表(支持审核时编辑 name/baseUrl/siteType/status/notes) */
|
/** 审核通过 → 写入 sites 表(支持审核时编辑 names/urls/...) */
|
||||||
Site approveChange(Long changeId, Long reviewerId, String name, String baseUrl,
|
Site approveChange(Long changeId, Long reviewerId, List<String> names, List<String> urls,
|
||||||
String siteType, String status, String notes);
|
String siteType, String status, String notes);
|
||||||
|
|
||||||
/** 拒绝变更 */
|
/** 拒绝变更 */
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public class SiteServiceImpl implements SiteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
String reviewerSiteType, String reviewerStatus, String reviewerNotes) {
|
||||||
SiteChange entry = changeMapper.selectById(changeId);
|
SiteChange entry = changeMapper.selectById(changeId);
|
||||||
if (entry == null) throw new IllegalArgumentException("变更记录不存在");
|
if (entry == null) throw new IllegalArgumentException("变更记录不存在");
|
||||||
@@ -251,9 +251,9 @@ public class SiteServiceImpl implements SiteService {
|
|||||||
|
|
||||||
// 优先使用审核者编辑的数据,否则用原始提交数据
|
// 优先使用审核者编辑的数据,否则用原始提交数据
|
||||||
@SuppressWarnings("unchecked")
|
@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>) 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());
|
: (List<String>) raw.getOrDefault("urls", List.of());
|
||||||
String notes = reviewerNotes != null ? reviewerNotes : (String) raw.getOrDefault("notes", "");
|
String notes = reviewerNotes != null ? reviewerNotes : (String) raw.getOrDefault("notes", "");
|
||||||
|
|
||||||
|
|||||||
@@ -105,13 +105,13 @@ const handleApprove = (row) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const confirmApprove = async () => {
|
const confirmApprove = async () => {
|
||||||
const name = approveForm.namesText.split('\n').map(s => s.trim()).filter(Boolean)[0] || ''
|
const names = approveForm.namesText.split('\n').map(s => s.trim()).filter(Boolean)
|
||||||
const baseUrl = approveForm.urlsText.split('\n').map(s => s.trim()).filter(Boolean)[0] || ''
|
const urls = approveForm.urlsText.split('\n').map(s => s.trim()).filter(Boolean)
|
||||||
if (!name || !baseUrl) { ElMessage.warning('名称和地址不能为空'); return }
|
if (names.length === 0 || urls.length === 0) { ElMessage.warning('名称和地址不能为空'); return }
|
||||||
saving.value = true
|
saving.value = true
|
||||||
try {
|
try {
|
||||||
await api.sites.approveChange(approveForm.id, {
|
await api.sites.approveChange(approveForm.id, {
|
||||||
name, baseUrl,
|
names, urls,
|
||||||
siteType: approveForm.siteType || 'unknown',
|
siteType: approveForm.siteType || 'unknown',
|
||||||
status: approveForm.status,
|
status: approveForm.status,
|
||||||
notes: approveForm.notes || null,
|
notes: approveForm.notes || null,
|
||||||
|
|||||||
Reference in New Issue
Block a user