http://jira.mfd.msk:8088/browse/CLS-256 backend-api. Юбилейный 256 таск :)
This commit is contained in:
parent
f71ae406a2
commit
0ea216fef2
11 changed files with 213 additions and 121 deletions
|
|
@ -20,4 +20,15 @@ public class AbstractQueueController {
|
|||
responseToClient.setMessage("success");
|
||||
return responseToClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Для оптимизации передачи userId
|
||||
*/
|
||||
protected <T> CudResponse processRequest(String destination, IAction<T> iAction, Long userId) throws ExecutionException, InterruptedException {
|
||||
CudResponse responseToClient = new CudResponse();
|
||||
responseToClient.setPayload(operator.sendRequestToQueue(destination, iAction, userId));
|
||||
responseToClient.setCode(0);
|
||||
responseToClient.setMessage("success");
|
||||
return responseToClient;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class EditCompanyInfoController extends AbstractQueueController {
|
|||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@ApiParam(value = "Идентификатор изменяемого объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody CompanyInfoUpdateAction companyInfoUpdateAction) throws ExecutionException, InterruptedException {
|
||||
|
|
|
|||
|
|
@ -7,13 +7,12 @@ import io.swagger.annotations.ApiResponses;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.clearing.classes.statics.data.profile.ProfileDocument;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ProfileDocumentNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.company.ProfileDocumentUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.entity.CommonGetAllResponse;
|
||||
|
|
@ -57,4 +56,28 @@ public class ProfileDocumentController extends AbstractQueueController {
|
|||
@RequestBody ProfileDocumentNewAction profileDocumentNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_PROFILE_DOCUMENT_NEW, profileDocumentNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update profile document.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody ProfileDocumentUpdateAction profileDocumentUpdateAction) throws ExecutionException, InterruptedException {
|
||||
profileDocumentUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_PROFILE_DOCUMENT_UPDATE, profileDocumentUpdateAction);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "delete profile document.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class)})
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@ResponseBody
|
||||
public CudResponse delete(@ApiParam(value = "Идентификатор удаляемого объекта", required = true, example = "1234")
|
||||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_PROFILE_DOCUMENT_DELETE, deleteAction);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,45 +11,42 @@ public class CompanyInfoUpdateAction implements IAction<CompanyInfoUpdateRequest
|
|||
@JsonProperty
|
||||
public Long id;
|
||||
|
||||
@ApiModelProperty(value = "Идентификатор единоличного исполнительного органа", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String corporationSoleType;
|
||||
@ApiModelProperty(value = "Идентификатор кода страны", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String countryCode;
|
||||
@ApiModelProperty(value = "Описание", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String description;
|
||||
@ApiModelProperty(value = "Признак проф. Участника", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String professionalSign;
|
||||
@ApiModelProperty(value = "Идентификатор вида субъекта", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String legalKind;
|
||||
@ApiModelProperty(value = "Идентификатор типа организации", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String organizationType;
|
||||
@ApiModelProperty(value = "Идентификатор кода страны", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String residence;
|
||||
@ApiModelProperty(value = "Краткое наименование Компании на английском", example = "Test Company Inc.")
|
||||
@JsonProperty
|
||||
private String shortNameEng;
|
||||
@ApiModelProperty(value = "Полное наименование Компании на английском", example = "Test Company Incorporated")
|
||||
@JsonProperty
|
||||
private String fullNameEng;
|
||||
@ApiModelProperty(value = "Краткое наименование Компании", example = "Test Company Incorporated")
|
||||
@ApiModelProperty(value = "Краткое наименование компании", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String shortName;
|
||||
@ApiModelProperty(value = "Полное наименование Компании", example = "Test Company Incorporated PlaceHolder Text Communication")
|
||||
@ApiModelProperty(value = "Полное наименование компании", example = "Test Компания Incorporated PlaceHolder Text Communication")
|
||||
@JsonProperty
|
||||
private String fullName;
|
||||
@ApiModelProperty(value = "Код участника торгов", example = "ABCD")
|
||||
@ApiModelProperty(value = "Юрисдикция", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String tradingCode;
|
||||
@ApiModelProperty(value = "Код участника клиринга", example = "ABCD")
|
||||
private String countryCode;
|
||||
@ApiModelProperty(value = "Единоличный исполнительный орган", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String clearingCode;
|
||||
private String corporationSoleType;
|
||||
@ApiModelProperty(value = "Вид субъекта", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String legalKind;
|
||||
@ApiModelProperty(value = "Тип организации", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String organizationType;
|
||||
@ApiModelProperty(value = "Резиденция (идентификатор кода страны)", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String residence;
|
||||
@ApiModelProperty(value = "Полное наименование компании на английском", example = "Test Company Incorporated")
|
||||
@JsonProperty
|
||||
private String fullNameEng;
|
||||
@ApiModelProperty(value = "Краткое наименование компании на английском", example = "Test Company Inc.")
|
||||
@JsonProperty
|
||||
private String shortNameEng;
|
||||
@ApiModelProperty(value = "Признак профессионального участника", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String professionalSign;
|
||||
@ApiModelProperty(value = "Описание компании", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String description;
|
||||
@ApiModelProperty(value = "Наименование статуса", example = "ACTV")
|
||||
@JsonProperty
|
||||
private String workflowStatus;
|
||||
|
||||
@Override
|
||||
public CompanyInfoUpdateRequest toRequest() {
|
||||
|
|
@ -66,8 +63,7 @@ public class CompanyInfoUpdateAction implements IAction<CompanyInfoUpdateRequest
|
|||
request.setFullNameEng(this.fullNameEng);
|
||||
request.setShortName(this.shortName);
|
||||
request.setFullName(this.fullName);
|
||||
request.setTradingCode(this.tradingCode);
|
||||
request.setClearingCode(this.clearingCode);
|
||||
request.setWorkflowStatus(workflowStatus);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
|
@ -173,19 +169,11 @@ public class CompanyInfoUpdateAction implements IAction<CompanyInfoUpdateRequest
|
|||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getTradingCode() {
|
||||
return tradingCode;
|
||||
public String getWorkflowStatus() {
|
||||
return workflowStatus;
|
||||
}
|
||||
|
||||
public void setTradingCode(String tradingCode) {
|
||||
this.tradingCode = tradingCode;
|
||||
}
|
||||
|
||||
public String getClearingCode() {
|
||||
return clearingCode;
|
||||
}
|
||||
|
||||
public void setClearingCode(String clearingCode) {
|
||||
this.clearingCode = clearingCode;
|
||||
public void setWorkflowStatus(String workflowStatus) {
|
||||
this.workflowStatus = workflowStatus;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.company;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.company.ProfileDocumentUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.LocalDateDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.LocalDateSerializer;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class ProfileDocumentUpdateAction implements IAction<ProfileDocumentUpdateRequest> {
|
||||
@ApiModelProperty(hidden = true)
|
||||
@JsonProperty
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "Идентификатор Компании", example = "123")
|
||||
@JsonProperty
|
||||
private Long companyId;
|
||||
@ApiModelProperty(value = "Идентификатор типа документа", example = "ABCD")
|
||||
@JsonProperty
|
||||
private String documentType;
|
||||
@ApiModelProperty(value = "Дата выдачи", example = "2022-12-25")
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalDate issueDate;
|
||||
@ApiModelProperty(value = "Место выдачи", example = "Example string")
|
||||
@JsonProperty
|
||||
private String issuePlace;
|
||||
@ApiModelProperty(value = "Кем выдан", example = "Example string")
|
||||
@JsonProperty
|
||||
private String issuer;
|
||||
@ApiModelProperty(value = "Код выдавшего органа", example = "Example string")
|
||||
@JsonProperty
|
||||
private String issuerCode;
|
||||
@ApiModelProperty(value = "Наименование", example = "Example string")
|
||||
@JsonProperty
|
||||
private String name;
|
||||
@ApiModelProperty(value = "Номер", example = "Example string")
|
||||
@JsonProperty
|
||||
private String number;
|
||||
@ApiModelProperty(value = "Место", example = "Example string")
|
||||
@JsonProperty
|
||||
private String place;
|
||||
@ApiModelProperty(value = "Дата начала срока действия", example = "2022-12-25")
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalDate validFromDate;
|
||||
@ApiModelProperty(value = "Дата окончания срока действия", example = "2022-12-25")
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonProperty
|
||||
private LocalDate validToDate;
|
||||
@ApiModelProperty(value = "Ссылка на документ", example = "Example string")
|
||||
@JsonProperty
|
||||
private String link;
|
||||
|
||||
@Override
|
||||
public ProfileDocumentUpdateRequest toRequest() {
|
||||
ProfileDocumentUpdateRequest request = new ProfileDocumentUpdateRequest();
|
||||
request.setId(this.id);
|
||||
request.setCompanyId(this.companyId);
|
||||
request.setDocumentType(this.documentType);
|
||||
request.setIssueDate(this.issueDate);
|
||||
request.setIssuePlace(this.issuePlace);
|
||||
request.setIssuer(this.issuer);
|
||||
request.setIssuerCode(this.issuerCode);
|
||||
request.setName(this.name);
|
||||
request.setNumber(this.number);
|
||||
request.setPlace(this.place);
|
||||
request.setValidFromDate(this.validFromDate);
|
||||
request.setValidToDate(this.validToDate);
|
||||
request.setLink(this.link);
|
||||
return request;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.UPDATE;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
|
@ -60,13 +60,8 @@ public class CompanyBackendGetAll extends BasicSpcexResponse {
|
|||
singleItem.setLegalKind(profile.getLegalKind());
|
||||
singleItem.setOrganizationType(profile.getOrganizationType());
|
||||
singleItem.setResidence(profile.getResidence());
|
||||
singleItem.setShortName(profile.getShortName());
|
||||
singleItem.setFullName(profile.getFullName());
|
||||
singleItem.setShortNameEng(profile.getShortNameEng());
|
||||
singleItem.setFullNameEng(profile.getFullNameEng());
|
||||
singleItem.setTradingCode(profile.getTradingCode());
|
||||
singleItem.setClearingCode(profile.getClearingCode());
|
||||
singleItem.setRegistrationCode(profile.getRegistrationCode());
|
||||
}
|
||||
payload.getItems().add(singleItem);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,13 +50,8 @@ public class CompanyBackendInfoGetAll extends BasicSpcexResponse {
|
|||
singleItem.setLegalKind(companyInfo.getLegalKind());
|
||||
singleItem.setOrganizationType(companyInfo.getOrganizationType());
|
||||
singleItem.setResidence(companyInfo.getResidence());
|
||||
singleItem.setShortName(companyInfo.getShortName());
|
||||
singleItem.setFullName(companyInfo.getFullName());
|
||||
singleItem.setShortNameEng(companyInfo.getShortNameEng());
|
||||
singleItem.setFullNameEng(companyInfo.getFullNameEng());
|
||||
singleItem.setTradingCode(companyInfo.getTradingCode());
|
||||
singleItem.setClearingCode(companyInfo.getClearingCode());
|
||||
singleItem.setRegistrationCode(companyInfo.getRegistrationCode());
|
||||
payload.getItems().add(singleItem);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,17 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
public interface IOperator {
|
||||
QueueSuccessResponse sendRequestToQueue(String destination, IAction<?> iAction, boolean appendUserId) throws ExecutionException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Для оптимизации проставления userId.
|
||||
* Аналог sendRequestToQueue(String destination, IAction<?> iAction, true)
|
||||
*
|
||||
* @param destination
|
||||
* @param iAction
|
||||
* @param userId совершивший запрос
|
||||
* @return
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
QueueSuccessResponse sendRequestToQueue(String destination, IAction<?> iAction, Long userId) throws ExecutionException, InterruptedException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import ru.spcex.platform.imdg.api.Imdg;
|
|||
import ru.spcex.platform.imdg.api.ImdgId;
|
||||
import ru.spcex.platform.imdg.api.ImdgProvider;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.log.ExceptionUtils;
|
||||
import ru.spcex.platform.utils.validation.IValidator;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -80,6 +81,25 @@ public class OperatorImpl implements IOperator {
|
|||
return new QueueSuccessResponse(request.getActionType(), request.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueueSuccessResponse sendRequestToQueue(String destination, IAction<?> iAction, Long userId) throws ExecutionException, InterruptedException {
|
||||
throwValidate(destination, iAction);
|
||||
BaseRequest<Object> request = new BaseRequest<>();
|
||||
request.setId(idGenerator.nextId());
|
||||
request.setActionType(iAction.getActionType());
|
||||
request.setRequestPayload(iAction.toRequest());
|
||||
if (userId == null) {
|
||||
log.warn("userId not set, Stacktrace: {}", ExceptionUtils.getStackTrace(new IllegalArgumentException("Empty userId")));
|
||||
} else {
|
||||
request.setUserId(userId);
|
||||
}
|
||||
//сохраняет данные о запросе в хранилище
|
||||
saveRequestToStorage(destination, request);
|
||||
Future<RecordMetadata> send = kafka.send(new ProducerRecord<>(destination, request));
|
||||
send.get();
|
||||
return new QueueSuccessResponse(request.getActionType(), request.getId());
|
||||
}
|
||||
|
||||
private void saveRequestToStorage(String destination, BaseRequest<Object> request) {
|
||||
Imdg<RequestInfo> requestStorage = imdgProvider.getImdg(IMDGDistributedNames.Map_RequestInfo, RequestInfo.class);
|
||||
RequestInfo requestInfo = RequestInfo.create(request.getId());
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@ public class CompanyInfo extends SpcexObjectBase {
|
|||
private String legalKind; // ref CHAR(4),
|
||||
private String organizationType; // ref CHAR(4),
|
||||
private String residence; // ref CHAR(4),
|
||||
private String shortName;
|
||||
private String fullName;
|
||||
// private String shortName; // extends Company
|
||||
// private String fullName; // extends Company
|
||||
private String shortNameEng;
|
||||
private String fullNameEng;
|
||||
private String tradingCode;
|
||||
private String clearingCode;
|
||||
private String registrationCode;
|
||||
// private String tradingCode; // extends Company
|
||||
// private String clearingCode; // extends Company
|
||||
// private String registrationCode; // extends Company
|
||||
// private String workflowStatus; // extends Company
|
||||
|
||||
public Long getCompanyId() {
|
||||
return companyId;
|
||||
|
|
@ -89,22 +90,6 @@ public class CompanyInfo extends SpcexObjectBase {
|
|||
this.residence = residence;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setShortName(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getShortNameEng() {
|
||||
return shortNameEng;
|
||||
}
|
||||
|
|
@ -121,27 +106,4 @@ public class CompanyInfo extends SpcexObjectBase {
|
|||
this.fullNameEng = fullNameEng;
|
||||
}
|
||||
|
||||
public String getTradingCode() {
|
||||
return tradingCode;
|
||||
}
|
||||
|
||||
public void setTradingCode(String tradingCode) {
|
||||
this.tradingCode = tradingCode;
|
||||
}
|
||||
|
||||
public String getClearingCode() {
|
||||
return clearingCode;
|
||||
}
|
||||
|
||||
public void setClearingCode(String clearingCode) {
|
||||
this.clearingCode = clearingCode;
|
||||
}
|
||||
|
||||
public String getRegistrationCode() {
|
||||
return registrationCode;
|
||||
}
|
||||
|
||||
public void setRegistrationCode(String registrationCode) {
|
||||
this.registrationCode = registrationCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,9 +29,7 @@ public class CompanyInfoUpdateRequest {
|
|||
@JsonProperty
|
||||
private String fullName;
|
||||
@JsonProperty
|
||||
private String tradingCode;
|
||||
@JsonProperty
|
||||
private String clearingCode;
|
||||
private String workflowStatus;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
|
@ -129,19 +127,11 @@ public class CompanyInfoUpdateRequest {
|
|||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getTradingCode() {
|
||||
return tradingCode;
|
||||
public String getWorkflowStatus() {
|
||||
return workflowStatus;
|
||||
}
|
||||
|
||||
public void setTradingCode(String tradingCode) {
|
||||
this.tradingCode = tradingCode;
|
||||
}
|
||||
|
||||
public String getClearingCode() {
|
||||
return clearingCode;
|
||||
}
|
||||
|
||||
public void setClearingCode(String clearingCode) {
|
||||
this.clearingCode = clearingCode;
|
||||
public void setWorkflowStatus(String workflowStatus) {
|
||||
this.workflowStatus = workflowStatus;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue