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
1c7f4818
Commit
1c7f4818
authored
May 25, 2020
by
huanle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0525-11:26
parent
1b5fc47f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
45 deletions
+44
-45
Index.php
application/api/controller/Index.php
+34
-41
Doclist.php
application/api/model/Doclist.php
+10
-4
No files found.
application/api/controller/Index.php
View file @
1c7f4818
...
@@ -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
()
{
{
...
...
application/api/model/Doclist.php
View file @
1c7f4818
...
@@ -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
;
}
}
...
...
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