Commit e92e2603 authored by huanle's avatar huanle

0529 edit

parent 28d92cc0
...@@ -168,6 +168,7 @@ class Index extends Controller ...@@ -168,6 +168,7 @@ class Index extends Controller
return json(code([], 10002, '请求失败')); return json(code([], 10002, '请求失败'));
} }
} }
public function articleAdd() public function articleAdd()
{ {
$title = input('post.title'); $title = input('post.title');
...@@ -196,14 +197,13 @@ class Index extends Controller ...@@ -196,14 +197,13 @@ class Index extends Controller
public function articleEdit() public function articleEdit()
{ {
$title = input('post.title'); $title = input('post.title');
$folderid = input('post.folderid');
$doc = input('post.doc'); $doc = input('post.doc');
$docid = input('post.docid'); $docid = input('post.docid');
$model = new Doclist(); $model = new Doclist();
if (empty($folderid) || empty($title) || empty($doc) || empty($docid)) { if ( empty($title) || empty($docid)) {
return json(code([], 10001, '参数不足')); return json(code([], 10001, '参数不足'));
} }
$res = $model->editArticle($title, $folderid, $doc, $docid); $res = $model->editArticle($title, $doc, $docid);
if ($res) { if ($res) {
return json(code([], 0, '修改成功')); return json(code([], 0, '修改成功'));
} else { } else {
......
...@@ -16,19 +16,19 @@ class Doclist extends Model ...@@ -16,19 +16,19 @@ class Doclist extends Model
} }
//获取文件夹名称 //获取文件夹名称
public function articleList($folderid,$origin,$pagenum) public function articleList($folderid, $origin, $pagenum)
{ {
// var_dump($folderid); // var_dump($folderid);
if($folderid){ if ($folderid) {
$where['folderid'] = array('=',$folderid); $where['folderid'] = array('=', $folderid);
$where['state'] = array('=',0); $where['state'] = array('=', 0);
$articlelist = Db::name('doclist')->field('docid,title,type,updatetime')->where($where)->order('createtime')->limit($origin,$pagenum)->select(); $articlelist = Db::name('doclist')->field('docid,title,type,updatetime')->where($where)->order('createtime')->limit($origin, $pagenum)->select();
// $sql = Db::name('doclist')->getLastSql(); // $sql = Db::name('doclist')->getLastSql();
// var_dump($sql); // var_dump($sql);
}else{ } else {
$articlelist=[]; $articlelist = [];
} }
return $articlelist; return $articlelist;
...@@ -37,13 +37,14 @@ class Doclist extends Model ...@@ -37,13 +37,14 @@ class Doclist extends Model
public function articleDetail($docid) public function articleDetail($docid)
{ {
if($docid){ if ($docid) {
$where = ['docid' => $docid]; $where = ['docid' => $docid];
$articldetail = Db::name('doclist')->field('docid,title,type,updatetime,doc')->where($where)->find(); $articldetail = Db::name('doclist')->field('docid,title,type,updatetime,doc')->where($where)->find();
return $articldetail; return $articldetail;
} }
} }
public function addArticle($title, $folderid,$type,$doc)
public function addArticle($title, $folderid, $type, $doc)
{ {
$docid = randomkeys(18); $docid = randomkeys(18);
...@@ -54,8 +55,8 @@ class Doclist extends Model ...@@ -54,8 +55,8 @@ class Doclist extends Model
$rs = new Doclist(); $rs = new Doclist();
if ($docname == 0) { if ($docname == 0) {
$data = [ $data = [
'docid' =>$docid, 'docid' => $docid,
'title' => $title , 'title' => $title,
'type' => $type, 'type' => $type,
'doc' => $doc, 'doc' => $doc,
'folderid' => $folderid, 'folderid' => $folderid,
...@@ -71,21 +72,21 @@ class Doclist extends Model ...@@ -71,21 +72,21 @@ class Doclist extends Model
} }
public function editArticle($title, $folderid,$doc,$docid)
public function editArticle($title, $doc, $docid)
{ {
$rs = new Doclist(); $rs = new Doclist();
$where = []; $where = [];
$docname = Db::name('doclist')->where(['docid' => $docid])->count();
if($docname>0){
$data = [ $data = [
'title' => $title, 'title' => $title,
'doc' =>$doc, 'doc' => $doc,
'updatetime' => date("Y-m-d H:i:s", time()), 'updatetime' => date("Y-m-d H:i:s", time()),
]; ];
if ($docid) { if ($docid) {
$where['docid'] = array('=',$docid); $where['docid'] = array('=', $docid);
} }
$rs = $this->where($where)->update($data); $rs = $this->where($where)->update($data);
...@@ -95,12 +96,9 @@ class Doclist extends Model ...@@ -95,12 +96,9 @@ class Doclist extends Model
} else { } else {
return true; return true;
} }
}else{
return false;
}
// var_dump($rs);die();
// $sql = Db::name('folder')->getLastSql();
// var_dump($sql);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment