This commit is contained in:
parent
a4de8e691b
commit
3c65d00bfb
6 changed files with 372 additions and 0 deletions
|
|
@ -0,0 +1,64 @@
|
|||
package ru.spcex.clearing.backendapi.controller.queue.utilities;
|
||||
|
||||
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.common.CommonDeleteAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.utilities.KeyRateNewAction;
|
||||
import ru.spcex.clearing.backendapi.controller.request.cud.utilities.KeyRateUpdateAction;
|
||||
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("/utilities/key-rates")
|
||||
public class CudKeyRateController extends AbstractQueueController {
|
||||
|
||||
@Autowired
|
||||
public CudKeyRateController(IOperator operator) {
|
||||
super(operator);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "create key rate.")
|
||||
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
|
||||
@RequestMapping(value = "/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody KeyRateNewAction keyRateNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_KEY_RATE_NEW, keyRateNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update key rate.")
|
||||
@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 KeyRateUpdateAction keyRateUpdateAction) throws ExecutionException, InterruptedException {
|
||||
keyRateUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_KEY_RATE_UPDATE, keyRateUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete key rate.")
|
||||
@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_KEY_RATE_DELETE, deleteAction);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.utilities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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.utilities.KeyRateNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.InstantDeserializer;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class KeyRateNewAction implements IAction<KeyRateNewRequest> {
|
||||
@ApiModelProperty(value = "Ключевая ставка ЦБ РФ", example = "12.5")
|
||||
@JsonProperty
|
||||
public Double keyRate;
|
||||
@ApiModelProperty(value = "Дата начала действия ключевой ставки", example = "2022-01-20")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "Europe/Moscow")
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
@JsonProperty
|
||||
public Instant startDate;
|
||||
@ApiModelProperty(value = "Дата окончания действия ключевой ставки", example = "2022-04-20")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "Europe/Moscow")
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
@JsonProperty
|
||||
public Instant endDate;
|
||||
@ApiModelProperty(value = "Документ ЦБ", example = "Lorem ipsum")
|
||||
@JsonProperty
|
||||
public String document;
|
||||
|
||||
@Override
|
||||
public Collection<EnumMessage> validate() {
|
||||
if (this.startDate == null)
|
||||
return List.of(new EnumMessage(BackEndError.ValidationError, "startDate"));
|
||||
else return Collections.emptyList();
|
||||
}
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.NEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyRateNewRequest toRequest() {
|
||||
var req = new KeyRateNewRequest();
|
||||
req.setStartDate(this.getStartDate());
|
||||
req.setEndDate(this.getEndDate());
|
||||
req.setKeyRate(this.getKeyRate());
|
||||
req.setDocument(this.getDocument());
|
||||
return req;
|
||||
}
|
||||
|
||||
public Double getKeyRate() {
|
||||
return keyRate;
|
||||
}
|
||||
|
||||
public void setKeyRate(Double keyRate) {
|
||||
this.keyRate = keyRate;
|
||||
}
|
||||
|
||||
public Instant getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Instant startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Instant getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Instant endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public void setDocument(String document) {
|
||||
this.document = document;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package ru.spcex.clearing.backendapi.controller.request.cud.utilities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
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.utilities.KeyRateUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.InstantDeserializer;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class KeyRateUpdateAction implements IAction<KeyRateUpdateRequest> {
|
||||
@ApiModelProperty(hidden = true)
|
||||
@JsonProperty
|
||||
public Long id;
|
||||
@ApiModelProperty(value = "Ключевая ставка ЦБ РФ", example = "12.5")
|
||||
@JsonProperty
|
||||
public Double keyRate;
|
||||
@ApiModelProperty(value = "Дата начала действия ключевой ставки", example = "2022-01-20")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "Europe/Moscow")
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
@JsonProperty
|
||||
public Instant startDate;
|
||||
@ApiModelProperty(value = "Дата окончания действия ключевой ставки", example = "2022-04-20")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "Europe/Moscow")
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
@JsonProperty
|
||||
public Instant endDate;
|
||||
@ApiModelProperty(value = "Документ ЦБ", example = "Lorem ipsum")
|
||||
@JsonProperty
|
||||
public String document;
|
||||
|
||||
@ApiModelProperty(hidden = true)
|
||||
@Override
|
||||
public ActionType getActionType() {
|
||||
return ActionType.UPDATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyRateUpdateRequest toRequest() {
|
||||
var req = new KeyRateUpdateRequest();
|
||||
req.setId(this.getId());
|
||||
req.setStartDate(this.getStartDate());
|
||||
req.setEndDate(this.getEndDate());
|
||||
req.setKeyRate(this.getKeyRate());
|
||||
req.setDocument(this.getDocument());
|
||||
return req;
|
||||
}
|
||||
|
||||
public Double getKeyRate() {
|
||||
return keyRate;
|
||||
}
|
||||
|
||||
public void setKeyRate(Double keyRate) {
|
||||
this.keyRate = keyRate;
|
||||
}
|
||||
|
||||
public Instant getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Instant startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Instant getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Instant endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setDocument(String document) {
|
||||
this.document = document;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,4 +4,8 @@ public interface Consts {
|
|||
String DESTINATION_MONEY_MARKET_SECURITY_NEW = "money-market-security-new";
|
||||
String DESTINATION_MONEY_MARKET_SECURITY_UPDATE = "money-market-security-update";
|
||||
String DESTINATION_MONEY_MARKET_SECURITY_DELETE = "money-market-security-delete";
|
||||
|
||||
String DESTINATION_KEY_RATE_NEW = "key-rate-new";
|
||||
String DESTINATION_KEY_RATE_UPDATE = "key-rate-update";
|
||||
String DESTINATION_KEY_RATE_DELETE = "key-rate-delete";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.utilities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.InstantDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.InstantSerializer;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class KeyRateNewRequest {
|
||||
@JsonProperty
|
||||
public Double keyRate;
|
||||
@JsonSerialize(using = InstantSerializer.class)
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
@JsonProperty
|
||||
public Instant startDate;
|
||||
@JsonSerialize(using = InstantSerializer.class)
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
@JsonProperty
|
||||
public Instant endDate;
|
||||
@JsonProperty
|
||||
public String document;
|
||||
|
||||
public Double getKeyRate() {
|
||||
return keyRate;
|
||||
}
|
||||
|
||||
public void setKeyRate(Double keyRate) {
|
||||
this.keyRate = keyRate;
|
||||
}
|
||||
|
||||
public Instant getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Instant startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Instant getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Instant endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public void setDocument(String document) {
|
||||
this.document = document;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package ru.spcex.clearing.platform.messaging.domain.cud.utilities;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.deserialize.InstantDeserializer;
|
||||
import ru.spcex.clearing.platform.messaging.domain.json.serialize.InstantSerializer;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public class KeyRateUpdateRequest {
|
||||
@JsonProperty
|
||||
public Long id;
|
||||
@JsonProperty
|
||||
public Double keyRate;
|
||||
@JsonSerialize(using = InstantSerializer.class)
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
@JsonProperty
|
||||
public Instant startDate;
|
||||
@JsonSerialize(using = InstantSerializer.class)
|
||||
@JsonDeserialize(using = InstantDeserializer.class)
|
||||
@JsonProperty
|
||||
public Instant endDate;
|
||||
@JsonProperty
|
||||
public String document;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Double getKeyRate() {
|
||||
return keyRate;
|
||||
}
|
||||
|
||||
public void setKeyRate(Double keyRate) {
|
||||
this.keyRate = keyRate;
|
||||
}
|
||||
|
||||
public Instant getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Instant startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Instant getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Instant endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getDocument() {
|
||||
return document;
|
||||
}
|
||||
|
||||
public void setDocument(String document) {
|
||||
this.document = document;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue