数据安全管理,数据回收规则不能关联多表
求助
数据安全
数据回收

数据安全管理,数据回收规则不能关联多表
例如:CMS中内容和标题是多表关联的,这里只能监控一张表到回收站,然后还原的时候也就没有办法还原完整信息了

请问这块有其他的解决办法吗?

已采纳
妙码生花
妙码生花
这家伙很懒,什么也没写~
11月前

感谢反馈,恢复与还原有特殊情况的,目前只能手动调整,或许未来会有对应的更加人性化的方案,手动调整代码文件位置:

涂小色
涂小色回复妙码生花
这家伙很懒,什么也没写~
11月前

谈到这里,我想讨论一下,为啥不用全局软删除的方案?优缺点是啥

leigevip
leigevip回复妙码生花
这家伙很懒,什么也没写~
11月前

为啥回收站不直接放在每个列表里呢,维护更方便。还有导入导出直接在列表里增加按钮更方便吧,现在还要单独出来一个栏目导入导出。

涂小色
涂小色回复leigevip
这家伙很懒,什么也没写~
11月前

我就是导出那建一个模板,然后列表加按钮请求导出的。
app/admin/library/traits/Backend.php添加方法

/**
     * 通用导出方法
     * @return void
     * @throws Throwable
     */
    public function downloadStart(): void
    {
        $identifying = $this->request->param('identifying');
        if (empty($identifying)) {
            $this->error('导出标识为空');
        }
        $model = new Dataexport();
        $row = $model->where('identifying', $identifying)->find();
        if (empty($row)) {
            $this->error('未找到导出配置:' . $identifying);
        }
        list($where, $alias, $limit, $order) = $this->queryBuilder();
        $whereField = [];
        $mainAlias = parse_name(basename(str_replace('\\', '/', get_class($this->model))));
        foreach ($where as $item) {
            $whereField[] = [
                'field' => str_replace($mainAlias . '.', '', $item[0]),
                'operator' => $item[1],
                'value' => $item[2],
            ];
        }
        $orderField = [];
        foreach ($order as $key => $val) {
            if (!str_contains($key, '.')) {
                $key = $row->main_table . '.' . $key;
            }
            $orderField[] = [
                'field' => $key,
                'value' => $val,
            ];
        }
        $row->where_field = !empty($whereField) ? $whereField : null;
        $row->order_field = !empty($orderField) ? $orderField : null;
        $dict = [];
        foreach ($this->dictField as $field) {
            $dict = array_merge($dict, get_sys_config('', $field));
        }
        $field_config = $row->field_config;
        foreach ($field_config as &$field) {
            $fieldName = str_contains($field['name'], '.') ? explode($field['name'], '.')[1] : $field['name'];
            if ($field['discern'] == 'valuation' && !empty($dict[$fieldName])) {
                $comment = [];
                foreach ($dict[$fieldName] as $key => $value) {
                    $comment[] = $key . '=' . $value;
                }
                $field['comment'] = implode(',', $comment);
            }
        }
        $row->field_config = $field_config;
        if ($row->save()) {
            $this->request->setRoute(['id' => $row->id]);
            $dataexport = new \app\admin\controller\routine\Dataexport($this->app);
            $dataexport->start();
        } else {
            $this->error('查询失败');
        }
    }

不足之处,自行调整

websky
websky回复涂小色
这家伙很懒,什么也没写~
11月前

一直用软删除,没有发现明显缺点,BuildAdmin的这种删除方案思路也很好,另一种方案。连表删除也是可以优化的。

YANG001
YANG001回复涂小色
这家伙很懒,什么也没写~
11月前

全局的优点就是统一管理了,就像本贴小伙伴们说的实现的方案不少,其实另外也提供了表格内导出的示例模块

0个回答默认排序 投票数排序
没有更多回答了~
请先登录
0
1
0
6