1
0

adding AccessMappings SepaMandateDTO with tests + consequences (HOWTO)

This commit is contained in:
Michael Hoennig
2019-04-29 09:39:08 +02:00
parent 474d51fbae
commit 328e809a2b
7 changed files with 365 additions and 23 deletions

View File

@ -64,10 +64,16 @@ public class SepaMandate implements Serializable {
private Customer customer;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public SepaMandate id(final Long id) {
this.id = id;
return this;
}
public void setId(Long id) {
this.id = id;
}

View File

@ -6,7 +6,6 @@ import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@ -19,7 +18,7 @@ import java.util.Optional;
*/
@Service
@Transactional
public class SepaMandateService {
public class SepaMandateService implements IdToDtoResolver<SepaMandateDTO> {
private final Logger log = LoggerFactory.getLogger(SepaMandateService.class);

View File

@ -0,0 +1,12 @@
package org.hostsharing.hsadminng.service;
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
import org.springframework.stereotype.Service;
@Service
public class SepaMandateValidator {
public void validate(final SepaMandateDTO sepaMandateDTO) {
// TODO: to be implemented
}
}

View File

@ -1,5 +1,11 @@
package org.hostsharing.hsadminng.service.dto;
import org.hostsharing.hsadminng.service.CustomerService;
import org.hostsharing.hsadminng.service.SepaMandateService;
import org.hostsharing.hsadminng.service.accessfilter.*;
import org.springframework.boot.jackson.JsonComponent;
import org.springframework.context.ApplicationContext;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
@ -9,38 +15,51 @@ import java.util.Objects;
/**
* A DTO for the SepaMandate entity.
*/
public class SepaMandateDTO implements Serializable {
public class SepaMandateDTO implements Serializable, AccessMappings {
@SelfId(resolver = SepaMandateService.class)
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private Long id;
@NotNull
@Size(max = 40)
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private String reference;
@Size(max = 34)
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private String iban;
@Size(max = 11)
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private String bic;
@NotNull
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private LocalDate grantingDocumentDate;
@AccessFor(init = Role.ADMIN, update = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private LocalDate revokationDocumentDate;
@NotNull
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private LocalDate validFromDate;
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, update = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private LocalDate validUntilDate;
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private LocalDate lastUsedDate;
@Size(max = 160)
@AccessFor(init = Role.ADMIN, update = Role.SUPPORTER, read = Role.SUPPORTER)
private String remark;
@ParentId(resolver = CustomerService.class)
@AccessFor(init = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT}, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private Long customerId;
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
private String customerPrefix;
public Long getId() {
@ -174,7 +193,23 @@ public class SepaMandateDTO implements Serializable {
", lastUsedDate='" + getLastUsedDate() + "'" +
", remark='" + getRemark() + "'" +
", customer=" + getCustomerId() +
", customer='" + getCustomerPrefix() + "'" +
", customerPrefix='" + getCustomerPrefix() + "'" +
"}";
}
@JsonComponent
public static class JsonSerializer extends JsonSerializerWithAccessFilter<SepaMandateDTO> {
public JsonSerializer(final ApplicationContext ctx) {
super(ctx);
}
}
@JsonComponent
public static class JsonDeserializer extends JsonDeserializerWithAccessFilter<SepaMandateDTO> {
public JsonDeserializer(final ApplicationContext ctx) {
super(ctx);
}
}
}