Commit 20846c18 authored by huanle's avatar huanle

0525 15:00

parent 48e78d4b
......@@ -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)) {
......@@ -95,71 +95,74 @@ class Index extends Controller
{
$folderid = input('post.folderid');
$model = new Doclist();
$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['folderid']) || empty($post['folderid']) ) {
if (!isset($folderid) || empty($folderid)) {
return json(code([], 10001, 'folderid为空'));
}
if ( !isset($post['origin']) || empty($post['origin']) ) {
$post['origin'] = 0 ;
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['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']);
$result = $model->articleList($folderid, $post['origin'], $post['pagenum']);
//var_dump($result);
if($result){
if ($result) {
return json(code([$result], 0, '请求成功'));
}else{
} else {
return json(code([$result], 0, '暂无数据'));
}
}
public function articleDetail(){
public function articleDetail()
{
$docid = input('post.docid');
$model = new Doclist();
$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) {
......@@ -169,23 +172,25 @@ 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()
{
......
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