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);
final Specification<Contact> specification = createSpecification(criteria);
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;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;
@ -8,6 +9,8 @@ import java.util.Objects;
*/
public class ContactDTO implements Serializable {
private boolean isOwnedByLoginUser;
private Long id;
@NotNull
@ -22,7 +25,6 @@ public class ContactDTO implements Serializable {
@Size(max = 80)
private String email;
public Long getId() {
return id;
}
@ -85,4 +87,12 @@ public class ContactDTO implements Serializable {
", email='" + getEmail() + "'" +
"}";
}
public boolean isOwnedByLoginUser() {
return isOwnedByLoginUser;
}
public void setOwnedByLoginUser(boolean ownedByLoginUser) {
isOwnedByLoginUser = ownedByLoginUser;
}
}