Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
solo-1
Commits
e753f134
Commit
e753f134
authored
Apr 01, 2017
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚧
#12256 获取一个分类
parent
d56b7ad8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
src/main/java/org/b3log/solo/processor/console/CategoryConsole.java
...ava/org/b3log/solo/processor/console/CategoryConsole.java
+55
-0
No files found.
src/main/java/org/b3log/solo/processor/console/CategoryConsole.java
View file @
e753f134
...
...
@@ -91,6 +91,61 @@ public class CategoryConsole {
@Inject
private
LangPropsService
langPropsService
;
/**
* Gets a category by the specified request.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "category": {
* "oId": "",
* "categoryTitle": "",
* "categoryURI": "",
* ....
* }
* }
* </pre>
* </p>
*
* @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing
(
value
=
"/console/category/*"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
getCategory
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
,
final
HTTPRequestContext
context
)
throws
Exception
{
if
(!
userQueryService
.
isAdminLoggedIn
(
request
))
{
response
.
sendError
(
HttpServletResponse
.
SC_FORBIDDEN
);
return
;
}
final
JSONRenderer
renderer
=
new
JSONRenderer
();
context
.
setRenderer
(
renderer
);
try
{
final
String
requestURI
=
request
.
getRequestURI
();
final
String
categoryId
=
requestURI
.
substring
((
Latkes
.
getContextPath
()
+
"/console/category/"
).
length
());
final
JSONObject
result
=
categoryQueryService
.
getCategory
(
categoryId
);
if
(
null
==
result
)
{
renderer
.
setJSONObject
(
QueryResults
.
defaultResult
());
return
;
}
renderer
.
setJSONObject
(
result
);
result
.
put
(
Keys
.
STATUS_CODE
,
true
);
}
catch
(
final
ServiceException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
final
JSONObject
jsonObject
=
QueryResults
.
defaultResult
();
renderer
.
setJSONObject
(
jsonObject
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"getFailLabel"
));
}
}
/**
* Removes a category by the specified request.
* <p>
...
...
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