增加删除域名所有者模板的api端点及实现功能并测试通过
This commit is contained in:
parent
bf0fce72cd
commit
107daadf5e
@ -106,6 +106,15 @@
|
|||||||
>
|
>
|
||||||
<EditIcon class="h-4 w-4" />
|
<EditIcon class="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
@click="deleteOwner(owner)"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
class="text-red-600 hover:text-red-700"
|
||||||
|
title="删除"
|
||||||
|
>
|
||||||
|
<Trash2Icon class="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -452,6 +461,7 @@ import DomainOwnerDialog from './DomainOwnerDialog.vue';
|
|||||||
import SearchIcon from '~icons/lucide/search';
|
import SearchIcon from '~icons/lucide/search';
|
||||||
import EyeIcon from '~icons/lucide/eye';
|
import EyeIcon from '~icons/lucide/eye';
|
||||||
import EditIcon from '~icons/lucide/edit';
|
import EditIcon from '~icons/lucide/edit';
|
||||||
|
import Trash2Icon from '~icons/lucide/trash-2';
|
||||||
import Loader2Icon from '~icons/lucide/loader-2';
|
import Loader2Icon from '~icons/lucide/loader-2';
|
||||||
import AlertCircleIcon from '~icons/lucide/alert-circle';
|
import AlertCircleIcon from '~icons/lucide/alert-circle';
|
||||||
import UsersIcon from '~icons/lucide/users';
|
import UsersIcon from '~icons/lucide/users';
|
||||||
@ -465,6 +475,7 @@ export default {
|
|||||||
SearchIcon,
|
SearchIcon,
|
||||||
EyeIcon,
|
EyeIcon,
|
||||||
EditIcon,
|
EditIcon,
|
||||||
|
Trash2Icon,
|
||||||
Loader2Icon,
|
Loader2Icon,
|
||||||
AlertCircleIcon,
|
AlertCircleIcon,
|
||||||
UsersIcon,
|
UsersIcon,
|
||||||
@ -790,6 +801,43 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 删除域名所有者
|
||||||
|
async deleteOwner(owner) {
|
||||||
|
confirmDialog({
|
||||||
|
title: '确认删除',
|
||||||
|
message: `确定要删除域名所有者模板 "<strong>${this.getDisplayName(owner)}</strong>" 吗?<br><br>此操作将同时删除西部数码平台和本地的模板记录,且不可逆。`,
|
||||||
|
primaryAction: {
|
||||||
|
label: '删除',
|
||||||
|
variant: 'solid',
|
||||||
|
onClick: async ({ hide }) => {
|
||||||
|
try {
|
||||||
|
const deleteRequest = createResource({
|
||||||
|
url: 'jcloud.api.domain_west.delete_domain_owner',
|
||||||
|
params: { name: owner.name },
|
||||||
|
onSuccess: (response) => {
|
||||||
|
if (response.status === 'Success') {
|
||||||
|
toast.success('域名所有者模板删除成功!');
|
||||||
|
this.fetchOwners(); // 刷新列表
|
||||||
|
hide();
|
||||||
|
} else {
|
||||||
|
throw new Error(response.message || '删除失败');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
throw new Error(getToastErrorMessage(error));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await deleteRequest.submit();
|
||||||
|
} catch (error) {
|
||||||
|
toast.error(error.message || '删除失败,请稍后重试');
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// 上一页
|
// 上一页
|
||||||
previousPage() {
|
previousPage() {
|
||||||
if (this.pagination.pageno > 1) {
|
if (this.pagination.pageno > 1) {
|
||||||
|
|||||||
@ -504,6 +504,23 @@ class WestDomain:
|
|||||||
|
|
||||||
return self._make_request('/audit/', 'POST', body_params=encoded_data)
|
return self._make_request('/audit/', 'POST', body_params=encoded_data)
|
||||||
|
|
||||||
|
def delete_contact_template(self, template_id: str) -> Dict[str, Any]:
|
||||||
|
"""
|
||||||
|
删除指定模板
|
||||||
|
|
||||||
|
Args:
|
||||||
|
template_id: 模板标识(c_sysid)
|
||||||
|
"""
|
||||||
|
if not template_id:
|
||||||
|
return {"status": "error", "message": "缺少必要参数:template_id"}
|
||||||
|
|
||||||
|
body_params = {
|
||||||
|
'act': 'auditdel',
|
||||||
|
'c_sysid': template_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
return self._make_request('/audit/', 'POST', body_params=body_params)
|
||||||
|
|
||||||
def get_domain_real_info(self, domain: str) -> Dict[str, Any]:
|
def get_domain_real_info(self, domain: str) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
获取域名实名信息
|
获取域名实名信息
|
||||||
@ -3375,3 +3392,56 @@ def update_domain_owner(name, **data):
|
|||||||
return {"status": "Error", "message": f"更新域名所有者信息失败: {str(e)}"}
|
return {"status": "Error", "message": f"更新域名所有者信息失败: {str(e)}"}
|
||||||
|
|
||||||
|
|
||||||
|
@jingrow.whitelist()
|
||||||
|
def delete_domain_owner(name):
|
||||||
|
"""删除域名所有者模板"""
|
||||||
|
try:
|
||||||
|
if not name:
|
||||||
|
return {"status": "Error", "message": "域名所有者名称不能为空"}
|
||||||
|
|
||||||
|
# 获取指定的域名所有者
|
||||||
|
domain_owner = jingrow.get_pg("Domain Owner", name)
|
||||||
|
if not domain_owner:
|
||||||
|
return {"status": "Error", "message": "未找到指定的域名所有者"}
|
||||||
|
|
||||||
|
# 检查权限(只能删除当前团队的所有者)
|
||||||
|
team = get_current_team()
|
||||||
|
if not team:
|
||||||
|
return {"status": "Error", "message": "未找到当前团队"}
|
||||||
|
|
||||||
|
if domain_owner.team != team:
|
||||||
|
return {"status": "Error", "message": "无权删除该域名所有者信息"}
|
||||||
|
|
||||||
|
# 检查是否有 c_sysid(西部数码模板标识)
|
||||||
|
c_sysid = getattr(domain_owner, 'c_sysid', None)
|
||||||
|
if not c_sysid:
|
||||||
|
return {"status": "Error", "message": "域名所有者没有模板标识,无法删除"}
|
||||||
|
|
||||||
|
# 先删除西部数码的模板
|
||||||
|
try:
|
||||||
|
client = get_west_client()
|
||||||
|
if not client:
|
||||||
|
return {"status": "Error", "message": "API客户端初始化失败"}
|
||||||
|
|
||||||
|
# 调用西部数码删除模板接口
|
||||||
|
west_result = client.delete_contact_template(c_sysid)
|
||||||
|
|
||||||
|
if west_result.get('result') != 200:
|
||||||
|
error_msg = west_result.get('msg', west_result.get('message', '西部数码模板删除失败'))
|
||||||
|
return {"status": "Error", "message": f"西部数码模板删除失败: {error_msg}"}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return {"status": "Error", "message": f"西部数码模板删除失败: {str(e)}"}
|
||||||
|
|
||||||
|
# 西部数码模板删除成功后,删除本地记录
|
||||||
|
try:
|
||||||
|
domain_owner.delete(ignore_permissions=True)
|
||||||
|
return {"status": "Success", "message": "域名所有者模板删除成功"}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return {"status": "Error", "message": f"本地记录删除失败: {str(e)}"}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return {"status": "Error", "message": f"删除失败: {str(e)}"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user