backend-api мелкий рефакторинг 4

This commit is contained in:
AKurakin 2023-05-12 12:21:47 +03:00
parent ee79336ce4
commit e13968a148
17 changed files with 277 additions and 33 deletions

View file

@ -10,6 +10,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import ru.clearing.classes.statics.data.profile.Contact;
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
import ru.spcex.clearing.backendapi.controller.request.cud.company.ContactNewAction;
import ru.spcex.clearing.backendapi.controller.request.cud.company.ContactUpdateAction;
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
@ -47,6 +48,16 @@ public class ContactController extends AbstractQueueController {
return processRequest(Consts.DESTINATION_CONTACT_UPDATE, contactUpdateAction);
}
@ApiOperation(value = "create company contact.")
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public CudResponse create(
@ApiParam(value = "Значения полей нового объекта.", required = true)
@RequestBody ContactNewAction contactNewAction) throws ExecutionException, InterruptedException {
return processRequest(Consts.DESTINATION_CONTACT_NEW, contactNewAction);
}
@ApiOperation(value = "get all Contacts.")
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CommonGetAllResponse.class)})
@RequestMapping(method = RequestMethod.GET)

View file

@ -0,0 +1,60 @@
package ru.spcex.clearing.backendapi.controller.request.cud.company;
import com.fasterxml.jackson.annotation.JsonProperty;
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.ContactNewRequest;
import ru.spcex.clearing.platform.messaging.domain.cud.company.ContactUpdateRequest;
public class ContactNewAction implements IAction<ContactNewRequest> {
@ApiModelProperty(value = "Наименование компании", example = "ABCD")
@JsonProperty
private Long companyId;
@ApiModelProperty(value = "Идентификатор справочника", example = "ABCD")
@JsonProperty
private String contactType;
@ApiModelProperty(value = "Значение справочника", example = "example contact string")
@JsonProperty
private String contactValue;
@Override
public ContactNewRequest toRequest() {
ContactNewRequest request = new ContactNewRequest();
request.setCompanyId(this.companyId);
request.setContactType(this.contactType);
request.setContactValue(this.contactValue);
return request;
}
@ApiModelProperty(hidden = true)
@Override
public ActionType getActionType() {
return ActionType.NEW;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
public String getContactType() {
return contactType;
}
public void setContactType(String contactType) {
this.contactType = contactType;
}
public String getContactValue() {
return contactValue;
}
public void setContactValue(String contactValue) {
this.contactValue = contactValue;
}
}

View file

@ -14,13 +14,13 @@ import java.util.Collections;
import java.util.List;
public class LauncherNew implements IAction<Object> {
@ApiModelProperty(value = "Идентификатор единоличного исполнительного органа", example = "ABCD")
@ApiModelProperty(value = "Код задачи", example = "ABCD")
@JsonProperty
private String task;
@ApiModelProperty(value = "Идентификатор инициатора", example = "1000")
@ApiModelProperty(value = "Наименование инициатора", example = "1000")
@JsonProperty
private Long companyId;
@ApiModelProperty(value = "Идентификатор инструмента", example = "1000")
@ApiModelProperty(value = "Наименование инструмента", example = "1000")
@JsonProperty
private Long securityId;
@JsonIgnore

View file

@ -40,7 +40,11 @@ public class PlannerNewAction implements IAction<PlannerNewRequest> {
@ApiModelProperty(value = "Секция", example = "ABCD")
@JsonProperty
public String market;
public String section;
@ApiModelProperty(value = "Тип клиринговой сессии", example = "ABCD")
@JsonProperty
public String sessionType;
@ApiModelProperty(value = "Статус", example = "ABCD")
@JsonProperty
@ -60,7 +64,8 @@ public class PlannerNewAction implements IAction<PlannerNewRequest> {
plannerNewRequest.setTask(task);
plannerNewRequest.setTaskTime(taskTime);
plannerNewRequest.setClearingDate(clearingDate);
plannerNewRequest.setMarket(market);
plannerNewRequest.setSection(section);
plannerNewRequest.setSessionType(sessionType);
plannerNewRequest.setTaskStatus(taskStatus);
plannerNewRequest.setCompanyId(companyId);
plannerNewRequest.setSecurityId(securityId);
@ -115,12 +120,28 @@ public class PlannerNewAction implements IAction<PlannerNewRequest> {
this.clearingDate = clearingDate;
}
public String getMarket() {
return market;
public String getSection() {
return section;
}
public void setMarket(String market) {
this.market = market;
public void setSection(String section) {
this.section = section;
}
public String getSessionType() {
return sessionType;
}
public void setSessionType(String sessionType) {
this.sessionType = sessionType;
}
public Long getCompanyId() {
return companyId;
}
public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
public String getTaskStatus() {

View file

@ -27,6 +27,12 @@ public class PlannerTemplateNewAction implements IAction<PlannerTemplateNewReque
@JsonDeserialize(using = LocalTimeDeserializer.class)
@JsonProperty
public LocalTime taskTime;
@ApiModelProperty(value = "Секция", example = "ABCD")
@JsonProperty
public String section;
@ApiModelProperty(value = "Тип клиринговой сессии", example = "ABCD")
@JsonProperty
public String sessionType;
@ApiModelProperty(value = "Статус", example = "ACTV")
@JsonProperty
public String taskStatus;
@ -42,6 +48,8 @@ public class PlannerTemplateNewAction implements IAction<PlannerTemplateNewReque
PlannerTemplateNewRequest plannerTemplateNewRequest = new PlannerTemplateNewRequest();
plannerTemplateNewRequest.setTask(task);
plannerTemplateNewRequest.setTaskTime(taskTime);
plannerTemplateNewRequest.setSection(section);
plannerTemplateNewRequest.setSessionType(sessionType);
plannerTemplateNewRequest.setTaskStatus(taskStatus);
plannerTemplateNewRequest.setCompanyId(companyId);
plannerTemplateNewRequest.setSecurityId(securityId);
@ -108,4 +116,20 @@ public class PlannerTemplateNewAction implements IAction<PlannerTemplateNewReque
public void setSecurityId(Long securityId) {
this.securityId = securityId;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public String getSessionType() {
return sessionType;
}
public void setSessionType(String sessionType) {
this.sessionType = sessionType;
}
}

View file

@ -31,6 +31,12 @@ public class PlannerTemplateUpdateAction implements IAction<PlannerTemplateUpdat
@JsonDeserialize(using = LocalTimeDeserializer.class)
@JsonProperty
public LocalTime taskTime;
@ApiModelProperty(value = "Секция", example = "ABCD")
@JsonProperty
public String section;
@ApiModelProperty(value = "Тип клиринговой сессии", example = "ABCD")
@JsonProperty
public String sessionType;
@ApiModelProperty(value = "Статус", example = "ACTV")
@JsonProperty
public String taskStatus;
@ -47,6 +53,8 @@ public class PlannerTemplateUpdateAction implements IAction<PlannerTemplateUpdat
plannerTemplateUpdateRequest.setId(id);
plannerTemplateUpdateRequest.setTask(task);
plannerTemplateUpdateRequest.setTaskTime(taskTime);
plannerTemplateUpdateRequest.setSection(section);
plannerTemplateUpdateRequest.setSessionType(sessionType);
plannerTemplateUpdateRequest.setTaskStatus(taskStatus);
plannerTemplateUpdateRequest.setCompanyId(companyId);
plannerTemplateUpdateRequest.setSecurityId(securityId);
@ -125,4 +133,20 @@ public class PlannerTemplateUpdateAction implements IAction<PlannerTemplateUpdat
public void setSecurityId(Long securityId) {
this.securityId = securityId;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public String getSessionType() {
return sessionType;
}
public void setSessionType(String sessionType) {
this.sessionType = sessionType;
}
}

View file

@ -45,7 +45,11 @@ public class PlannerUpdateAction implements IAction<PlannerUpdateRequest>, WithI
@ApiModelProperty(value = "Секция", example = "ABCD")
@JsonProperty
public String market;
public String section;
@ApiModelProperty(value = "Тип клиринговой сессии", example = "ABCD")
@JsonProperty
public String sessionType;
@ApiModelProperty(value = "Статус", example = "ABCD")
@JsonProperty
@ -66,7 +70,8 @@ public class PlannerUpdateAction implements IAction<PlannerUpdateRequest>, WithI
plannerUpdateRequest.setTask(task);
plannerUpdateRequest.setTaskTime(taskTime);
plannerUpdateRequest.setClearingDate(clearingDate);
plannerUpdateRequest.setMarket(market);
plannerUpdateRequest.setSection(section);
plannerUpdateRequest.setSessionType(sessionType);
plannerUpdateRequest.setTaskStatus(taskStatus);
plannerUpdateRequest.setCompanyId(companyId);
plannerUpdateRequest.setSecurityId(securityId);
@ -133,12 +138,20 @@ public class PlannerUpdateAction implements IAction<PlannerUpdateRequest>, WithI
this.clearingDate = clearingDate;
}
public String getMarket() {
return market;
public String getSection() {
return section;
}
public void setMarket(String market) {
this.market = market;
public void setSection(String section) {
this.section = section;
}
public String getSessionType() {
return sessionType;
}
public void setSessionType(String sessionType) {
this.sessionType = sessionType;
}
public String getTaskStatus() {

View file

@ -8,6 +8,7 @@ import ru.clearing.classes.statics.data.profile.Contact;
import ru.spcex.clearing.backendapi.controller.queue.AbstractControllerTest;
import ru.spcex.clearing.backendapi.controller.request.cud.company.ClearingMemberCategoryNewAction;
import ru.spcex.clearing.backendapi.controller.request.cud.company.CompanySymbolUpdateAction;
import ru.spcex.clearing.backendapi.controller.request.cud.company.ContactNewAction;
import ru.spcex.clearing.backendapi.controller.request.cud.company.ContactUpdateAction;
import ru.spcex.clearing.backendapi.domain.actions.IAction;
import ru.spcex.clearing.backendapi.errors.ActionValidationException;
@ -35,6 +36,28 @@ class ContactControllerTest extends AbstractControllerTest {
assertThrowsFor(getClearingMemberCategoryNewAction("", 0L));
}
/**
* {@link ContactController#create(Long, ContactNewAction)}<br>
* Тест проверяет получение сущности {@link ContactNewAction} по REST API и отправку в Apache Kafka.<br>
* Входной запрос {@link ContactNewAction}:<br>
* {@link ContactNewAction#contactType} - ContactType<br>
* {@link ContactNewAction#contactValue} - ContactValue<br>
* {@link ContactNewAction#id} - currentId<br>
*/
@Test
void create() throws Exception {
//ARRANGE
ContactNewAction companySymbolNewAction = new ContactNewAction();
companySymbolNewAction.setContactType("ContactType");
companySymbolNewAction.setContactValue("ContactValue");
companySymbolNewAction.setCompanyId(currentId.get());
//ACT and ASSERT
checkAddingByRestApi(REST_URL, companySymbolNewAction);
checkSendedMessegeFromKafka(Consts.DESTINATION_CONTACT_NEW, companySymbolNewAction);
}
/**
* {@link ContactController#update(Long, ContactUpdateAction)}<br>
* Тест проверяет получение сущности {@link ContactUpdateAction} по REST API и отправку в Apache Kafka.<br>

View file

@ -49,8 +49,8 @@ public class PlannerValidationConfig {
TimeNotBeforeRule.instance("taskTime",
PlannerNewRequest::getTaskTime,
LocalDate.now().equals(plannerNewRequest.getClearingDate())),
EnumPresentRule.instance("market",
PlannerNewRequest::getMarket,
EnumPresentRule.instance("section",
PlannerNewRequest::getSection,
Market.values(),
false),
DictionaryPresentRule.instance("taskStatus",
@ -104,8 +104,8 @@ public class PlannerValidationConfig {
DateNotBeforeRule.instance("clearingDate",
PlannerUpdateRequest::getClearingDate,
false),
EnumPresentRule.instance("market",
PlannerUpdateRequest::getMarket,
EnumPresentRule.instance("section",
PlannerUpdateRequest::getSection,
Market.values(),
false),
DictionaryPresentRule.instance("taskStatus",

View file

@ -95,7 +95,7 @@ public class PlannerService extends QueueConsumer implements InitializingBean {
planner.setTask(req.getTask());
planner.setTaskTime(req.getTaskTime());
planner.setClearingDate(req.getClearingDate());
planner.setMarket(req.getMarket());
planner.setMarket(req.getSection());
planner.setTaskStatus(req.getTaskStatus());
planner.setCompanyId(req.getCompanyId());
planner.setSecurityId(req.getSecurityId());
@ -122,7 +122,7 @@ public class PlannerService extends QueueConsumer implements InitializingBean {
planner.setTask(req.getTask());
planner.setTaskTime(req.getTaskTime());
planner.setClearingDate(req.getClearingDate());
planner.setMarket(req.getMarket());
planner.setMarket(req.getSection());
planner.setTaskStatus(req.getTaskStatus());
planner.setCompanyId(req.getCompanyId());
planner.setSecurityId(req.getSecurityId());

View file

@ -11,6 +11,7 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import ru.clearing.classes.statics.data.company.Company;
import ru.clearing.classes.statics.data.misc.Market;
import ru.clearing.classes.statics.data.scheduler.*;
import ru.clearing.classes.statics.data.security.Security;
import ru.clearing.platform.dictionary.DayStatusDictionary;
@ -140,6 +141,8 @@ public abstract class AbstractServiceTest {
plannerTemplate.setTask(Task.accountBlock.getKey());
plannerTemplate.setTaskTime(LocalTime.now().plusHours(1).withNano(0));
plannerTemplate.setTaskStatus(Status.Active.getKey());
plannerTemplate.setSection("BMIC");
plannerTemplate.setSessionType("FINL");
plannerTemplate.setCompanyId(companyId);
plannerTemplate.setSecurityId(testSecurityId);
return plannerTemplate;

View file

@ -59,7 +59,7 @@ class PlannerServiceTest extends AbstractServiceTest {
plannerNewRequest.setTaskTime(planner.getTaskTime());
plannerNewRequest.setTaskStatus(planner.getTaskStatus());
plannerNewRequest.setClearingDate(planner.getClearingDate());
plannerNewRequest.setMarket(planner.getMarket());
plannerNewRequest.setSection(planner.getMarket());
plannerNewRequest.setCompanyId(planner.getCompanyId());
plannerNewRequest.setSecurityId(planner.getSecurityId());
@ -94,7 +94,7 @@ class PlannerServiceTest extends AbstractServiceTest {
plannerUpdateRequest.setTaskTime(planner.getTaskTime());
plannerUpdateRequest.setTaskStatus(planner.getTaskStatus());
plannerUpdateRequest.setClearingDate(planner.getClearingDate());
plannerUpdateRequest.setMarket(planner.getMarket());
plannerUpdateRequest.setSection(planner.getMarket());
plannerUpdateRequest.setCompanyId(planner.getCompanyId());
plannerUpdateRequest.setSecurityId(planner.getSecurityId());

View file

@ -50,6 +50,8 @@ class PlannerTemplateServiceTest extends AbstractServiceTest {
PlannerTemplateNewRequest templateNewRequest = new PlannerTemplateNewRequest();
templateNewRequest.setTask(plannerTemplate.getTask());
templateNewRequest.setTaskTime(plannerTemplate.getTaskTime());
templateNewRequest.setSection(plannerTemplate.getSection());
templateNewRequest.setSessionType(plannerTemplate.getSessionType());
templateNewRequest.setTaskStatus(plannerTemplate.getTaskStatus());
templateNewRequest.setCompanyId(plannerTemplate.getCompanyId());
templateNewRequest.setSecurityId(plannerTemplate.getSecurityId());
@ -83,6 +85,8 @@ class PlannerTemplateServiceTest extends AbstractServiceTest {
plannerTemplateUpdateRequest.setId(plannerTemplate.getId());
plannerTemplateUpdateRequest.setTask(plannerTemplate.getTask());
plannerTemplateUpdateRequest.setTaskTime(plannerTemplate.getTaskTime());
plannerTemplateUpdateRequest.setSection(plannerTemplate.getSection());
plannerTemplateUpdateRequest.setSessionType(plannerTemplate.getSessionType());
plannerTemplateUpdateRequest.setTaskStatus(plannerTemplate.getTaskStatus());
plannerTemplateUpdateRequest.setCompanyId(plannerTemplate.getCompanyId());
plannerTemplateUpdateRequest.setSecurityId(plannerTemplate.getSecurityId());

View file

@ -27,7 +27,10 @@ public class PlannerNewRequest {
public LocalDate clearingDate;
@JsonProperty
public String market;
public String section;
@JsonProperty
public String sessionType;
@JsonProperty
public String taskStatus;
@ -62,12 +65,20 @@ public class PlannerNewRequest {
this.clearingDate = clearingDate;
}
public String getMarket() {
return market;
public String getSection() {
return section;
}
public void setMarket(String market) {
this.market = market;
public void setSection(String section) {
this.section = section;
}
public String getSessionType() {
return sessionType;
}
public void setSessionType(String sessionType) {
this.sessionType = sessionType;
}
public String getTaskStatus() {

View file

@ -17,6 +17,10 @@ public class PlannerTemplateNewRequest {
@JsonProperty
public LocalTime taskTime;
@JsonProperty
public String section;
@JsonProperty
public String sessionType;
@JsonProperty
public String taskStatus;
@JsonProperty
public Long companyId;
@ -47,6 +51,22 @@ public class PlannerTemplateNewRequest {
this.taskStatus = taskStatus;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public String getSessionType() {
return sessionType;
}
public void setSessionType(String sessionType) {
this.sessionType = sessionType;
}
public Long getCompanyId() {
return companyId;
}

View file

@ -20,6 +20,10 @@ public class PlannerTemplateUpdateRequest {
@JsonProperty
public LocalTime taskTime;
@JsonProperty
public String section;
@JsonProperty
public String sessionType;
@JsonProperty
public String taskStatus;
@JsonProperty
public Long companyId;
@ -50,6 +54,22 @@ public class PlannerTemplateUpdateRequest {
this.taskStatus = taskStatus;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public String getSessionType() {
return sessionType;
}
public void setSessionType(String sessionType) {
this.sessionType = sessionType;
}
public Long getId() {
return id;
}

View file

@ -26,7 +26,9 @@ public class PlannerUpdateRequest {
@JsonProperty
public LocalDate clearingDate;
@JsonProperty
public String market;
public String section;
@JsonProperty
public String sessionType;
@JsonProperty
public String taskStatus;
@JsonProperty
@ -66,12 +68,20 @@ public class PlannerUpdateRequest {
this.clearingDate = clearingDate;
}
public String getMarket() {
return market;
public String getSection() {
return section;
}
public void setMarket(String market) {
this.market = market;
public void setSection(String section) {
this.section = section;
}
public String getSessionType() {
return sessionType;
}
public void setSessionType(String sessionType) {
this.sessionType = sessionType;
}
public String getTaskStatus() {