后置 前置 环绕 @AfterReturning(value="@annotation(com.sdyy.biz.act.maint.aop.annotation.ResIfNull)",returning="result") public void AfterReturning(JoinPoint joinPoint , Object result) { logger.info("AfterReturning------------start"); ResIfNull myAnno= ((MethodSignature)joinPoint.getSignature()).getMethod().getAnnotation(ResIfNull.class); if ("obj".equals(myAnno.type())) { if (result == null) { throw new SysException("初始化流程失败,请定义服务流程"); } } else if ("list".equals(myAnno.type())) { if (result instanceof List) { List res = (List) result; if (res.size() == 0) { throw new SysException("初始化流程失败,请配置参数"); } } } }
@Before(value="@annotation(com.sdyy.biz.act.maint.aop.annotation.IfMount)") public void ifMountCheck(JoinPoint joinPoint) throws Exception { Object[] args = joinPoint.getArgs(); if(dsServiceDetailService.getMountCount(args[0].toString())<=0){ //说明没有挂接数据 throw new SysException("请挂接数据"); } //获取方法参数 }
package com.sdyy.common.aop; import com.sdyy.common.annotation.OperLog; import com.sdyy.common.controller.BaseController; import com.sdyy.common.entity.KafkaMessage; import com.sdyy.common.entity.Log; import com.sdyy.common.kafka.KafkaProducer; import com.sdyy.common.retobj.BaseEntity; import com.sdyy.common.utils.DateUtils; import com.sdyy.core.auth.operator.entity.AuthOperator; import lombok.extern.log4j.Log4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; /** * * * @className: LogAspect * * @description:日志切面 * * @param: * * @return: * * @throws: * * @author: lizz * * @date: 2020/03/15 18:37 * */ @Log4j @Component @Aspect public class LogAspect { @Autowired private KafkaProducer producer; /** * @Description: 方法切入点 * @Author: lizz * @Date: 2020/3/15 18:56 * @Reviser:修改人 * @ReviseDate:修改时间 * @Revision:修改内容 **/ @Pointcut("execution(* com.sdyy.maint.*.controller.*.*(..))") public void pointerCutMethod() { } /** * @Description: 环绕通知 * @Author: lizz * @Date: 2020/3/15 18:56 * @Reviser:修改人 * @ReviseDate:修改时间 * @Revision:修改内容 **/ @Around(value = "pointerCutMethod() && @annotation(annotation)") public Object doAround(ProceedingJoinPoint joinPoint, OperLog annotation) { Log logs = new Log(); //通过注解获取当前属于那个模块 logs.setModuleName(annotation.moduleName()); //通过注解获取当前的操作方式 logs.setOperation(annotation.option()); logs.setCreatedate(DateUtils.getCurrentDate()); RequestAttributes ra = RequestContextHolder.getRequestAttributes(); Long beginTime = System.currentTimeMillis(); if (ra != null) { ServletRequestAttributes sra = (ServletRequestAttributes) ra; HttpServletRequest request = sra.getRequest(); String ip = request.getRemoteHost(); logs.setUserIp(ip); logs.setReqUrl(request.getRequestURI()); // 从session中获取用户信息 AuthOperator authOperator = (AuthOperator) request.getSession().getAttribute(BaseController.LOGIN_IN_OPERATOR_SESSION); if (authOperator != null) { logs.setUserName(authOperator.getUserId()); } } try { Object object = joinPoint.proceed(); if (object != null) { if (object instanceof BaseEntity) { if(((BaseEntity) object).getStatus()==200){ logs.setOperResult("成功"); }else { logs.setOperResult(((BaseEntity) object).getMessage()); } } } KafkaMessage ms =new KafkaMessage(); ms.setMsg(logs); producer.send("logs", ms); return object; } catch (Throwable e) { logs.setOperResult("失败:" + e.getMessage()); KafkaMessage ms =new KafkaMessage(); ms.setMsg(logs); producer.send("logs", ms); log.error("异常"+e); return null; } } }
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算