spike for isOwnedByLoginUser

This commit is contained in:
Michael Hoennig 2019-04-03 18:32:10 +02:00
parent 39b9a1a7dc
commit dfa6bd2bed
2 changed files with 18 additions and 2 deletions

View File

@ -65,7 +65,13 @@ public class ContactQueryService extends QueryService<Contact> {
log.debug("find by criteria : {}, page: {}", criteria, page); log.debug("find by criteria : {}, page: {}", criteria, page);
final Specification<Contact> specification = createSpecification(criteria); final Specification<Contact> specification = createSpecification(criteria);
return contactRepository.findAll(specification, page) return contactRepository.findAll(specification, page)
.map(contactMapper::toDto); .map(contactMapper::toDto)
.map((dto) -> determineAccessRights(dto));
}
private ContactDTO determineAccessRights(ContactDTO dto) {
dto.setOwnedByLoginUser(dto.getLastName().startsWith("Owner"));
return dto;
} }
/** /**

View File

@ -1,4 +1,5 @@
package org.hostsharing.hsadminng.service.dto; package org.hostsharing.hsadminng.service.dto;
import javax.validation.constraints.*; import javax.validation.constraints.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
@ -8,6 +9,8 @@ import java.util.Objects;
*/ */
public class ContactDTO implements Serializable { public class ContactDTO implements Serializable {
private boolean isOwnedByLoginUser;
private Long id; private Long id;
@NotNull @NotNull
@ -22,7 +25,6 @@ public class ContactDTO implements Serializable {
@Size(max = 80) @Size(max = 80)
private String email; private String email;
public Long getId() { public Long getId() {
return id; return id;
} }
@ -85,4 +87,12 @@ public class ContactDTO implements Serializable {
", email='" + getEmail() + "'" + ", email='" + getEmail() + "'" +
"}"; "}";
} }
public boolean isOwnedByLoginUser() {
return isOwnedByLoginUser;
}
public void setOwnedByLoginUser(boolean ownedByLoginUser) {
isOwnedByLoginUser = ownedByLoginUser;
}
} }