<?php

namespace app\controller\admin\system;

use app\BaseController;
use app\entity\SysFileRecord;
use app\service\CurdService;
use think\db\exception\DbException;
use think\response\Json;

class FileController extends BaseController
{
    /**
     * 分页查询账号登录记录
     * @return Json
     * @throws DbException
     */
    public function page(): Json
    {
        $model = SysFileRecord::with(['createUser'])->withSearch(['name','path','createNickname'], [
            'name'=> $this->request->param('name/s',''),
            'path'=> $this->request->param('path/s',''),
            'createNickname'=> $this->request->param('createNickname/s',''),
            'createTime' => [
                $this->request->get('createTimeStart/s', ''),
                $this->request->get('createTimeEnd/s', '')
            ],
        ]);

        $paginate = CurdService::getPaginate($this->request, $model);

        return $this->writeSuccess('ok', $paginate);
    }

    public function batchRemove()
    {
        $data = $this->request->delete();
        SysFileRecord::destroy($data);
        return $this->writeSuccess('删除成功');
    }

    public function upload()
    {
        $file = $this->request->file('file');

    }
}