views/rental/nodeDetail 租赁地址,添加可以删除待验证的地址功能

This commit is contained in:
lu7213 committed 2026-10-30 19:32:11 -04:00
1 parent dafa5261bd
commit 624110e43c
4 files changed
+76

No files matched your search

@@ -184,6 +184,14 @@ public class RentalController {
return AjaxResult.success();
}
/** 删除本人尚未完成所有权验证的待审核地址。 */
@DeleteMapping("/wallet/{id}")
@PreAuthorize("@ss.hasPermi('rent:wallet:bind')")
public AjaxResult removeWallet(@PathVariable long id) {
provisioning.deletePendingWallet(id, user());
return AjaxResult.success();
}
@PostMapping("/wallet/{id}/challenge")
@PreAuthorize("@ss.hasPermi('rent:wallet:bind')")
public AjaxResult challenge(@PathVariable long id) {
@@ -120,6 +120,12 @@ public class RentalIdentity {
require("APP".equals(type) || "NODE".equals(type), "凭证主体非法");
Map<String, Object> row = store.get(type.toLowerCase(Locale.ROOT), owner, true);
require(number(row, "user_id") == actor, "无主体权限");
if ("NODE".equals(type)) {
// 与 Agent 建连共用节点行锁:检查必须在旧凭证降级之前完成,
// 防止过期页面或其他签发入口轮换在线节点的凭证,造成 Agent 认证中断。
require(!Arrays.asList("ONLINE", "SYNCING").contains(text(row, "connection_status")),
"节点在线或正在恢复连接,禁止重新签发凭证,请先停止Agent并确认节点离线");
}
String secret = RentalCrypto.random();
String encrypted = crypto.encrypt(secret);
String key = id("RK");
@@ -157,6 +157,24 @@ public class RentalProvisioning {
return wallet;
}
/**
* 仅清理误添加的待验证地址,不删除已验证或已产生业务关联的钱包。
* 与所有权验证共用钱包行锁,保证验证与删除不能同时成功;审计独立保留。
*/
@Transactional(rollbackFor = Exception.class)
public void deletePendingWallet(long id, long actor) {
Map<String, Object> wallet = ownedWallet(id, actor, true);
require(wallet.get("ownership_verified_at") == null && "PENDING".equals(text(wallet, "status")),
"仅允许删除待验证的租赁地址");
require(store.one("SELECT id FROM rent_order WHERE wallet_id=? LIMIT 1 FOR UPDATE", id) == null,
"地址存在关联订单,不能删除");
require(store.one("SELECT id FROM rent_task WHERE wallet_id=? LIMIT 1 FOR UPDATE", id) == null,
"地址存在关联任务,不能删除");
require(store.execute("DELETE FROM rent_wallet WHERE id=? AND status='PENDING' AND ownership_verified_at IS NULL", id) == 1,
"地址状态已变化,请刷新后重试");
store.event("WALLET", id, "DELETE", actor, "删除待验证且无业务关联的租赁地址");
}
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> challenge(long id, long actor) {
Map<String, Object> wallet = ownedWallet(id, actor, true);