diff --git a/app/common/controller/BaseController.php b/app/common/controller/BaseController.php index 96bf726..0464381 100644 --- a/app/common/controller/BaseController.php +++ b/app/common/controller/BaseController.php @@ -237,7 +237,7 @@ abstract class BaseController protected function showUser() { //1.查询用户 - $user = Db::name('user')->field('id,name,nickname,user_img,sex,auth,city,email,sign,point')->where('id',Session::get('user_id'))->cache(true)->find(); + $user = Db::name('user')->field('id,name,nickname,user_img,sex,auth,city,email,sign,point')->where('id',Session::get('user_id'))->cache(600)->find(); //2.将User变量赋给模板 公共模板nav.html View::assign('user',$user); } diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index 8a60322..82d69f7 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -172,7 +172,7 @@ class Article extends BaseController if(true !==$result){ return $this->error($validate->getError()); } else { - $article = new \app\common\model\Article(); + $article = new \app\common\model\Article; $result = $article->add($data); if($result == 1) { $aid = Db::name('article')->max('id'); @@ -212,8 +212,8 @@ class Article extends BaseController if(true !==$res){ return $this->error($validate->getError()); - } else { - $article = new \app\common\model\Article(); + } else { + $article = new \app\common\model\Article; $result = $article->edit($data); if($result == 1) { return json(['code'=>1,'msg'=>'修改成功','url'=>'/'.app('http')->getName().'/jie/'.$id.'.html']); diff --git a/app/index/controller/User.php b/app/index/controller/User.php index ba7e971..f547bb0 100644 --- a/app/index/controller/User.php +++ b/app/index/controller/User.php @@ -134,11 +134,11 @@ class User extends BaseController public function home($id) { //用户 - $u = Db::name('user')->field('name,nickname,city,sex,sign,user_img,point,create_time')->cache(true)->find($id); + $u = Db::name('user')->field('name,nickname,city,sex,sign,user_img,point,create_time')->cache(3600)->find($id); //用户发贴 - $arts = Db::name('user')->alias('u')->join('article a','u.id = a.user_id')->field('u.id,a.id,a.title,a.pv,a.is_hot,a.create_time,a.delete_time')->where('a.delete_time',0)->where('a.user_id',$id)->cache(true)->select(); + $arts = Db::name('user')->alias('u')->join('article a','u.id = a.user_id')->field('u.id,a.id,a.title,a.pv,a.is_hot,a.create_time,a.delete_time')->where('a.delete_time',0)->where('a.user_id',$id)->order(['a.create_time'=>'desc'])->cache(3600)->select(); //用户回答 - $reys = Db::name('comment')->alias('c')->join('article a','c.article_id = a.id')->field('a.id,a.title,c.content,c.create_time,c.delete_time')->where(['a.delete_time'=>0,'c.delete_time'=>0])->where('c.user_id',$id)->cache(true)->select(); + $reys = Db::name('comment')->alias('c')->join('article a','c.article_id = a.id')->field('a.id,a.title,c.content,c.create_time,c.delete_time')->where(['a.delete_time'=>0,'c.delete_time'=>0])->where('c.user_id',$id)->order(['c.create_time'=>'desc'])->cache(3600)->select(); View::assign(['u'=>$u,'arts'=>$arts,'reys'=>$reys]); return View::fetch(); diff --git a/view/index/article/add.html b/view/index/article/add.html index 0334126..2f9347a 100644 --- a/view/index/article/add.html +++ b/view/index/article/add.html @@ -1,5 +1,4 @@ {extend name="public/base" /} - {block name="title"}发表帖子{/block} {block name="column"}{/block} {block name="content"} diff --git a/view/index/article/edit.html b/view/index/article/edit.html index 91f78e1..6674682 100644 --- a/view/index/article/edit.html +++ b/view/index/article/edit.html @@ -31,7 +31,7 @@
- +