logs
This commit is contained in:
parent
e92cb8cc8e
commit
7a8c5d704e
12 changed files with 210 additions and 19 deletions
|
|
@ -53,6 +53,14 @@
|
|||
<groupId>ru.spcex.platform</groupId>
|
||||
<artifactId>platform-enum</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>security-util</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.spcex.clearing</groupId>
|
||||
<artifactId>clearing-validation</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package ru.spcex.clearing.gatewayapi.config;
|
||||
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import ru.spcex.clearing.gatewayapi.errors.GatewayError;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.util.services.IMDGMessageResolver;
|
||||
import ru.spcex.platform.enumeration.UserRole;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.IMessageResolver;
|
||||
|
||||
@Configuration
|
||||
public class BeanConfiguration {
|
||||
@Bean
|
||||
public IMessageResolver messageResolver(ImdgProvider imdgProvider) {
|
||||
return new IMDGMessageResolver(imdgProvider);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public UserRoleVerification userRoleVerification(ImdgProvider imdgProvider, IMessageResolver messageResolver) {
|
||||
return new UserRoleVerification(imdgProvider, messageResolver, UserRole.Admin, GatewayError.UserVerifyDenial);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,9 +2,10 @@ package ru.spcex.clearing.gatewayapi.config;
|
|||
|
||||
public class InboundServerSettings {
|
||||
private String host;
|
||||
private String path;
|
||||
private String pathLOCM;
|
||||
private String pathLOSC;
|
||||
private Integer port;
|
||||
private Boolean ssl;
|
||||
private Boolean enableSsl;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
|
|
@ -22,19 +23,27 @@ public class InboundServerSettings {
|
|||
this.port = port;
|
||||
}
|
||||
|
||||
public Boolean getSsl() {
|
||||
return ssl;
|
||||
public Boolean getEnableSsl() {
|
||||
return enableSsl;
|
||||
}
|
||||
|
||||
public void setSsl(Boolean ssl) {
|
||||
this.ssl = ssl;
|
||||
public void setEnableSsl(Boolean enableSsl) {
|
||||
this.enableSsl = enableSsl;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
public String getPathLOCM() {
|
||||
return pathLOCM;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
public void setPathLOCM(String pathLOCM) {
|
||||
this.pathLOCM = pathLOCM;
|
||||
}
|
||||
|
||||
public String getPathLOSC() {
|
||||
return pathLOSC;
|
||||
}
|
||||
|
||||
public void setPathLOSC(String pathLOSC) {
|
||||
this.pathLOSC = pathLOSC;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package ru.spcex.clearing.gatewayapi.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
private final RestTemplateBuilder builder;
|
||||
|
||||
@Autowired
|
||||
public RestTemplateConfig(RestTemplateBuilder builder) {
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
@Bean("rest-template")
|
||||
public RestTemplate restTemplate() {
|
||||
return builder
|
||||
.setConnectTimeout(Duration.ofMillis(10000))
|
||||
.setReadTimeout(Duration.ofMillis(40000))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package ru.spcex.clearing.gatewayapi.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.filter.CommonsRequestLoggingFilter;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
|
|
@ -8,4 +10,14 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||
@EnableWebMvc
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public CommonsRequestLoggingFilter loggingFilter() {
|
||||
CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter();
|
||||
filter.setIncludePayload(true);
|
||||
filter.setIncludeQueryString(true);
|
||||
filter.setMaxPayloadLength(1000000000);
|
||||
filter.setAfterMessagePrefix("Income request data: ");
|
||||
return filter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,9 @@ public class GatewayController {
|
|||
return commonResponse;
|
||||
}
|
||||
|
||||
|
||||
public CommonResponse errorResponse() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private CommonResponse createResponse(BaseRequest request) {
|
||||
CommonResponse commonResponse = new CommonResponse();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package ru.spcex.clearing.gatewayapi.errors;
|
||||
|
||||
import ru.spcex.platform.utils.enumeration.IErrorEnumId;
|
||||
|
||||
public enum GatewayError implements IErrorEnumId {
|
||||
UserVerifyDenial(6443L),
|
||||
CompanyNotFound(6001L),
|
||||
SecurityNotFound(6002L),
|
||||
WrongFieldValue(5004L)
|
||||
;
|
||||
|
||||
|
||||
private final Long id;
|
||||
|
||||
GatewayError(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package ru.spcex.clearing.gatewayapi.exception;
|
||||
|
||||
public class GatewayException extends RuntimeException {
|
||||
|
||||
}
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
package ru.spcex.clearing.gatewayapi.logic;
|
||||
|
||||
public class ProcessResult {
|
||||
private boolean ok = true;
|
||||
import ru.spcex.clearing.gatewayapi.errors.GatewayError;
|
||||
|
||||
public boolean isOk() {
|
||||
return ok;
|
||||
public class ProcessResult {
|
||||
private GatewayError error = null;
|
||||
|
||||
public GatewayError getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setOk(boolean ok) {
|
||||
this.ok = ok;
|
||||
public void setError(GatewayError error) {
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
package service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import ru.spcex.clearing.gatewayapi.config.InboundServerSettings;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.GatewayTaskRequest;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.platform.enumeration.Task;
|
||||
|
||||
@Service
|
||||
public class GatewayService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final RestTemplate restTemplate;
|
||||
private final InboundServerSettings inboundServerSettings;
|
||||
|
||||
public GatewayService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaProducer,
|
||||
RestTemplate restTemplate,
|
||||
UserRoleVerification userRoleVerification,
|
||||
InboundServerSettings inboundServerSettings) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.restTemplate = restTemplate;
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.inboundServerSettings = inboundServerSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
callback(GatewayTaskRequest.class)
|
||||
.setFunction(this::requestOnDemandCompany)
|
||||
.forDestination(Task.loadParty_LOCM.topic(), callbacks::put);
|
||||
callback(GatewayTaskRequest.class)
|
||||
.setFunction(this::requestOnDemandSecurity)
|
||||
.forDestination(Task.loadIssue_LOSC.topic(), callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
public RequestInfoUpdate requestOnDemandCompany(BaseRequest<GatewayTaskRequest> userRequest) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate requestOnDemandSecurity(BaseRequest<GatewayTaskRequest> userRequest) {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
server.port=8080
|
||||
server.servlet.context-path=/gateway-api
|
||||
logging.level.org.springframework.web=DEBUG
|
||||
logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG
|
||||
|
||||
spring.main.web-application-type=servlet
|
||||
|
||||
|
|
@ -23,7 +25,8 @@ gateway-api.kafka-consumer.auto-offset-reset=latest
|
|||
gateway-api.kafka-consumer.linger-ms=1
|
||||
gateway-api.kafka-consumer.buffer-memory=33554432
|
||||
|
||||
gateway-api.inbound-server.ssl=true
|
||||
gateway-api.inbound-server.enable-ssl=true
|
||||
gateway-api.inbound-server.host=localhost
|
||||
gateway-api.inbound-server.port=9999
|
||||
gateway-api.inbound-server.path=/inbound_request
|
||||
gateway-api.inbound-server.pathLOCM=/inbound_request
|
||||
gateway-api.inbound-server.pathLOSC=/inbound_request
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.gateway;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class GatewayTaskRequest {
|
||||
@JsonProperty
|
||||
public String task;
|
||||
|
||||
public String getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
public void setTask(String task) {
|
||||
this.task = task;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue