Helius
2022-07-22 823aabb391a0cbd2eddf7c58c03b76e71967b964
src/main/java/cc/mrbird/febs/common/advise/MyResponseBodyAdvise.java
@@ -5,6 +5,7 @@
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
@@ -12,14 +13,15 @@
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
/**
 * @author wzy
 * @date 2022-06-14
 **/
@Slf4j
@ControllerAdvice
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public class MyResponseBodyAdvise implements ResponseBodyAdvice {
    @Override
    public boolean supports(MethodParameter methodParameter, Class aClass) {
@@ -31,7 +33,6 @@
        if (!AppContants.ENCRYPT_METHOD.contains(methodParameter.getMethod().getName())) {
            return o;
        }
        RSA rsa = new RSA(AppContants.RESP_PRIVATE_KEY, AppContants.RESP_PUBLIC_KEY);
        return rsa.encryptBase64(JSONObject.toJSONString(o), KeyType.PublicKey);
    }