<?php

namespace app\controller\admin\system;

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

class OperateRecordController extends BaseController
{
    /**
     * 分页查询操作日志记录
     * @return Json
     * @throws DbException
     */
    public function page(): Json
    {
        $model = SysOperateRecord::withSearch(['createTime', 'contextId', 'location', 'operateUserId'], [
            'createTime' => [
                $this->request->get('createTimeStart/s', ''),
                $this->request->get('createTimeEnd/s', '')
            ],
            'contextId' => $this->request->get('contextId/s',''),
            'location'  => $this->request->get('location/s',''),
            'operateUserId' => $this->request->get('operateUserId/d',0),
        ]);

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

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