| | |
| | | import com.zy.asrs.entity.ApiLog; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.common.annotations.OpenApiLog; |
| | | import com.zy.system.timer.LicenseTimer; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.aspectj.lang.ProceedingJoinPoint; |
| | | import org.aspectj.lang.annotation.Around; |
| | |
| | | |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private LicenseTimer licenseTimer; |
| | | |
| | | @Pointcut("execution(* com.zy.asrs.controller.*(..))") |
| | | private void webLog() { |
| | |
| | | Object result = null; |
| | | Object errorResponse = null; |
| | | try { |
| | | if (licenseTimer != null && !licenseTimer.getSystemSupport()) { |
| | | Object fail = R.error("许可证失效"); |
| | | if (annotation != null && !Cools.isEmpty(annotation.memo())) { |
| | | saveErrLog(joinPoint, request, fail, new CoolException("许可证失效"), annotation.memo()); |
| | | } |
| | | return fail; |
| | | } |
| | | result = joinPoint.proceed(joinPoint.getArgs()); |
| | | if (annotation != null && !Cools.isEmpty(annotation.memo())) { |
| | | saveLog(joinPoint, request, result, annotation.memo()); |
| | |
| | | if (annotation != null && !Cools.isEmpty(annotation.memo())) { |
| | | saveErrLog(joinPoint, request, errorResponse, ex, annotation.memo()); |
| | | } |
| | | throw ex; |
| | | if (ex instanceof Exception) { |
| | | throw (Exception) ex; |
| | | } |
| | | throw new RuntimeException(ex); |
| | | } finally { |
| | | long end = System.currentTimeMillis(); |
| | | // log.info("请求日志的打印"); |
| | |
| | | |
| | | private Object buildErrorResponse(Throwable ex) { |
| | | if (ex instanceof CoolException) { |
| | | return R.parse(ex.getMessage()); |
| | | return R.error(ex.getMessage()); |
| | | } |
| | | return R.error(); |
| | | } |