Browse Source

👎 删除dubbo 修复本地域名

sj
Loki 2 years ago
parent
commit
567bda85a6
  1. 12
      yudao-framework/yudao-spring-boot-starter-web/pom.xml
  2. 10
      yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
  3. 1
      yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java
  4. 2
      yudao-server/src/main/resources/application-local.yaml
  5. 202
      zsw-bxg/src/main/java/co/yixiang/app/common/aspect/AppLogAspect.java

12
yudao-framework/yudao-spring-boot-starter-web/pom.xml

@ -59,12 +59,12 @@
<artifactId>resilience4j-ratelimiter</artifactId>
<scope>provided</scope> <!-- 设置为 provided,主要是 GlobalExceptionHandler 使用 -->
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>3.0.9</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.dubbo</groupId>-->
<!-- <artifactId>dubbo</artifactId>-->
<!-- <version>3.0.9</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>

10
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java

@ -17,7 +17,7 @@ import io.github.resilience4j.ratelimiter.RequestNotPermitted;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.dubbo.rpc.RpcException;
//import org.apache.dubbo.rpc.RpcException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.util.Assert;
import org.springframework.validation.BindException;
@ -96,10 +96,10 @@ public class GlobalExceptionHandler {
return accessDeniedExceptionHandler(request, (AccessDeniedException) ex);
}
if (ex instanceof RpcException){
log.error("dubbo错误", ex);
return null;
}
// if (ex instanceof RpcException){
// log.error("dubbo错误", ex);
// return null;
// }
return defaultExceptionHandler(request, ex);
}

1
yudao-server/src/main/java/cn/iocoder/yudao/server/YudaoServerApplication.java

@ -1,6 +1,5 @@
package cn.iocoder.yudao.server;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.system.ApplicationHome;

2
yudao-server/src/main/resources/application-local.yaml

@ -270,7 +270,7 @@ dubbo:
bxg:
shop:
# API_URL: http://192.168.10.113:48080/bxgApp
API_URL: http://45288535.r5.cpolar.top
API_URL: http://yudao.test.yixinhuixiang.com
SITE_URL: http://192.168.10.113:48080/bxgApp
UNI_SITE_URL: http://192.168.10.113:48080/bxgApp
ADMIN_API_URL: http://192.168.10.113:48080/bxg

202
zsw-bxg/src/main/java/co/yixiang/app/common/aspect/AppLogAspect.java

@ -1,101 +1,101 @@
/**
* Copyright (C) 2018-2022
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.app.common.aspect;
import co.yixiang.app.common.bean.LocalUser;
import co.yixiang.logging.domain.Log;
import co.yixiang.logging.service.LogService;
import co.yixiang.utils.RequestHolder;
import co.yixiang.utils.StringUtils;
import co.yixiang.utils.ThrowableUtil;
import lombok.extern.slf4j.Slf4j;
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.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
/**
* @author hupeng
* @date 2018-11-24
*/
@Component
@Aspect
@Slf4j
public class AppLogAspect {
private final LogService logService;
ThreadLocal<Long> currentTime = new ThreadLocal<>();
public AppLogAspect(LogService logService) {
this.logService = logService;
}
/**
* 配置切入点
*/
@Pointcut("@annotation(co.yixiang.logging.aop.log.AppLog)")
public void logPointcut() {
// 该方法无方法体,主要为了让同类中其他方法使用此切入点
}
/**
* 配置环绕通知,使用在方法logPointcut()上注册的切入点
*
* @param joinPoint join point for advice
*/
@Around("logPointcut()")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
Object result;
currentTime.set(System.currentTimeMillis());
result = joinPoint.proceed();
Log log = new Log("INFO",System.currentTimeMillis() - currentTime.get());
currentTime.remove();
HttpServletRequest request = RequestHolder.getHttpServletRequest();
logService.saveApp(getUsername(),
StringUtils.getIp(RequestHolder.getHttpServletRequest()),joinPoint,
log,getUid());
return result;
}
/**
* 配置异常通知
*
* @param joinPoint join point for advice
* @param e exception
*/
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
Log log = new Log("ERROR",System.currentTimeMillis() - currentTime.get());
currentTime.remove();
log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes());
HttpServletRequest request = RequestHolder.getHttpServletRequest();
logService.save(getUsername(),
StringUtils.getIp(RequestHolder.getHttpServletRequest()),
(ProceedingJoinPoint)joinPoint, log,getUid());
}
public String getUsername() {
try {
return LocalUser.getUser().getUsername();
}catch (Exception e){
return "";
}
}
public Long getUid(){
try {
return LocalUser.getUser().getUid();
}catch (Exception e){
return 0L;
}
}
}
///**
// * Copyright (C) 2018-2022
// * All rights reserved, Designed By www.yixiang.co
//
// */
//package co.yixiang.app.common.aspect;
//
//import co.yixiang.app.common.bean.LocalUser;
//import co.yixiang.logging.domain.Log;
//import co.yixiang.logging.service.LogService;
//import co.yixiang.utils.RequestHolder;
//import co.yixiang.utils.StringUtils;
//import co.yixiang.utils.ThrowableUtil;
//import lombok.extern.slf4j.Slf4j;
//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.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//
///**
// * @author hupeng
// * @date 2018-11-24
// */
//@Component
//@Aspect
//@Slf4j
//public class AppLogAspect {
//
// private final LogService logService;
//
// ThreadLocal<Long> currentTime = new ThreadLocal<>();
//
// public AppLogAspect(LogService logService) {
// this.logService = logService;
// }
//
// /**
// * 配置切入点
// */
// @Pointcut("@annotation(co.yixiang.logging.aop.log.AppLog)")
// public void logPointcut() {
// // 该方法无方法体,主要为了让同类中其他方法使用此切入点
// }
//
// /**
// * 配置环绕通知,使用在方法logPointcut()上注册的切入点
// *
// * @param joinPoint join point for advice
// */
// @Around("logPointcut()")
// public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
// Object result;
// currentTime.set(System.currentTimeMillis());
// result = joinPoint.proceed();
// Log log = new Log("INFO",System.currentTimeMillis() - currentTime.get());
// currentTime.remove();
// HttpServletRequest request = RequestHolder.getHttpServletRequest();
// logService.saveApp(getUsername(),
// StringUtils.getIp(RequestHolder.getHttpServletRequest()),joinPoint,
// log,getUid());
// return result;
// }
//
// /**
// * 配置异常通知
// *
// * @param joinPoint join point for advice
// * @param e exception
// */
// @AfterThrowing(pointcut = "logPointcut()", throwing = "e")
// public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
// Log log = new Log("ERROR",System.currentTimeMillis() - currentTime.get());
// currentTime.remove();
// log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes());
// HttpServletRequest request = RequestHolder.getHttpServletRequest();
// logService.save(getUsername(),
// StringUtils.getIp(RequestHolder.getHttpServletRequest()),
// (ProceedingJoinPoint)joinPoint, log,getUid());
// }
//
// public String getUsername() {
// try {
// return LocalUser.getUser().getUsername();
// }catch (Exception e){
// return "";
// }
// }
//
// public Long getUid(){
// try {
// return LocalUser.getUser().getUid();
// }catch (Exception e){
// return 0L;
// }
// }
//}

Loading…
Cancel
Save