|
@@ -2,8 +2,11 @@ package org.jeecg.modules.adweb.api.controller;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.jeecg.modules.adweb.api.vo.APIRequestVO;
|
|
|
import org.jeecg.modules.adweb.api.vo.ProductInfoVO;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.security.oauth2.server.resource.InvalidBearerTokenException;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.Collections;
|
|
@@ -18,8 +21,17 @@ public class OpenAPIController {
|
|
|
|
|
|
@PostMapping("/product/list")
|
|
|
@ResponseBody
|
|
|
- public List<ProductInfoVO> listProducts(@RequestParam APIRequestVO apiReques) {
|
|
|
+ public List<ProductInfoVO> listProducts(
|
|
|
+ @RequestHeader(value = HttpHeaders.AUTHORIZATION, required = true) String authToken,
|
|
|
+ @RequestParam APIRequestVO apiRequest) {
|
|
|
+ this.validateAuthToken(authToken);
|
|
|
|
|
|
return Collections.EMPTY_LIST;
|
|
|
}
|
|
|
+
|
|
|
+ private boolean validateAuthToken(String authToken) {
|
|
|
+ if (!StringUtils.equals(STATIC_BEARER_TOKEN, authToken)) {
|
|
|
+ throw new InvalidBearerTokenException("Bearer toke is invalid: " + authToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|