feat: 站点编辑增加状态字段 active/deprecated 切换

This commit is contained in:
mediabot-pt
2026-06-30 12:30:06 +08:00
parent 3a9b98ff5d
commit 9b5ad7cc03
4 changed files with 16 additions and 5 deletions

View File

@@ -51,10 +51,11 @@ public class SiteController {
String description = (String) payload.get("description");
String baseUrl = (String) payload.get("baseUrl");
String siteType = (String) payload.get("siteType");
String status = (String) payload.get("status");
Long operatorId = (Long) request.getAttribute("accountId");
try {
Site site = siteService.updateSite(siteId, name, description, baseUrl, siteType, operatorId);
Site site = siteService.updateSite(siteId, name, description, baseUrl, siteType, status, operatorId);
return ApiResponse.success(siteService.toDTO(site));
} catch (IllegalArgumentException e) {
return ApiResponse.error(404, e.getMessage());

View File

@@ -44,7 +44,7 @@ public interface SiteService {
* 管理员编辑站点基本信息
*/
Site updateSite(String siteId, String name, String description, String baseUrl,
String siteType, Long operatorId);
String siteType, String status, Long operatorId);
/** 所有站点列表(管理员用) */
List<Site> listAllSites();

View File

@@ -195,7 +195,7 @@ public class SiteServiceImpl implements SiteService {
@Override
public Site updateSite(String siteId, String name, String description, String baseUrl,
String siteType, Long operatorId) {
String siteType, String status, Long operatorId) {
Site site = siteMapper.selectBySiteId(siteId);
if (site == null) throw new IllegalArgumentException("站点不存在: " + siteId);
@@ -215,6 +215,9 @@ public class SiteServiceImpl implements SiteService {
if (siteType != null && !siteType.isBlank()) {
try { site.setSiteType(SiteType.fromValue(siteType)); } catch (Exception ignored) {}
}
if (status != null && !status.isBlank()) {
try { site.setStatus(SiteStatus.fromValue(status)); } catch (Exception ignored) {}
}
siteMapper.updateById(site);
log.info("站点编辑: siteId={}", siteId);
return site;

View File

@@ -49,6 +49,12 @@
<el-option v-for="t in siteTypes" :key="t.value" :label="t.label" :value="t.value" />
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="editForm.status" style="width:100%">
<el-option label="活跃" value="active" />
<el-option label="弃用" value="deprecated" />
</el-select>
</el-form-item>
<el-form-item label="描述">
<el-input v-model="editForm.description" type="textarea" :rows="3" placeholder="站点描述" />
</el-form-item>
@@ -116,7 +122,7 @@ import api from '../api'
const sites = ref([])
const loading = ref(false)
const editVisible = ref(false), saving = ref(false)
const editForm = ref({ id: null, siteId: '', name: '', baseUrl: '', siteType: '', description: '' })
const editForm = ref({ id: null, siteId: '', name: '', baseUrl: '', siteType: '', status: '', description: '' })
const siteTypes = [
{ value: 'nexusphp', label: 'NexusPHP' }, { value: 'mtorrent', label: 'MTorrent' },
{ value: 'mteam', label: 'M-Team API' }, { value: 'pttime', label: 'PTTime' },
@@ -140,7 +146,7 @@ const fetchAll = async () => {
}
const handleEdit = (row) => {
editForm.value = { id: row.id, siteId: row.siteId, name: (row.names||[]).join('\n'), baseUrl: (row.urls||[]).join('\n'), siteType: row.siteType||'', description: row.description||'' }
editForm.value = { id: row.id, siteId: row.siteId, name: (row.names||[]).join('\n'), baseUrl: (row.urls||[]).join('\n'), siteType: row.siteType||'', status: row.status||'active', description: row.description||'' }
editVisible.value = true
}
@@ -152,6 +158,7 @@ const handleSave = async () => {
name: editForm.value.name.trim().split('\n').filter(Boolean)[0]||'',
baseUrl: editForm.value.baseUrl.trim().split('\n').filter(Boolean)[0]||'',
siteType: editForm.value.siteType.trim()||'unknown',
status: editForm.value.status||'active',
description: editForm.value.description.trim()||null,
})
ElMessage.success('保存成功'); editVisible.value = false; fetchAll()