添加ip白名单功能

This commit is contained in:
lu7213 committed 2026-11-16 10:30:21 -05:00
1 parent c12b777a42
commit 4d656ef63c
20 files changed
+436 -6

No files matched your search

@@ -121,7 +121,7 @@ public class RentalController {
@PreAuthorize("@ss.hasPermi('rent:portal:view')")
public AjaxResult appDetail(@PathVariable long id) {
Map<String, Object> app = store.one(
"SELECT id,name,status,notify_url,created_at,updated_at FROM rent_app WHERE id=? AND user_id=?",
"SELECT id,name,status,notify_url,ip_whitelist,created_at,updated_at FROM rent_app WHERE id=? AND user_id=?",
id, user());
require(app != null, "应用不存在或无权访问");
// DATETIME(3) 约定存服务器本地时间;统一输出毫秒,避免驱动返回 Timestamp/LocalDateTime 的差异。
@@ -143,6 +143,24 @@ public class RentalController {
return AjaxResult.success(map("app", app, "credentials", credentials));
}
/** 商户只能维护本人应用,白名单不是商户外部API,避免配置错误后无法修复。 */
@PostMapping("/app/{id}/ip-whitelist")
@PreAuthorize("@ss.hasPermi('rent:portal:register') or @ss.hasPermi('rent:app:create') or @ss.hasPermi('rent:app:edit')")
public AjaxResult updateAppIpWhitelist(@PathVariable long id, @RequestBody Map<String, Object> body) {
require(body.containsKey("ip_whitelist"), "缺少IP白名单配置");
provisioning.updateAppIpWhitelist(id, text(body, "ip_whitelist"), user());
return AjaxResult.success();
}
/** 运营配置入口与商户入口分离,不能通过提交应用ID越权。 */
@PostMapping("/manage/app/{id}/ip-whitelist")
@PreAuthorize("@ss.hasPermi('rent:manage:audit')")
public AjaxResult manageAppIpWhitelist(@PathVariable long id, @RequestBody Map<String, Object> body) {
require(body.containsKey("ip_whitelist"), "缺少IP白名单配置");
provisioning.updateAppIpWhitelist(id, text(body, "ip_whitelist"), null);
return AjaxResult.success();
}
/** 仅允许删除本人未产生业务关联的空应用。 */
@DeleteMapping("/app/{id}")
@PreAuthorize("@ss.hasPermi('rent:portal:register') or @ss.hasPermi('rent:app:remove')")