This commit is contained in:
parent
7aad3f4100
commit
102f6f7ce6
3 changed files with 384 additions and 0 deletions
|
|
@ -0,0 +1,64 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.account;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
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.*;
|
||||
import ru.spcex.clearing.backendapi.controller.queue.AbstractQueueController;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.BankAccountNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.account.BankAccountUpdateAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.response.BasicSpcexResponse;
|
||||
import ru.spcex.clearing.backendapi.controller.response.cud.CudResponse;
|
||||
import ru.spcex.clearing.backendapi.service.IOperator;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/securities/bank-accounts")
|
||||
public class BankAccountController extends AbstractQueueController {
|
||||
|
||||
@Autowired
|
||||
public BankAccountController(IOperator operator) {
|
||||
super(operator);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create bank account.")
|
||||
@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, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody BankAccountNewAction bankAccountNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_BANK_ACCOUNT_NEW, bankAccountNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update bank account.")
|
||||
@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)
|
||||
@ResponseBody
|
||||
public CudResponse update(
|
||||
@ApiParam(value = "Идентификатор изменяего объекта.", required = true, example = "1234")
|
||||
@PathVariable("id") Long id,
|
||||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody BankAccountUpdateAction bankAccountUpdateAction) throws ExecutionException, InterruptedException {
|
||||
bankAccountUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_BANK_ACCOUNT_UPDATE, bankAccountUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete bank account.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.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_BANK_ACCOUNT_DELETE, deleteAction);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.spcex.clearing.backendapi.domain.actions.IAction;
|
||||
import ru.spcex.clearing.backendapi.errors.BackEndError;
|
||||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.BankAccountNewRequest;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BankAccountNewAction implements IAction<BankAccountNewRequest> {
|
||||
|
||||
@ApiModelProperty(value = "Банковский идентификационный код (БИК)", example = "044525776")
|
||||
@JsonProperty
|
||||
private String bankIdentificationCode;
|
||||
@ApiModelProperty(value = "Наименование банка", example = "Beta Money Bank")
|
||||
@JsonProperty
|
||||
private String bankName;
|
||||
@ApiModelProperty(value = "Корреспондентский счет", example = "30101111111111111776")
|
||||
@JsonProperty
|
||||
private String correspondentAccount;
|
||||
@ApiModelProperty(value = "Наименование корреспондентского счета", example = "correspondent account name")
|
||||
@JsonProperty
|
||||
private String correspondentAccountName;
|
||||
@ApiModelProperty(value = "Идентификатор валюты", example = "RUB")
|
||||
@JsonProperty
|
||||
private String currency;
|
||||
@ApiModelProperty(value = "Назначение", example = "destination")
|
||||
@JsonProperty
|
||||
private String destination;
|
||||
@ApiModelProperty(value = "Идентификационный номер налогоплательщика (ИНН)", example = "3664011397")
|
||||
@JsonProperty
|
||||
private String taxpayerIdentificationNumber;
|
||||
@ApiModelProperty(value = "Код причины постановки (КПП)", example = "01")
|
||||
@JsonProperty
|
||||
private String taxRegistrationReasonCode;
|
||||
@ApiModelProperty(value = "Номер счета", example = "11111222223333344444")
|
||||
@JsonProperty
|
||||
private String account;
|
||||
|
||||
@Override
|
||||
public Collection<EnumMessage> validate() {
|
||||
if (!StringUtils.hasLength(this.bankIdentificationCode))
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "bankIdentificationCode"));
|
||||
if (!StringUtils.hasLength(this.bankName))
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "bankIdentificationCode"));
|
||||
if ("RUB".equalsIgnoreCase(this.currency) && !StringUtils.hasLength(correspondentAccount)) {
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "correspondentAccount"));
|
||||
}
|
||||
if ("RUB".equalsIgnoreCase(this.currency) && !StringUtils.hasLength(correspondentAccountName)) {
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "correspondentAccountName"));
|
||||
}
|
||||
if (!StringUtils.hasLength(currency)) {
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "currency"));
|
||||
}
|
||||
if (!StringUtils.hasLength(destination)) {
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "destination"));
|
||||
}
|
||||
if ("RUB".equalsIgnoreCase(this.currency) && !StringUtils.hasLength(taxpayerIdentificationNumber)) {
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "taxpayerIdentificationNumber"));
|
||||
}
|
||||
if ("RUB".equalsIgnoreCase(this.currency) && !StringUtils.hasLength(taxRegistrationReasonCode)) {
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "taxRegistrationReasonCode"));
|
||||
}
|
||||
if (!StringUtils.hasLength(account)) {
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "account"));
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankAccountNewRequest toRequest() {
|
||||
var req = new BankAccountNewRequest();
|
||||
req.setBankIdentificationCode(this.bankIdentificationCode);
|
||||
req.setBankName(this.bankName);
|
||||
req.setCorrespondentAccount(this.correspondentAccount);
|
||||
req.setCorrespondentAccountName(this.correspondentAccountName);
|
||||
req.setCurrency(this.currency);
|
||||
req.setDestination(this.destination);
|
||||
req.setTaxpayerIdentificationNumber(this.taxpayerIdentificationNumber);
|
||||
req.setTaxRegistrationReasonCode(this.taxRegistrationReasonCode);
|
||||
req.setAccount(this.account);
|
||||
return req;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.NEW;
|
||||
}
|
||||
|
||||
public String getBankIdentificationCode() {
|
||||
return bankIdentificationCode;
|
||||
}
|
||||
|
||||
public void setBankIdentificationCode(String bankIdentificationCode) {
|
||||
this.bankIdentificationCode = bankIdentificationCode;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return bankName;
|
||||
}
|
||||
|
||||
public void setBankName(String bankName) {
|
||||
this.bankName = bankName;
|
||||
}
|
||||
|
||||
public String getCorrespondentAccount() {
|
||||
return correspondentAccount;
|
||||
}
|
||||
|
||||
public void setCorrespondentAccount(String correspondentAccount) {
|
||||
this.correspondentAccount = correspondentAccount;
|
||||
}
|
||||
|
||||
public String getCorrespondentAccountName() {
|
||||
return correspondentAccountName;
|
||||
}
|
||||
|
||||
public void setCorrespondentAccountName(String correspondentAccountName) {
|
||||
this.correspondentAccountName = correspondentAccountName;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public void setDestination(String destination) {
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public String getTaxpayerIdentificationNumber() {
|
||||
return taxpayerIdentificationNumber;
|
||||
}
|
||||
|
||||
public void setTaxpayerIdentificationNumber(String taxpayerIdentificationNumber) {
|
||||
this.taxpayerIdentificationNumber = taxpayerIdentificationNumber;
|
||||
}
|
||||
|
||||
public String getTaxRegistrationReasonCode() {
|
||||
return taxRegistrationReasonCode;
|
||||
}
|
||||
|
||||
public void setTaxRegistrationReasonCode(String taxRegistrationReasonCode) {
|
||||
this.taxRegistrationReasonCode = taxRegistrationReasonCode;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.account;
|
||||
|
||||
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.account.BankAccountUpdateRequest;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class BankAccountUpdateAction implements IAction<BankAccountUpdateRequest> {
|
||||
@ApiModelProperty(hidden = true)
|
||||
@JsonProperty
|
||||
public Long id;
|
||||
@ApiModelProperty(value = "Банковский идентификационный код (БИК)", example = "044525776")
|
||||
@JsonProperty
|
||||
private String bankIdentificationCode;
|
||||
@ApiModelProperty(value = "Наименование банка", example = "Beta Money Bank")
|
||||
@JsonProperty
|
||||
private String bankName;
|
||||
@ApiModelProperty(value = "Корреспондентский счет", example = "30101111111111111776")
|
||||
@JsonProperty
|
||||
private String correspondentAccount;
|
||||
@ApiModelProperty(value = "Наименование корреспондентского счета", example = "correspondent account name")
|
||||
@JsonProperty
|
||||
private String correspondentAccountName;
|
||||
@ApiModelProperty(value = "Идентификатор валюты", example = "RUB")
|
||||
@JsonProperty
|
||||
private String currency;
|
||||
@ApiModelProperty(value = "Назначение", example = "destination")
|
||||
@JsonProperty
|
||||
private String destination;
|
||||
@ApiModelProperty(value = "Идентификационный номер налогоплательщика (ИНН)", example = "3664011397")
|
||||
@JsonProperty
|
||||
private String taxpayerIdentificationNumber;
|
||||
@ApiModelProperty(value = "Код причины постановки (КПП)", example = "01")
|
||||
@JsonProperty
|
||||
private String taxRegistrationReasonCode;
|
||||
@ApiModelProperty(value = "Номер счета", example = "11111222223333344444")
|
||||
@JsonProperty
|
||||
private String account;
|
||||
|
||||
@Override
|
||||
public Collection<EnumMessage> validate() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankAccountUpdateRequest toRequest() {
|
||||
var req = new BankAccountUpdateRequest();
|
||||
req.setId(this.id);
|
||||
req.setBankIdentificationCode(this.bankIdentificationCode);
|
||||
req.setBankName(this.bankName);
|
||||
req.setCorrespondentAccount(this.correspondentAccount);
|
||||
req.setCorrespondentAccountName(this.correspondentAccountName);
|
||||
req.setCurrency(this.currency);
|
||||
req.setDestination(this.destination);
|
||||
req.setTaxpayerIdentificationNumber(this.taxpayerIdentificationNumber);
|
||||
req.setTaxRegistrationReasonCode(this.taxRegistrationReasonCode);
|
||||
req.setAccount(this.account);
|
||||
return req;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.UPDATE;
|
||||
}
|
||||
|
||||
public String getBankIdentificationCode() {
|
||||
return bankIdentificationCode;
|
||||
}
|
||||
|
||||
public void setBankIdentificationCode(String bankIdentificationCode) {
|
||||
this.bankIdentificationCode = bankIdentificationCode;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return bankName;
|
||||
}
|
||||
|
||||
public void setBankName(String bankName) {
|
||||
this.bankName = bankName;
|
||||
}
|
||||
|
||||
public String getCorrespondentAccount() {
|
||||
return correspondentAccount;
|
||||
}
|
||||
|
||||
public void setCorrespondentAccount(String correspondentAccount) {
|
||||
this.correspondentAccount = correspondentAccount;
|
||||
}
|
||||
|
||||
public String getCorrespondentAccountName() {
|
||||
return correspondentAccountName;
|
||||
}
|
||||
|
||||
public void setCorrespondentAccountName(String correspondentAccountName) {
|
||||
this.correspondentAccountName = correspondentAccountName;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getDestination() {
|
||||
return destination;
|
||||
}
|
||||
|
||||
public void setDestination(String destination) {
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public String getTaxpayerIdentificationNumber() {
|
||||
return taxpayerIdentificationNumber;
|
||||
}
|
||||
|
||||
public void setTaxpayerIdentificationNumber(String taxpayerIdentificationNumber) {
|
||||
this.taxpayerIdentificationNumber = taxpayerIdentificationNumber;
|
||||
}
|
||||
|
||||
public String getTaxRegistrationReasonCode() {
|
||||
return taxRegistrationReasonCode;
|
||||
}
|
||||
|
||||
public void setTaxRegistrationReasonCode(String taxRegistrationReasonCode) {
|
||||
this.taxRegistrationReasonCode = taxRegistrationReasonCode;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue