dev #1
@@ -12,4 +12,7 @@ public interface DashBoardAppClient {
|
|||||||
|
|
||||||
@PostMapping("/api/v1/data")
|
@PostMapping("/api/v1/data")
|
||||||
Map<String, Object> getUsersWithPagination(@RequestBody BaseRequest request);
|
Map<String, Object> getUsersWithPagination(@RequestBody BaseRequest request);
|
||||||
|
|
||||||
|
@PostMapping("api/internal/data")
|
||||||
|
Map<String, Object> internalData(@RequestBody BaseRequest request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package ru.soune.nocopy.adminpanel.config;
|
||||||
|
|
||||||
|
import feign.RequestInterceptor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class FeignConfig {
|
||||||
|
|
||||||
|
@Value("${app.internal-api-key}")
|
||||||
|
private String internalApiKey;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RequestInterceptor internalKeyInterceptor() {
|
||||||
|
return requestTemplate -> {
|
||||||
|
requestTemplate.header("X-Internal-Key", internalApiKey);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -90,6 +90,30 @@ public class AdminController {
|
|||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/internal-info")
|
||||||
|
public ResponseEntity<BaseResponse> handleInternalInfo(@RequestBody BaseRequest request) {
|
||||||
|
Long currentUserId = (Long) httpServletRequest.getAttribute("userId");
|
||||||
|
|
||||||
|
if (!adminSectionPermissionService.canRead(currentUserId,
|
||||||
|
AdminSection.USERS)) {
|
||||||
|
return ResponseEntity.ok(BaseResponse.builder()
|
||||||
|
.msgId(request.getMsgId())
|
||||||
|
.messageCode(MessageCode.PERMISSION_DENIED.getCode())
|
||||||
|
.messageDesc("You can't reads")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> response = dashBoardAppClient.internalData(request);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(
|
||||||
|
BaseResponse.builder()
|
||||||
|
.msgId(request.getMsgId())
|
||||||
|
.messageCode(MessageCode.SUCCESS.getCode())
|
||||||
|
.messageDesc(MessageCode.SUCCESS.getDescription())
|
||||||
|
.messageBody(response)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/control")
|
@PostMapping("/control")
|
||||||
public ResponseEntity<BaseResponse> handleControl(@RequestBody BaseRequest request) {
|
public ResponseEntity<BaseResponse> handleControl(@RequestBody BaseRequest request) {
|
||||||
Long currentUserId = (Long) httpServletRequest.getAttribute("userId");
|
Long currentUserId = (Long) httpServletRequest.getAttribute("userId");
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ spring:
|
|||||||
server:
|
server:
|
||||||
port: ${SERVER_PORT:8082}
|
port: ${SERVER_PORT:8082}
|
||||||
|
|
||||||
|
app:
|
||||||
|
internal-api-key: "tljzkXiEYF1klSHuG2hPZKjx6EsBX8RQP6UrzMdQanSKbRYuHuOBwrXejZkn7V4FICvIahoDmYD2hjNBPw61NFbGIt4scOzwZpyCiXEa1YKLAeJSPso4S43LIZlKjO4S"
|
||||||
|
|
||||||
jwt:
|
jwt:
|
||||||
secret: Z29nb3Bvd2VycmFuZ2VydHVtYmF5YW1iZjMyNDIyMjh3aW5lcndpbmVy
|
secret: Z29nb3Bvd2VycmFuZ2VydHVtYmF5YW1iZjMyNDIyMjh3aW5lcndpbmVy
|
||||||
expiration: 3600000
|
expiration: 3600000
|
||||||
|
|||||||
Reference in New Issue
Block a user