where(array('id' => $param_id))->find(); if ($login_user['nickname'] == '') { $login_user['nickname'] = $login_user['name']; } if ($login_user['nickname'] == '') { $login_user['nickname'] = $login_user['username']; } } else { $login_user = get_login_user(); if (empty($login_user)) { $login_user = []; $login_user['id'] = 0; $login_user['nickname'] = '游客'; } else { if ($login_user['nickname'] == '') { $login_user['nickname'] = $login_user['username']; } } } $content = $login_user['nickname'] . '在' . date('Y-m-d H:i:s') . '执行了' . $title . '操作'; if ($param_str != '') { $content = $login_user['nickname'] . '在' . date('Y-m-d H:i:s') . $title . '了' . $param_str; } $data = []; $data['uid'] = $login_user['id']; $data['nickname'] = $login_user['nickname']; $data['type'] = $type; $data['title'] = $title; $data['content'] = $content; $data['param_id'] = $param_id; $data['param'] = json_encode($param); $data['module'] = \think\facade\App::initialize()->http->getName(); $data['controller'] = app('request')->controller(); $data['function'] = app('request')->action(); $data['ip'] = $request->ip(); $data['create_time'] = time(); \think\facade\Db::name('user_log')->strict(false)->field(true)->insert($data); } //读取导航列表,用于前台 function get_navs($name) { if (!get_cache('homeNav' . $name)) { $nav_id = \think\facade\Db::name('Nav')->where(['name' => $name, 'status' => 1])->value('id'); if (empty($nav_id)) { return ''; } $list = \think\facade\Db::name('NavInfo')->where(['nav_id' => $nav_id, 'status' => 1])->order('sort asc')->select(); \think\facade\Cache::tag('homeNav')->set('homeNav' . $name, $list); } $navs = get_cache('homeNav' . $name); return $navs; } //读取指定文章的详情 function get_article_detail($id) { $article = \think\facade\Db::name('article')->where(['id' => $id])->find(); if (empty($article)) { return $this->error('文章不存在'); } $keywrod_array = \think\facade\Db::name('ArticleKeywords') ->field('i.aid,i.keywords_id,k.title') ->alias('i') ->join('keywords k', 'k.id = i.keywords_id', 'LEFT') ->order('i.create_time asc') ->where(array('i.aid' => $id, 'k.status' => 1)) ->select()->toArray(); $article['keyword_ids'] = implode(",", array_column($keywrod_array, 'keywords_id')); $article['keyword_names'] = implode(',', array_column($keywrod_array, 'title')); return $article; }