Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doc_phone
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangyipeng
doc_phone
Commits
d3c8271e
Commit
d3c8271e
authored
May 25, 2020
by
huanle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0525—10:28
parent
e8a20591
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
24 deletions
+97
-24
Index.php
application/api/controller/Index.php
+97
-24
No files found.
application/api/controller/Index.php
View file @
d3c8271e
...
...
@@ -11,7 +11,7 @@ class Index extends Controller
{
public
function
index
()
{
}
...
...
@@ -21,18 +21,15 @@ class Index extends Controller
$model
=
new
Folder
();
$parentid
=
$request
->
param
(
'parentid'
);
$res
=
$model
->
folderList
(
$parentid
);
// if ($res) {
// return json(code([$res], 0, 'ok'));
// } else {
// return json(code([$res], 10002, '请求失败'));
// }
return
json
(
code
([
$res
],
0
,
'ok'
));
}
public
function
folderAdd
()
{
$name
=
input
(
'post.name'
);
// var_dump($name);
$parentid
=
input
(
'post.parentid'
);
$model
=
new
Folder
();
...
...
@@ -55,8 +52,9 @@ class Index extends Controller
$name
=
input
(
'post.name'
);
$parentid
=
input
(
'post.parentid'
);
$folderid
=
input
(
'post.folderid'
);
$model
=
new
Folder
();
if
(
empty
(
$
parentid
)
||
empty
(
$
folderid
))
{
if
(
empty
(
$folderid
))
{
return
json
(
code
([],
10001
,
'参数不足'
));
}
if
(
empty
(
$name
))
{
...
...
@@ -104,39 +102,114 @@ class Index extends Controller
// $res = $model->ArticleList($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
[
'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
[
'lenght
'
];
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
;
}
$data
[
'admin'
]
=
AdminModel
::
admin_lst
(
$post
[
'origin'
],
$post
[
'pagenum'
]);
//数据总条数
$data
[
'count'
]
=
StudyModel
::
rules_count
();
//总页数
$data
[
'page'
]
=
ceil
(
$data
[
'count'
]
/
$data
[
'lenght'
]);
$result
=
$model
->
articleList
(
$folderid
,
$post
[
'origin'
],
$post
[
'pagenum'
]);
if
(
$result
)
{
return
json
(
code
([
$result
],
0
,
'请求成功'
));
}
else
{
return
json
(
code
([],
10002
,
'没有数据了'
));
}
}
public
function
articleDetail
()
{
$docid
=
input
(
'post.docid'
);
$model
=
new
Doclist
();
$detail
=
$model
->
articleDetail
(
$docid
);
if
(
$detail
)
{
return
json
(
code
([
$detail
],
0
,
'请求成功'
));
}
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'
);
$model
=
new
Doclist
();
if
(
empty
(
$type
))
{
return
json
(
code
([],
10001
,
'类型不能为空'
));
}
if
(
empty
(
$title
))
{
return
json
(
code
([],
10001
,
'标题不能为空'
));
}
else
{
$res
=
$model
->
addArticle
(
$title
,
$folderid
,
$type
,
$doc
);
if
(
$res
)
{
return
json
(
code
([
$res
],
0
,
'添加成功'
));
}
else
{
return
json
(
code
([
$res
],
10002
,
'添加失败'
));
}
}
}
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
))
{
return
json
(
code
([],
10001
,
'参数不足'
));
}
$res
=
$model
->
editArticle
(
$title
,
$folderid
,
$doc
,
$docid
);
if
(
$res
)
{
return
json
(
code
([],
0
,
'修改成功'
));
}
else
{
return
json
(
code
([],
10002
,
'修改失败'
));
}
}
}
public
function
articleDel
()
{
$docid
=
input
(
'post.docid'
);
$model
=
new
Doclist
();
if
(
empty
(
$docid
))
{
return
json
(
code
([],
10001
,
'没有docid'
));
}
else
{
$res
=
$model
->
delArticle
(
$docid
);
if
(
$res
)
{
return
json
(
code
([],
0
,
'删除成功'
));
}
else
{
return
json
(
code
([],
10002
,
'删除失败'
));
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment