rjuqwhnt
This commit is contained in:
parent
445de7c5be
commit
4c9b572eec
@ -0,0 +1,11 @@
|
||||
package com.heyu.api.common.annotation;
|
||||
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface AdminNotNeedLogin {
|
||||
|
||||
}
|
||||
@ -91,6 +91,22 @@ public class AnnotationUtils {
|
||||
|
||||
|
||||
|
||||
public static <T> T getAnnotationValueByClass(Class clazz, String annotationName, String key) {
|
||||
Annotation annotation[] = clazz.getAnnotations();
|
||||
if (annotation != null && annotation.length > 0) {
|
||||
for (Annotation annotation1 : annotation) {
|
||||
if (annotationName.equals(getAnnotationName(annotation1))) {
|
||||
return getAnnotationValue(annotation1, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static <T> T getAnnotationValue(Annotation annotation,String key) {
|
||||
try {
|
||||
Method method = annotation.getClass().getMethod(key);
|
||||
|
||||
@ -92,6 +92,7 @@ public class ZhenZhenLogAop {
|
||||
try {
|
||||
args = recordRequestLog(point.getArgs(), uri);
|
||||
Signature sig = point.getSignature();
|
||||
|
||||
Method method = ((MethodSignature) sig).getMethod();
|
||||
if (sig instanceof MethodSignature) {
|
||||
methodName = ((MethodSignature) sig).getMethod().getName();
|
||||
@ -99,6 +100,7 @@ public class ZhenZhenLogAop {
|
||||
|
||||
describe = AnnotationUtils.getAnnotationValueByMethod(method, "Describe", "value");
|
||||
|
||||
|
||||
Class clazz = point.getTarget().getClass();
|
||||
className = clazz.getName();
|
||||
|
||||
@ -140,12 +142,12 @@ public class ZhenZhenLogAop {
|
||||
} else if (uri.startsWith(ApiConstants.MM_URI_START)) {
|
||||
token = attributes.getRequest().getHeader(ApiConstants.MM_TOKEN);
|
||||
Object tokenValue = redisUtils.get(token);
|
||||
boolean adminNotNeedLogin = AnnotationUtils.hasAnnotation(clazz, "AdminNotNeedLogin");
|
||||
// 登录不拦截
|
||||
if (!ApiConstants.MM_ADMIN_LOGIN_RUI.equals(uri)) {
|
||||
if (tokenValue == null) {
|
||||
return R.error("请登录");
|
||||
}
|
||||
if (!adminNotNeedLogin && tokenValue == null) {
|
||||
return R.error("请登录");
|
||||
}
|
||||
|
||||
if (tokenValue != null) {
|
||||
try {
|
||||
VVAdminDTO vvAdminDTO = JSONObject.parseObject(tokenValue + "", VVAdminDTO.class);
|
||||
|
||||
@ -3,6 +3,7 @@ package com.heyu.api.controller.mm;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.heyu.api.alibaba.request.mm.VVAdminRequest;
|
||||
import com.heyu.api.common.annotation.AdminNotNeedLogin;
|
||||
import com.heyu.api.common.annotation.Describe;
|
||||
import com.heyu.api.data.constants.RedisConstans;
|
||||
import com.heyu.api.data.dao.vv.VvAdminDao;
|
||||
@ -25,6 +26,7 @@ import java.util.Date;
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/mm/user/")
|
||||
@AdminNotNeedLogin
|
||||
public class AdminLoginController {
|
||||
|
||||
@Autowired
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user