
com.owl.comment.asImpl.OwlBackToMsgResultAS Maven / Gradle / Ivy
package com.owl.comment.asImpl;
import com.owl.comment.annotations.OwlBackToMsgResult;
import com.owl.comment.utils.AsLogUtil;
import com.owl.util.ObjectUtil;
import com.owl.mvc.model.MsgConstant;
import com.owl.mvc.vo.MsgResultVO;
import com.owl.util.RegexUtil;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
* @author engwen
* email [email protected]
* 2018/12/7.
*/
@Aspect
@Component
@Order(97)
public class OwlBackToMsgResultAS {
@Pointcut("@within(com.owl.comment.annotations.OwlBackToMsgResult) || @annotation(com.owl.comment.annotations.OwlBackToMsgResult)")
public void changeBackClassCut() {
}
@AfterThrowing(value = "changeBackClassCut()", throwing = "ex")
public Object afterThrowing(JoinPoint joinPoint, Exception ex) {
MsgResultVO result = new MsgResultVO<>();
result.errorResult(MsgConstant.CONTROLLER_THROWABLE_ERROR);
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
AsLogUtil.error(joinPoint, methodSignature.getMethod().getName() + " " + ex);
return result;
}
@Around("changeBackClassCut()")
public Object changeBackClass(ProceedingJoinPoint joinPoint) throws Throwable {
Object obj = joinPoint.proceed();
if (obj instanceof MsgResultVO)
return obj;
MsgResultVO
© 2015 - 2025 Weber Informatics LLC | Privacy Policy