From e9d8315ef063d49dee73d3b35c189a7e37622bbd Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Wed, 13 May 2020 17:06:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=A0=A1=E9=AA=8C=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cm/common/aspect/ApiParamsAspect.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/cloud-common-plugin/src/main/java/com/cm/common/aspect/ApiParamsAspect.java b/cloud-common-plugin/src/main/java/com/cm/common/aspect/ApiParamsAspect.java index 8029a02..cffb65b 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/aspect/ApiParamsAspect.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/aspect/ApiParamsAspect.java @@ -46,6 +46,14 @@ public class ApiParamsAspect { public void oauthCutPoint() { } + @Pointcut("execution(public * com.cm.common.article.controller..*.*(..))") + public void articleCutPoint() { + } + + @Pointcut("execution(public * com.cm.common.wechat.controller..*.*(..))") + public void wechatCutPoint() { + } + @Before("apiCutPoint()") public void beforeApiCutPoint(JoinPoint joinPoint) throws ParamsException { beforeCutPoint(joinPoint); @@ -61,6 +69,16 @@ public class ApiParamsAspect { beforeCutPoint(joinPoint); } + @Before("articleCutPoint()") + public void beforeArticleCutPoint(JoinPoint joinPoint) throws ParamsException { + beforeCutPoint(joinPoint); + } + + @Before("wechatCutPoint()") + public void beforeWechatCutPoint(JoinPoint joinPoint) throws ParamsException { + beforeCutPoint(joinPoint); + } + private void beforeCutPoint(JoinPoint joinPoint) throws ParamsException { Signature signature = joinPoint.getSignature(); Object[] args = joinPoint.getArgs(); @@ -73,10 +91,10 @@ public class ApiParamsAspect { if (method.isAnnotationPresent(CheckRequestBodyAnnotation.class)) { LOG.debug("校验参数"); Parameter[] parameters = method.getParameters(); - for(Parameter parameter : parameters) { - if(parameter.isAnnotationPresent(RequestBody.class)) { - for(Object arg: args) { - if(parameter.getType() == arg.getClass()) { + for (Parameter parameter : parameters) { + if (parameter.isAnnotationPresent(RequestBody.class)) { + for (Object arg : args) { + if (parameter.getType() == arg.getClass()) { AnnotationUtil.checkField(arg); } }