Commit 2f075639 authored by Liang Ding's avatar Liang Ding

🎨 #12580

parent 2be92150
......@@ -57,7 +57,7 @@ import java.util.Set;
* @since 2.0.0
*/
@RequestProcessor
@Before( ConsoleAdminAuthAdvice.class)
@Before(ConsoleAdminAuthAdvice.class)
public class CategoryConsole {
/**
......@@ -159,15 +159,12 @@ public class CategoryConsole {
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing(value = "/console/category/*", method = HttpMethod.GET)
@RequestProcessing(value = "/console/category/{id}", method = HttpMethod.GET)
public void getCategory(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
try {
final HttpServletRequest request = context.getRequest();
final String requestURI = request.getRequestURI();
final String categoryId = requestURI.substring((Latkes.getContextPath() + "/console/category/").length());
final String categoryId = context.pathVar("id");
final JSONObject result = categoryQueryService.getCategory(categoryId);
if (null == result) {
renderer.setJSONObject(new JSONObject().put(Keys.STATUS_CODE, false));
......@@ -209,15 +206,14 @@ public class CategoryConsole {
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing(value = "/console/category/*", method = HttpMethod.DELETE)
@RequestProcessing(value = "/console/category/{id}", method = HttpMethod.DELETE)
public void removeCategory(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
final JSONObject jsonObject = new JSONObject();
renderer.setJSONObject(jsonObject);
try {
final HttpServletRequest request = context.getRequest();
final String categoryId = request.getRequestURI().substring((Latkes.getContextPath() + "/console/category/").length());
final String categoryId = context.pathVar("id");
categoryMgmtService.removeCategory(categoryId);
jsonObject.put(Keys.STATUS_CODE, true);
......
......@@ -87,7 +87,7 @@ public class CommentConsole {
*
* @param context the specified http request context
*/
@RequestProcessing(value = "/console/page/comment/*", method = HttpMethod.DELETE)
@RequestProcessing(value = "/console/page/comment/{id}", method = HttpMethod.DELETE)
public void removePageComment(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
......@@ -97,8 +97,7 @@ public class CommentConsole {
try {
final HttpServletRequest request = context.getRequest();
final HttpServletResponse response = context.getResponse();
final String commentId = request.getRequestURI().substring((Latkes.getContextPath() + "/console/page/comment/").length());
final String commentId = context.pathVar("id");
final JSONObject currentUser = Solos.getCurrentUser(request, response);
if (!commentQueryService.canAccessComment(commentId, currentUser)) {
ret.put(Keys.STATUS_CODE, false);
......@@ -133,7 +132,7 @@ public class CommentConsole {
*
* @param context the specified http request context
*/
@RequestProcessing(value = "/console/article/comment/*", method = HttpMethod.DELETE)
@RequestProcessing(value = "/console/article/comment/{id}", method = HttpMethod.DELETE)
public void removeArticleComment(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
......@@ -143,7 +142,7 @@ public class CommentConsole {
try {
final HttpServletRequest request = context.getRequest();
final HttpServletResponse response = context.getResponse();
final String commentId = request.getRequestURI().substring((Latkes.getContextPath() + "/console/article/comment/").length());
final String commentId = context.pathVar("id");
final JSONObject currentUser = Solos.getCurrentUser(request, response);
if (!commentQueryService.canAccessComment(commentId, currentUser)) {
ret.put(Keys.STATUS_CODE, false);
......
......@@ -48,7 +48,7 @@ import javax.servlet.http.HttpServletRequest;
* @since 0.4.0
*/
@RequestProcessor
@Before( ConsoleAdminAuthAdvice.class)
@Before(ConsoleAdminAuthAdvice.class)
public class LinkConsole {
/**
......@@ -88,7 +88,7 @@ public class LinkConsole {
*
* @param context the specified http request context
*/
@RequestProcessing(value = "/console/link/*", method = HttpMethod.DELETE)
@RequestProcessing(value = "/console/link/{id}", method = HttpMethod.DELETE)
public void removeLink(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
......@@ -96,9 +96,7 @@ public class LinkConsole {
renderer.setJSONObject(jsonObject);
try {
final HttpServletRequest request = context.getRequest();
final String linkId = request.getRequestURI().substring((Latkes.getContextPath() + "/console/link/").length());
final String linkId = context.pathVar("id");
linkMgmtService.removeLink(linkId);
jsonObject.put(Keys.STATUS_CODE, true);
......@@ -336,16 +334,13 @@ public class LinkConsole {
*
* @param context the specified http request context
*/
@RequestProcessing(value = "/console/link/*", method = HttpMethod.GET)
@RequestProcessing(value = "/console/link/{id}", method = HttpMethod.GET)
public void getLink(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
try {
final HttpServletRequest request = context.getRequest();
final String requestURI = request.getRequestURI();
final String linkId = requestURI.substring((Latkes.getContextPath() + "/console/link/").length());
final String linkId = context.pathVar("id");
final JSONObject result = linkQueryService.getLink(linkId);
if (null == result) {
renderer.setJSONObject(new JSONObject().put(Keys.STATUS_CODE, false));
......
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