|
|
@ -11,6 +11,7 @@ import com.ccsens.util.JsonResponse; |
|
|
|
import com.ccsens.util.WebConstant; |
|
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.ss.formula.functions.T; |
|
|
|
import org.aspectj.lang.ProceedingJoinPoint; |
|
|
|
import org.aspectj.lang.Signature; |
|
|
|
import org.aspectj.lang.annotation.Around; |
|
|
@ -24,7 +25,10 @@ import org.springframework.web.context.request.RequestContextHolder; |
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.lang.reflect.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: |
|
|
@ -66,8 +70,9 @@ public class MustLoginAspect { |
|
|
|
Signature signature = pjp.getSignature(); |
|
|
|
MethodSignature methodSignature = (MethodSignature) signature; |
|
|
|
Method targetMethod = methodSignature.getMethod(); |
|
|
|
MustLogin mustLoginAnnotation = targetMethod.getAnnotation(MustLogin.class); |
|
|
|
|
|
|
|
MustLogin mustLoginAnnotation = targetMethod.getAnnotation(MustLogin.class); |
|
|
|
fillSeptial(dto, mustLoginAnnotation); |
|
|
|
if (mustLoginAnnotation == null) { |
|
|
|
log.info("不是必须登录,有token,则添加userId,没有则不添加"); |
|
|
|
if (response != null && response.getCode().intValue() == CodeEnum.SUCCESS.getCode().intValue() && response.getData() != null) { |
|
|
@ -115,4 +120,29 @@ public class MustLoginAspect { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private void fillSeptial(QueryDto dto, MustLogin mustLoginAnnotation) { |
|
|
|
if (dto != null && mustLoginAnnotation.type() > -1) { |
|
|
|
switch (mustLoginAnnotation.type()) { |
|
|
|
case 0: |
|
|
|
Object obj = dto.getParam(); |
|
|
|
if (obj!= null && !obj.getClass().isArray()) { |
|
|
|
Class<?> aClass = dto.getParam().getClass(); |
|
|
|
Object o = Array.newInstance(aClass, 1); |
|
|
|
Array.set(o, 0, dto.getParam()); |
|
|
|
dto.setParam(o); |
|
|
|
} |
|
|
|
break; |
|
|
|
case 1: |
|
|
|
Object obj1 = dto.getParam(); |
|
|
|
if (obj1!= null && !(obj1 instanceof List)) { |
|
|
|
ArrayList arrayList = new ArrayList(); |
|
|
|
arrayList.add(dto.getParam()); |
|
|
|
dto.setParam(arrayList); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|