add section admin permission
This commit is contained in:
@@ -20,6 +20,11 @@ configurations {
|
||||
}
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2023.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -41,5 +46,6 @@ dependencies {
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-data-jpa-test'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:4.1.0'
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package ru.soune.nocopy.adminpanel;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class AdminPanelApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package ru.soune.nocopy.adminpanel.client;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import ru.soune.nocopy.adminpanel.dto.BaseRequest;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(name = "dashboard", url = "${nocopy-dashboard.url}")
|
||||
public interface DashBoardAppClient {
|
||||
|
||||
@PostMapping("/api/v1/data")
|
||||
Map<String, Object> getUsersWithPagination(@RequestBody BaseRequest request);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.soune.nocopy.adminpanel.client.DashBoardAppClient;
|
||||
import ru.soune.nocopy.adminpanel.dto.BaseRequest;
|
||||
import ru.soune.nocopy.adminpanel.dto.BaseResponse;
|
||||
import ru.soune.nocopy.adminpanel.handler.RequestHandler;
|
||||
@@ -22,6 +23,8 @@ public class AdminController {
|
||||
|
||||
private final Map<Integer, RequestHandler> handlers;
|
||||
|
||||
private final DashBoardAppClient dashBoardAppClient;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<BaseResponse> handleRequest(@RequestBody BaseRequest request) {
|
||||
log.info("Received request: msg_id={}, version={}", request.getMsgId(), request.getVersion());
|
||||
@@ -55,4 +58,17 @@ public class AdminController {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/get-users")
|
||||
public ResponseEntity<BaseResponse> handleUsers(@RequestBody BaseRequest request) {
|
||||
Map<String, Object> response = dashBoardAppClient.getUsersWithPagination(request);
|
||||
|
||||
return ResponseEntity.ok(
|
||||
BaseResponse.builder()
|
||||
.msgId(request.getMsgId())
|
||||
.messageCode(MessageCode.SUCCESS.getCode())
|
||||
.messageDesc(MessageCode.SUCCESS.getDescription())
|
||||
.messageBody(response)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
spring:
|
||||
cloud:
|
||||
compatibility-verifier:
|
||||
enabled: false
|
||||
datasource:
|
||||
url: jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
|
||||
username: ${POSTGRES_USER}
|
||||
@@ -14,3 +17,6 @@ server:
|
||||
jwt:
|
||||
secret: Z29nb3Bvd2VycmFuZ2VydHVtYmF5YW1iZjMyNDIyMjh3aW5lcndpbmVy
|
||||
expiration: 3600000
|
||||
|
||||
nocopy-dashboard:
|
||||
url: http://localhost:3001
|
||||
Reference in New Issue
Block a user