liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
 
namespace app\openapi\model\access;
 
use app\common\model\admin\RoleAccess as RoleAccessModel;
class Access extends RoleAccessModel
{
 
    /**
     * 新增记录
     */
    public function add($data)
    {
        $this->startTrans();
        try {
 
            $model = new RoleAccessModel();
            $model->saveAll($data);
 
            $this->commit();
            return true;
        } catch (\Exception $e) {
            $this->error = $e->getMessage();
            $this->rollback();
            return false;
        }
    }
 
    /**
     * 修改记录
     */
    public function edit($data)
    {
        $this->startTrans();
        try {
 
            $access_model = new RoleAccessModel();
            $access_model->where(['role_id' => $data[0]['role_id']])->delete();
            $access_model->saveAll($data);
 
            $this->commit();
            return true;
        } catch (\Exception $e) {
            $this->error = $e->getMessage();
            $this->rollback();
            return false;
        }
    }
 
 
 
}