uhome and artedit

This commit is contained in:
zhao 2020-03-15 22:19:10 +08:00
parent e6ee8dff79
commit d079f03887
5 changed files with 8 additions and 9 deletions

View File

@ -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);
}

View File

@ -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']);

View File

@ -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();

View File

@ -1,5 +1,4 @@
{extend name="public/base" /}
{block name="title"}发表帖子{/block}
{block name="column"}{/block}
{block name="content"}

View File

@ -31,7 +31,7 @@
<label for="L_title" class="layui-form-label">标题</label>
<div class="layui-input-block">
<input type="text" id="L_title" name="title" required lay-verify="required" autocomplete="off" class="layui-input" value="{$article.title}">
<input type="hidden" name="user_id" value="{:session('user_id')}">
<input type="hidden" name="user_id" value="{$article.user_id}">
</div>
</div>
</div>