<?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([], [
            'username' => $this->request->get('username/s', ''),
            'nickname' => $this->request->get('nickname/s', ''),
            'loginType' => $this->request->get('loginType/d', 0),
            'createTime' => [
                $this->request->get('createTimeStart/s', ''),
                $this->request->get('createTimeEnd/s', '')
            ],
        ]);

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

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