Commit 1c7f4818 authored by huanle's avatar huanle

0525-11:26

parent 1b5fc47f
...@@ -54,7 +54,7 @@ class Index extends Controller ...@@ -54,7 +54,7 @@ class Index extends Controller
$folderid = input('post.folderid'); $folderid = input('post.folderid');
$model = new Folder(); $model = new Folder();
if (empty($folderid)) { if ( empty($folderid)) {
return json(code([], 10001, '参数不足')); return json(code([], 10001, '参数不足'));
} }
if (empty($name)) { if (empty($name)) {
...@@ -94,77 +94,72 @@ class Index extends Controller ...@@ -94,77 +94,72 @@ class Index extends Controller
public function articleList() public function articleList()
{ {
$folderid = input('post.folderid'); $folderid = input('post.folderid');
//
// $model = new Doclist(); $model = new Doclist();
// if(empty($folderid)){
// return json(code([],10001,'没有folderid'));
// }else{
// $res = $model->ArticleList($folderid);
//
// }
$model = new Doclist();
$folderid = input('post.folderid'); $folderid = input('post.folderid');
$post['origin'] = input('request.origin'); $post['origin'] = input('request.origin');
$post['pagenum'] = input('request.pagenum'); $post['pagenum'] = input('request.pagenum');
$post['current'] = input('request.current'); $post['current'] = input('request.current');
if (!isset($post['origin']) || empty($post['origin'])) { if ( !isset($post['folderid']) || empty($post['folderid']) ) {
$post['origin'] = 0; return json(code([], 10001, 'folderid为空'));
}
if ( !isset($post['origin']) || empty($post['origin']) ) {
$post['origin'] = 0 ;
} }
//每页显示多少条数据 //每页显示多少条数据
if (!isset($post['pagenum']) || empty($post['pagenum'])) { if ( !isset($post['pagenum']) || empty($post['pagenum']) ) {
$post['pagenum'] = 20; $post['pagenum'] = 20 ;
} }
//当前页 //当前页
if (isset($post['current']) && !empty($post['current']) && $post['current'] >= 1) { if ( isset($post['current']) && !empty($post['current']) && $post['current']>=1 ) {
$data['current'] = ceil($post['current']); $data['current'] = ceil($post['current']);
if (($data['current'] - 1) >= 1) { if (($data['current']-1)>=1){
$post['origin'] = ($post['current'] - 1) * $post['pagenum']; $post['origin'] = ($post['current']-1) * $post['pagenum'];
} }
} else { }else{
$data['current'] = $post['origin'] / $post['pagenum']; $data['current'] = $post['origin'] / $post['pagenum'];
} }
$data['pagenum'] = $post['pagenum']; $data['pagenum'] = $post['pagenum'];
if ($data['current'] <= 1) { if ($data['current']<=1) {
$data['current'] = 1; $data['current'] = 1;
} }
$result = $model->articleList($folderid, $post['origin'], $post['pagenum']); $result = $model->articleList($folderid,$post['origin'],$post['pagenum']);
if ($result) { //var_dump($result);
if($result){
return json(code([$result], 0, '请求成功')); return json(code([$result], 0, '请求成功'));
} else { }else{
return json(code([], 10002, '没有数据了')); return json(code([$result], 0, '暂无数据'));
} }
} }
public function articleDetail(){
public function articleDetail()
{
$docid = input('post.docid'); $docid = input('post.docid');
$model = new Doclist(); $model = new Doclist();
$detail = $model->articleDetail($docid); $detail = $model->articleDetail($docid);
if ($detail) { if($detail){
return json(code([$detail], 0, '请求成功')); return json(code([$detail], 0, '请求成功'));
} else { }else{
return json(code([], 10002, '请求失败')); return json(code([], 10002, '请求失败'));
} }
} }
public function articleAdd() public function articleAdd()
{ {
$title = input('post.title'); $title = input('post.title');
$folderid = input('post.folderid'); $folderid = input('post.folderid');
$type = (int)input('post.type'); $type=(int)input('post.type');
$doc = input('post.doc'); $doc =input('post.doc');
$model = new Doclist(); $model = new Doclist();
if (empty($type)) { if(empty($type)){
return json(code([], 10001, '类型不能为空')); return json(code([], 10001, '类型不能为空'));
} }
if (empty($title)) { if (empty($title)) {
return json(code([], 10001, '标题不能为空')); return json(code([], 10001, '标题不能为空'));
} else { } else {
$res = $model->addArticle($title, $folderid, $type, $doc); $res = $model->addArticle($title, $folderid,$type,$doc);
if ($res) { if ($res) {
...@@ -174,25 +169,23 @@ class Index extends Controller ...@@ -174,25 +169,23 @@ class Index extends Controller
} }
} }
} }
public function articleEdit() public function articleEdit()
{ {
$title = input('post.title'); $title = input('post.title');
$folderid = input('post.folderid'); $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($folderid) || empty($title)||empty($doc)||empty($docid)) {
return json(code([], 10001, '参数不足')); return json(code([], 10001, '参数不足'));
} }
$res = $model->editArticle($title, $folderid, $doc, $docid); $res = $model->editArticle($title, $folderid, $doc,$docid);
if ($res) { if ($res) {
return json(code([], 0, '修改成功')); return json(code([], 0, '修改成功'));
} else { } else {
return json(code([], 10002, '修改失败')); return json(code([], 10002, '修改失败'));
} }
} }
public function articleDel() public function articleDel()
{ {
......
...@@ -19,11 +19,17 @@ class Doclist extends Model ...@@ -19,11 +19,17 @@ class Doclist extends Model
public function articleList($folderid,$origin,$pagenum) public function articleList($folderid,$origin,$pagenum)
{ {
$where = ['folderid' => $folderid]; if($folderid){
$articlelist = Db::name('doclist')->field('docid,title,type,updatetime')->where($where)->order('createtime')->limit($origin,$pagenum)->select(); $where['folderid'] = array('=',$folderid);
// $sql = Db::name('doclist')->getLastSql(); $where['state'] = array('=',0);
// var_dump($sql); $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=[];
}
return $articlelist; return $articlelist;
} }
......
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