diff --git a/build.gradle b/build.gradle index 64ab47a8..3e6af7d2 100644 --- a/build.gradle +++ b/build.gradle @@ -69,7 +69,7 @@ ext { allprojects { apply plugin: "idea" group = 'io.nerv' - version = '2.6.9.a' + version = '2.6.9.c' } subprojects { diff --git a/eva-core/eva-core-common/src/main/java/io/nerv/core/advice/JsonFilterAdvice.java b/eva-core/eva-core-common/src/main/java/io/nerv/core/advice/JsonFilterAdvice.java deleted file mode 100644 index 62372a0b..00000000 --- a/eva-core/eva-core-common/src/main/java/io/nerv/core/advice/JsonFilterAdvice.java +++ /dev/null @@ -1,156 +0,0 @@ -package io.nerv.core.advice; - -import io.nerv.core.annotation.JsonFilter; -import lombok.extern.slf4j.Slf4j; -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.stereotype.Component; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.*; - -/** - * 序列化对象时过滤某些属性 - */ -@Aspect -@Component -@Slf4j -public class JsonFilterAdvice { - //切入点 - @Pointcut("@annotation(io.nerv.core.annotation.JsonFilter)") - public void annotation(){} - - - /** - * 以jsonFilter注解为切入点切入方法,序列化对象时过滤某些属性 - * @param pjp - * @return - * @throws Throwable - */ - @Around("annotation()") - public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable { - //得到Controller层返回的对象 - Object retVal = pjp.proceed(); - - //得到方法上的注解 - Class clazzz=pjp.getTarget().getClass(); - Method mm=clazzz.getDeclaredMethod(pjp.getSignature().getName(),pjp.getArgs().getClass()); - JsonFilter jsonFilter=mm.getAnnotation(JsonFilter.class); - if(jsonFilter == null || jsonFilter.exclude().length < 1){ - return null; - }else{ - //操作对象,使得注解里对应的属性值为空 - nullVlueFeild(retVal,jsonFilter.exclude()); - } - return retVal; - } - - /** - * 把对象的属性置空 - * @param returnValue - * @param values - * @throws NoSuchFieldException - * @throws IllegalAccessException - */ - - private void nullVlueFeild(Object returnValue,String[] values) throws NoSuchFieldException,IllegalAccessException{ - for(String value:values) { - //根据.号分级 - String[] splitValue = value.split("\\."); - if (splitValue.length == 1) { - //顶层属性,直接设置属性值为空 - setNull(returnValue, value); - continue; - } - //表示上一层的属性对象的值 - Object fatherObj=returnValue; - //表示当前循环的属性对象的值 - Object object; - for (int i = 0; i < splitValue.length - 1; i++) { - - //得到当前对象的当前属性的值 - String param = splitValue[i]; - Field field = null; - try { - field = fatherObj.getClass().getDeclaredField(param); - } catch (NoSuchFieldException e) { - field = fatherObj.getClass().getSuperclass().getDeclaredField(param); - } - if (field == null) { - continue; - } - field.setAccessible(true); - object = field.get(fatherObj); - - - //如果是最后一个对象 即最后一个点之前的属性值 c(a.b.c.d),直接设置值 - if(splitValue.length-2 == i){ - setNull(object,splitValue[i+1]); - } - - //得到当前循环的子集的所有下层子集 - int begin =value.indexOf(".",i+1); - String[] sValue = {value.substring(begin+1,value.length())}; - - //判断是否是数组/集合 - if (object.getClass().isArray() || object instanceof Collection) { - for (Object obj : (Collection) object) { - //把当前属性的对象和所有下层子集传到方法中 - nullVlueFeild(obj, sValue); - } - break; - } else if (object instanceof Map) { - //判断是否是map集合 - Map map = (Map) object; - //map对象点之后即map的key 第二个点即该key对应的value里的属性 - String last=sValue[0]; - last=last.substring(last.indexOf(".")+1,last.length()); - sValue[0]=last; - nullVlueFeild(map.get(splitValue[i+1]), sValue); - break; - } - //下一级的父对象为当前这一级 - fatherObj=object; - } - } - - } - //根据对象类型把该对象的value置位空 - public void setNull(Object object,String value) throws NoSuchFieldException,IllegalAccessException{ - //判断是否是数组/集合 - if (object.getClass().isArray() || object instanceof Collection) { - for (Object obj : (Collection) object) { - nul(obj,value); - } - } else if (object instanceof Map) { - //判断是否是map集合 - Map map = (Map) object; - map.put(value,null); - }else{ - //javabean - nul(object,value); - } - } - - //把object的value属性置位空 - public void nul(Object object,String value) throws NoSuchFieldException,IllegalAccessException { - Field field = null; - - for (Object obj : (Collection) object) { - try { - field = obj.getClass().getDeclaredField(value); - } catch (NoSuchFieldException e) { - field = obj.getClass().getSuperclass().getDeclaredField(value); - } - field.setAccessible(true); - field.set(obj, null); - - } - } - -} - - \ No newline at end of file diff --git a/eva-web/eva-web-auth/src/main/java/io/nerv/config/WebSecurityConfig.java b/eva-web/eva-web-auth/src/main/java/io/nerv/config/WebSecurityConfig.java index b2c079b8..c4372f5d 100644 --- a/eva-web/eva-web-auth/src/main/java/io/nerv/config/WebSecurityConfig.java +++ b/eva-web/eva-web-auth/src/main/java/io/nerv/config/WebSecurityConfig.java @@ -106,6 +106,10 @@ public JwtAuthFilter authenticationTokenFilterBean() { return new JwtAuthFilter(); } + /** + * 跨域配置 + * @return + */ @Bean CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); diff --git a/eva-web/eva-web-base/src/main/java/io/nerv/core/advice/CommonResponseAdvice.java b/eva-web/eva-web-base/src/main/java/io/nerv/core/advice/CommonResponseAdvice.java new file mode 100644 index 00000000..a0b1eff6 --- /dev/null +++ b/eva-web/eva-web-base/src/main/java/io/nerv/core/advice/CommonResponseAdvice.java @@ -0,0 +1,45 @@ +package io.nerv.core.advice; + +import io.nerv.core.enums.BizCode; +import io.nerv.core.enums.BizCodeEnum; +import io.nerv.core.mvc.vo.Response; +import org.springframework.core.MethodParameter; +import org.springframework.http.MediaType; +import org.springframework.http.server.ServerHttpRequest; +import org.springframework.http.server.ServerHttpResponse; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; + +/** + * 统一处理返回值 + * 注意 这里只对io.nerv包下的返回值自动响应处理 + */ +@RestControllerAdvice(basePackages = "io.nerv") +public class CommonResponseAdvice implements ResponseBodyAdvice { + + @Override + public boolean supports(MethodParameter returnType, Class converterType) { + return true; + } + + @Override + public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) { + + + if (body instanceof Response){ + return body; + } + Response res = new Response(); + res.setSuccess(true); + + if (body instanceof BizCode){ + res.setCode(((BizCode) body).getIndex()); + res.setMessage(((BizCode) body).getName()); + } else { + res.setMessage(BizCodeEnum.OPERATE_SUCCESS.getIndex()); + res.setData(body); + } + + return res; + } +} diff --git a/gradle.properties b/gradle.properties index e7b31f5d..7d393d7c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,31 +2,31 @@ profile=aliyun spring_dep=1.0.11.RELEASE jfrog_ver=1.8.5 -spring_boot_ver=2.5.2 -mysql=8.0.25 -mybatis_plus_starter=3.4.3 +spring_boot_ver=2.5.3 +mysql=8.0.26 +mybatis_plus_starter=3.4.3.1 mybatis_plus_generator=3.5.0 lombok=1.18.20 -knife4j=3.0.2 -hutool=5.7.3 +knife4j=3.0.3 +hutool=5.7.7 jaxb_api=2.3.1 jasypt=3.0.3 p6spy=3.9.1 -flyway=7.9.1 +flyway=7.11.4 boot_admin=2.4.3 truelicense=1.33 caffeine=3.0.3 -weixin=4.0.0 +weixin=4.1.0 securityTest=5.5.1 -alipay=4.13.58.ALL +alipay=4.16.1.ALL zxing=3.4.1 velocity=2.3 -jwt=9.9.3 +jwt=9.11.2 jsr310=2.12.1 -oracle=19.10.0.0 +oracle=19.11.0.0 orai18n=12.1.0.2.0 snakeyaml=1.29 -cdu=1.4.0 +cdu=1.4.1 org.gradle.jvmargs=-Dfile.encoding=UTF-8 systemProp.file.encoding=UTF-8 diff --git a/settings.gradle b/settings.gradle index dda2399a..aa1f141c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,8 +11,10 @@ include ':eva-core:eva-core-cache' include ':eva-core:eva-core-data-jpa' include ':eva-core:eva-core-data-mybatis' include ':eva-core:eva-core-security' +include 'eva-core:eva-core-sso' + include 'nerv-admin-server' include 'nerv-license' include 'nerv-generator' include 'web-booter' - +include 'web-booter-sso' diff --git a/web-booter/src/main/resources/application-aliyun.yaml b/web-booter/src/main/resources/application-aliyun.yaml index cd5d823f..85630fd9 100644 --- a/web-booter/src/main/resources/application-aliyun.yaml +++ b/web-booter/src/main/resources/application-aliyun.yaml @@ -37,7 +37,7 @@ spring: additional-paths: src/main/java # redis 配置 redis: - host: xilai.my.to + host: 47.104.217.77 port: 6379 password: 7u8i9o0p timeout: 10000