diff --git a/src/main/java/com/rymcu/forest/core/service/security/AuthorshipAspect.java b/src/main/java/com/rymcu/forest/core/service/security/AuthorshipAspect.java index 093b48d..92fd989 100644 --- a/src/main/java/com/rymcu/forest/core/service/security/AuthorshipAspect.java +++ b/src/main/java/com/rymcu/forest/core/service/security/AuthorshipAspect.java @@ -75,11 +75,21 @@ public class AuthorshipAspect { isArticle = false; } HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); - String idArticle = ""; + String idArticle; Integer idAuthor = 0; if (isAjax(request)) { Object[] objects = joinPoint.getArgs(); - JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(objects[0])); + JSONObject jsonObject; + if (objects[0] instanceof Integer) { + jsonObject = new JSONObject(); + if (isArticle) { + jsonObject.put("idArticle", objects[0].toString()); + } else { + jsonObject.put("idPortfolio", objects[0].toString()); + } + } else { + jsonObject = JSONObject.parseObject(JSON.toJSONString(objects[0])); + } if (Objects.nonNull(jsonObject)) { if (isArticle) { idArticle = jsonObject.getString("idArticle"); diff --git a/src/main/java/com/rymcu/forest/core/service/security/SecurityAspect.java b/src/main/java/com/rymcu/forest/core/service/security/SecurityAspect.java index f6ba82c..453d5eb 100644 --- a/src/main/java/com/rymcu/forest/core/service/security/SecurityAspect.java +++ b/src/main/java/com/rymcu/forest/core/service/security/SecurityAspect.java @@ -54,9 +54,14 @@ public class SecurityAspect { String idUser = ""; if (isAjax(request)) { Object[] objects = joinPoint.getArgs(); - JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(objects[0])); - if (Objects.nonNull(jsonObject)) { - idUser = jsonObject.getString("idUser"); + JSONObject jsonObject; + if (objects[0] instanceof Integer) { + idUser = objects[0].toString(); + } else { + jsonObject = JSONObject.parseObject(JSON.toJSONString(objects[0])); + if (Objects.nonNull(jsonObject)) { + idUser = jsonObject.getString("idUser"); + } } } else { Map params = getParams(request);