feat(admin): full integration of order, product, and finance modules with real RPC data streams
This commit is contained in:
20
docs/sql/20_rls/finance/ml_extract_rls_v1.sql
Normal file
20
docs/sql/20_rls/finance/ml_extract_rls_v1.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- =====================================================================================
|
||||
-- RLS: 用户提现申请表
|
||||
-- 位置:docs/sql/20_rls/finance/
|
||||
-- 对象类型:RLS 策略
|
||||
-- 版本:v1
|
||||
-- 说明:仅允许用户查看自己的提现记录;管理端通过 RPC 访问
|
||||
-- =====================================================================================
|
||||
|
||||
ALTER TABLE public.ml_extract ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- 策略 1: 允许用户读取自己的提现申请
|
||||
DROP POLICY IF EXISTS ml_extract_user_select ON public.ml_extract;
|
||||
CREATE POLICY ml_extract_user_select
|
||||
ON public.ml_extract
|
||||
FOR SELECT
|
||||
TO authenticated
|
||||
USING (uid = auth.uid());
|
||||
|
||||
-- 默认不开放 INSERT/UPDATE/DELETE 给普通用户
|
||||
-- 提现申请通常由特定的 RPC 函数 (security definer) 创建,以确保业务逻辑(如冻结余额)的原子性
|
||||
19
docs/sql/20_rls/finance/ml_invoices_rls_v1.sql
Normal file
19
docs/sql/20_rls/finance/ml_invoices_rls_v1.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- =====================================================================================
|
||||
-- RLS: 发票管理表
|
||||
-- 位置:docs/sql/20_rls/finance/ml_invoices_rls_v1.sql
|
||||
-- 对象类型:RLS 策略
|
||||
-- 版本:v1
|
||||
-- 说明:用户仅能查看自己的开票申请;管理端通过 RPC 访问
|
||||
-- =====================================================================================
|
||||
|
||||
ALTER TABLE public.ml_invoices ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- 策略 1: 允许用户读取自己的记录
|
||||
DROP POLICY IF EXISTS ml_invoices_user_select ON public.ml_invoices;
|
||||
CREATE POLICY ml_invoices_user_select
|
||||
ON public.ml_invoices
|
||||
FOR SELECT
|
||||
TO authenticated
|
||||
USING (uid = auth.uid());
|
||||
|
||||
-- 默认不开放 INSERT/UPDATE/DELETE 给普通用户,通常由 RPC 或支付后逻辑触发
|
||||
19
docs/sql/20_rls/finance/ml_user_bill_rls_v1.sql
Normal file
19
docs/sql/20_rls/finance/ml_user_bill_rls_v1.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- =====================================================================================
|
||||
-- RLS: 用户资金流水表
|
||||
-- 位置:docs/sql/20_rls/finance/
|
||||
-- 对象类型:RLS 策略
|
||||
-- 版本:v1
|
||||
-- 说明:仅允许用户查看自己的流水记录;管理端通过 RPC 访问
|
||||
-- =====================================================================================
|
||||
|
||||
ALTER TABLE public.ml_user_bill ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- 策略 1: 允许用户读取自己的记录
|
||||
DROP POLICY IF EXISTS ml_user_bill_user_select ON public.ml_user_bill;
|
||||
CREATE POLICY ml_user_bill_user_select
|
||||
ON public.ml_user_bill
|
||||
FOR SELECT
|
||||
TO authenticated
|
||||
USING (uid = auth.uid());
|
||||
|
||||
-- 默认不开放 INSERT/UPDATE/DELETE 给普通用户,由后端逻辑或 RPC 触发
|
||||
19
docs/sql/20_rls/finance/ml_user_recharge_rls_v1.sql
Normal file
19
docs/sql/20_rls/finance/ml_user_recharge_rls_v1.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- =====================================================================================
|
||||
-- RLS: 用户充值记录表
|
||||
-- 位置:docs/sql/20_rls/finance/
|
||||
-- 对象类型:RLS 策略
|
||||
-- 版本:v1
|
||||
-- 说明:仅允许用户查看自己的充值记录;管理端通过 RPC 访问
|
||||
-- =====================================================================================
|
||||
|
||||
ALTER TABLE public.ml_user_recharge ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- 策略 1: 允许用户读取自己的记录
|
||||
DROP POLICY IF EXISTS ml_user_recharge_user_select ON public.ml_user_recharge;
|
||||
CREATE POLICY ml_user_recharge_user_select
|
||||
ON public.ml_user_recharge
|
||||
FOR SELECT
|
||||
TO authenticated
|
||||
USING (uid = auth.uid());
|
||||
|
||||
-- 默认不开放 INSERT/UPDATE/DELETE 给普通用户,写操作通常由业务逻辑或支付回调触发
|
||||
Reference in New Issue
Block a user