Commit 1c7f4818 authored by huanle's avatar huanle

0525-11:26

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