Commit e92e2603 authored by huanle's avatar huanle

0529 edit

parent 28d92cc0
......@@ -168,6 +168,7 @@ class Index extends Controller
return json(code([], 10002, '请求失败'));
}
}
public function articleAdd()
{
$title = input('post.title');
......@@ -196,14 +197,13 @@ class Index extends Controller
public function articleEdit()
{
$title = input('post.title');
$folderid = input('post.folderid');
$doc = input('post.doc');
$docid = input('post.docid');
$model = new Doclist();
if (empty($folderid) || empty($title) || empty($doc) || empty($docid)) {
if ( empty($title) || empty($docid)) {
return json(code([], 10001, '参数不足'));
}
$res = $model->editArticle($title, $folderid, $doc, $docid);
$res = $model->editArticle($title, $doc, $docid);
if ($res) {
return json(code([], 0, '修改成功'));
} else {
......
......@@ -16,20 +16,20 @@ class Doclist extends Model
}
//获取文件夹名称
public function articleList($folderid,$origin,$pagenum)
public function articleList($folderid, $origin, $pagenum)
{
// var_dump($folderid);
if($folderid){
$where['folderid'] = array('=',$folderid);
$where['state'] = array('=',0);
$articlelist = Db::name('doclist')->field('docid,title,type,updatetime')->where($where)->order('createtime')->limit($origin,$pagenum)->select();
if ($folderid) {
$where['folderid'] = array('=', $folderid);
$where['state'] = array('=', 0);
$articlelist = Db::name('doclist')->field('docid,title,type,updatetime')->where($where)->order('createtime')->limit($origin, $pagenum)->select();
// $sql = Db::name('doclist')->getLastSql();
// var_dump($sql);
}else{
$articlelist=[];
}
} else {
$articlelist = [];
}
return $articlelist;
}
......@@ -37,13 +37,14 @@ class Doclist extends Model
public function articleDetail($docid)
{
if($docid){
$where = ['docid' => $docid];
$articldetail = Db::name('doclist')->field('docid,title,type,updatetime,doc')->where($where)->find();
return $articldetail;
}
if ($docid) {
$where = ['docid' => $docid];
$articldetail = Db::name('doclist')->field('docid,title,type,updatetime,doc')->where($where)->find();
return $articldetail;
}
}
public function addArticle($title, $folderid,$type,$doc)
public function addArticle($title, $folderid, $type, $doc)
{
$docid = randomkeys(18);
......@@ -54,12 +55,12 @@ class Doclist extends Model
$rs = new Doclist();
if ($docname == 0) {
$data = [
'docid' =>$docid,
'title' => $title ,
'docid' => $docid,
'title' => $title,
'type' => $type,
'doc' => $doc,
'folderid' => $folderid,
'createtime' => date("Y-m-d H:i:s", time())
'createtime' => date("Y-m-d H:i:s", time())
];
$rs->isUpdate(false)->save($data);
// $sql = Db::name('doclist')->getLastSql();
......@@ -71,23 +72,23 @@ class Doclist extends Model
}
public function editArticle($title, $folderid,$doc,$docid)
public function editArticle($title, $doc, $docid)
{
$rs = new Doclist();
$where = [];
$data = [
'title' => $title,
'doc' =>$doc,
'updatetime' => date("Y-m-d H:i:s", time()),
];
$docname = Db::name('doclist')->where(['docid' => $docid])->count();
if($docname>0){
$data = [
'title' => $title,
'doc' => $doc,
'updatetime' => date("Y-m-d H:i:s", time()),
if ($docid) {
$where['docid'] = array('=',$docid);
];
if ($docid) {
$where['docid'] = array('=', $docid);
}
}
$rs = $this->where($where)->update($data);
if ($rs === false) {
......@@ -95,12 +96,9 @@ class Doclist extends Model
} else {
return true;
}
// var_dump($rs);die();
// $sql = Db::name('folder')->getLastSql();
// var_dump($sql);
}else{
return false;
}
}
......
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