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

🎨 #12580

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