<?php
namespace backendApi\modules\v1\models\exportForms;

use common\libs\export\module\LogExport;
use yii\base\Exception;

class LogExportForm extends BaseExportForm
{
    /**
     * 导出
     * @param $filter
     * @param $listName
     * @param null $consoleRouter
     * @return bool
     * @throws \yii\db\Exception
     */
    public function run($filter, $listName, $consoleRouter = null){
        $this->exportObj = LogExport::instance();
        return $this->export($filter, $listName, $consoleRouter);
    }

    /**
     * 导出
     * @param $filter
     * @param $listName
     * @param null $consoleRouter
     * 不传值默认导出controller、action和console里面的controller、action一致
     * @return bool
     * @throws \yii\db\Exception
     */
    public function export($filter, $listName, $consoleRouter = null){
        try {
            $this->exportObj->exportHandle($filter, $listName, $consoleRouter);
            return true;
        } catch (Exception $e) {
            $this->addError('export', $e->getMessage());
            return false;
        }
    }


}
