feat: 站点编辑增加状态字段 active/deprecated 切换
This commit is contained in:
@@ -51,10 +51,11 @@ public class SiteController {
|
|||||||
String description = (String) payload.get("description");
|
String description = (String) payload.get("description");
|
||||||
String baseUrl = (String) payload.get("baseUrl");
|
String baseUrl = (String) payload.get("baseUrl");
|
||||||
String siteType = (String) payload.get("siteType");
|
String siteType = (String) payload.get("siteType");
|
||||||
|
String status = (String) payload.get("status");
|
||||||
Long operatorId = (Long) request.getAttribute("accountId");
|
Long operatorId = (Long) request.getAttribute("accountId");
|
||||||
|
|
||||||
try {
|
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));
|
return ApiResponse.success(siteService.toDTO(site));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return ApiResponse.error(404, e.getMessage());
|
return ApiResponse.error(404, e.getMessage());
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public interface SiteService {
|
|||||||
* 管理员编辑站点基本信息
|
* 管理员编辑站点基本信息
|
||||||
*/
|
*/
|
||||||
Site updateSite(String siteId, String name, String description, String baseUrl,
|
Site updateSite(String siteId, String name, String description, String baseUrl,
|
||||||
String siteType, Long operatorId);
|
String siteType, String status, Long operatorId);
|
||||||
|
|
||||||
/** 所有站点列表(管理员用) */
|
/** 所有站点列表(管理员用) */
|
||||||
List<Site> listAllSites();
|
List<Site> listAllSites();
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ public class SiteServiceImpl implements SiteService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Site updateSite(String siteId, String name, String description, String baseUrl,
|
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);
|
Site site = siteMapper.selectBySiteId(siteId);
|
||||||
if (site == null) throw new IllegalArgumentException("站点不存在: " + siteId);
|
if (site == null) throw new IllegalArgumentException("站点不存在: " + siteId);
|
||||||
|
|
||||||
@@ -215,6 +215,9 @@ public class SiteServiceImpl implements SiteService {
|
|||||||
if (siteType != null && !siteType.isBlank()) {
|
if (siteType != null && !siteType.isBlank()) {
|
||||||
try { site.setSiteType(SiteType.fromValue(siteType)); } catch (Exception ignored) {}
|
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);
|
siteMapper.updateById(site);
|
||||||
log.info("站点编辑: siteId={}", siteId);
|
log.info("站点编辑: siteId={}", siteId);
|
||||||
return site;
|
return site;
|
||||||
|
|||||||
@@ -49,6 +49,12 @@
|
|||||||
<el-option v-for="t in siteTypes" :key="t.value" :label="t.label" :value="t.value" />
|
<el-option v-for="t in siteTypes" :key="t.value" :label="t.label" :value="t.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</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-form-item label="描述">
|
||||||
<el-input v-model="editForm.description" type="textarea" :rows="3" placeholder="站点描述" />
|
<el-input v-model="editForm.description" type="textarea" :rows="3" placeholder="站点描述" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -116,7 +122,7 @@ import api from '../api'
|
|||||||
const sites = ref([])
|
const sites = ref([])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const editVisible = ref(false), saving = 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 = [
|
const siteTypes = [
|
||||||
{ value: 'nexusphp', label: 'NexusPHP' }, { value: 'mtorrent', label: 'MTorrent' },
|
{ value: 'nexusphp', label: 'NexusPHP' }, { value: 'mtorrent', label: 'MTorrent' },
|
||||||
{ value: 'mteam', label: 'M-Team API' }, { value: 'pttime', label: 'PTTime' },
|
{ value: 'mteam', label: 'M-Team API' }, { value: 'pttime', label: 'PTTime' },
|
||||||
@@ -140,7 +146,7 @@ const fetchAll = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleEdit = (row) => {
|
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
|
editVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +158,7 @@ const handleSave = async () => {
|
|||||||
name: editForm.value.name.trim().split('\n').filter(Boolean)[0]||'',
|
name: editForm.value.name.trim().split('\n').filter(Boolean)[0]||'',
|
||||||
baseUrl: editForm.value.baseUrl.trim().split('\n').filter(Boolean)[0]||'',
|
baseUrl: editForm.value.baseUrl.trim().split('\n').filter(Boolean)[0]||'',
|
||||||
siteType: editForm.value.siteType.trim()||'unknown',
|
siteType: editForm.value.siteType.trim()||'unknown',
|
||||||
|
status: editForm.value.status||'active',
|
||||||
description: editForm.value.description.trim()||null,
|
description: editForm.value.description.trim()||null,
|
||||||
})
|
})
|
||||||
ElMessage.success('保存成功'); editVisible.value = false; fetchAll()
|
ElMessage.success('保存成功'); editVisible.value = false; fetchAll()
|
||||||
|
|||||||
Reference in New Issue
Block a user