1818use  Casbin \Persist \FilteredAdapter ;
1919use  Casbin \Persist \Adapters \Filter ;
2020use  Casbin \Exceptions \InvalidFilterTypeException ;
21+ use  think \db \exception \DataNotFoundException ;
22+ use  think \db \exception \DbException ;
23+ use  think \db \exception \ModelNotFoundException ;
2124use  think \facade \Db ;
2225use  Casbin \WebmanPermission \Model \RuleModel ;
2326
@@ -80,7 +83,7 @@ public function filterRule(array $rule): array
8083     * 
8184     * @return void 
8285     */ 
83-     public  function  savePolicyLine ($ ptype , array  $ rule )
86+     public  function  savePolicyLine (string   $ ptype , array  $ rule ):  void 
8487    {
8588        $ col ['ptype ' ] = $ ptype ;
8689        foreach  ($ rule  as  $ key  => $ value ) {
@@ -93,6 +96,9 @@ public function savePolicyLine($ptype, array $rule)
9396     * loads all policy rules from the storage. 
9497     * 
9598     * @param Model $model 
99+      * @throws DataNotFoundException 
100+      * @throws DbException 
101+      * @throws ModelNotFoundException 
96102     */ 
97103    public  function  loadPolicy (Model   $ model ): void 
98104    {
@@ -168,7 +174,10 @@ public function addPolicies(string $sec, string $ptype, array $rules): void
168174     * 
169175     * @param string $sec 
170176     * @param string $ptype 
171-      * @param array  $rule 
177+      * @param array $rule 
178+      * @throws DataNotFoundException 
179+      * @throws DbException 
180+      * @throws ModelNotFoundException 
172181     */ 
173182    public  function  removePolicy (string  $ sec , string  $ ptype , array  $ rule ): void 
174183    {
@@ -205,12 +214,14 @@ public function removePolicies(string $sec, string $ptype, array $rules): void
205214    }
206215
207216    /** 
208-      * @param string       $sec 
209-      * @param string       $ptype 
210-      * @param int          $fieldIndex 
217+      * @param string $sec 
218+      * @param string $ptype 
219+      * @param int $fieldIndex 
211220     * @param string|null ...$fieldValues 
212221     * @return array 
213-      * @throws Throwable 
222+      * @throws DbException 
223+      * @throws ModelNotFoundException 
224+      * @throws DataNotFoundException 
214225     */ 
215226    public  function  _removeFilteredPolicy (string  $ sec , string  $ ptype , int  $ fieldIndex , ?string  ...$ fieldValues ): array 
216227    {
@@ -244,8 +255,11 @@ public function _removeFilteredPolicy(string $sec, string $ptype, int $fieldInde
244255     * 
245256     * @param string $sec 
246257     * @param string $ptype 
247-      * @param int     $fieldIndex 
258+      * @param int $fieldIndex 
248259     * @param string ...$fieldValues 
260+      * @throws DataNotFoundException 
261+      * @throws DbException 
262+      * @throws ModelNotFoundException 
249263     */ 
250264    public  function  removeFilteredPolicy (string  $ sec , string  $ ptype , int  $ fieldIndex , string  ...$ fieldValues ): void 
251265    {
@@ -260,6 +274,9 @@ public function removeFilteredPolicy(string $sec, string $ptype, int $fieldIndex
260274     * @param string $ptype 
261275     * @param string[] $oldRule 
262276     * @param string[] $newPolicy 
277+      * @throws DataNotFoundException 
278+      * @throws DbException 
279+      * @throws ModelNotFoundException 
263280     */ 
264281    public  function  updatePolicy (string  $ sec , string  $ ptype , array  $ oldRule , array  $ newPolicy ): void 
265282    {
@@ -342,6 +359,10 @@ public function setFiltered(bool $filtered): void
342359     * 
343360     * @param Model $model 
344361     * @param mixed $filter 
362+      * @throws InvalidFilterTypeException 
363+      * @throws DataNotFoundException 
364+      * @throws DbException 
365+      * @throws ModelNotFoundException 
345366     */ 
346367    public  function  loadFilteredPolicy (Model   $ model , $ filter ): void 
347368    {
@@ -351,7 +372,6 @@ public function loadFilteredPolicy(Model $model, $filter): void
351372            $ instance  = $ instance ->whereRaw ($ filter );
352373        } elseif  ($ filter  instanceof  Filter) {
353374            foreach  ($ filter ->p  as  $ k  => $ v ) {
354-                 $ where [$ v ] = $ filter ->g [$ k ];
355375                $ instance  = $ instance ->where ($ v , $ filter ->g [$ k ]);
356376            }
357377        } elseif  ($ filter  instanceof  \Closure) {
0 commit comments