added userdata, email to lowercase

This commit is contained in:
2021-10-28 11:51:22 +02:00
parent 2af3b8cd63
commit 67a66e3cb9
17 changed files with 366 additions and 104 deletions
@@ -16,8 +16,10 @@ import org.springframework.util.Assert;
import com.google.common.collect.Lists;
import com.querydsl.core.BooleanBuilder;
import de.bstly.we.businesslogic.UserDataProvider;
import de.bstly.we.businesslogic.UserManager;
import de.bstly.we.model.User;
import de.bstly.we.model.UserData;
import de.bstly.we.partey.model.ParteyUserTag;
import de.bstly.we.partey.model.ParteyUserTag.ParteyUserTagId;
import de.bstly.we.partey.model.QParteyUserTag;
@@ -27,7 +29,7 @@ import de.bstly.we.partey.repository.ParteyUserTagRepository;
* The Class ParteyUserTagManager.
*/
@Component
public class ParteyUserTagManager {
public class ParteyUserTagManager implements UserDataProvider {
@Autowired
private ParteyUserTagRepository parteyUserTagRepository;
@@ -97,8 +99,8 @@ public class ParteyUserTagManager {
* @return the all for username
*/
public List<ParteyUserTag> getAllForUsername(String username) {
return Lists.newArrayList(
parteyUserTagRepository.findAll(qParteyUserTag.username.equalsIgnoreCase(username)));
return Lists.newArrayList(parteyUserTagRepository
.findAll(qParteyUserTag.username.equalsIgnoreCase(username)));
}
/**
@@ -159,8 +161,37 @@ public class ParteyUserTagManager {
* @param username the username
*/
public void deleteAllForTarget(String username) {
parteyUserTagRepository
.deleteAll(parteyUserTagRepository.findAll(qParteyUserTag.username.equalsIgnoreCase(username)));
parteyUserTagRepository.deleteAll(parteyUserTagRepository
.findAll(qParteyUserTag.username.equalsIgnoreCase(username)));
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#getId()
*/
@Override
public String getId() {
return "partey-tags";
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#getUserData(java.lang.Long)
*/
@Override
public List<UserData> getUserData(Long userId) {
List<UserData> result = Lists.newArrayList(getAllByUserId(userId));
return result;
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#purgeUserData(java.lang.Long)
*/
@Override
public void purgeUserData(Long userId) {
User user = userManager.get(userId);
Assert.notNull(user, "invalid userId: '"
+ userId
+ "'!");
deleteAllForTarget(user.getUsername());
}
}
@@ -12,6 +12,7 @@ import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import de.bstly.we.model.UserData;
import de.bstly.we.partey.model.ParteyUserTag.ParteyUserTagId;
/**
@@ -20,7 +21,7 @@ import de.bstly.we.partey.model.ParteyUserTag.ParteyUserTagId;
@Entity
@IdClass(ParteyUserTagId.class)
@Table(name = "partey_user_tags")
public class ParteyUserTag {
public class ParteyUserTag implements UserData {
@Id
private String username;
@@ -64,16 +64,16 @@ public class TimeslotManager implements UserDataProvider {
/**
* Gets the.
*
* @param owner the owner
* @param owner the owner
* @param invertOwner the invert owner
* @param after the after
* @param type the type
* @param visibility the visibility
* @param search the search
* @param page the page
* @param size the size
* @param sortBy the sort by
* @param descending the descending
* @param after the after
* @param type the type
* @param visibility the visibility
* @param search the search
* @param page the page
* @param size the size
* @param sortBy the sort by
* @param descending the descending
* @return the page
*/
public Page<Timeslot> get(Long owner, boolean invertOwner, Instant after, TimeslotType type,
@@ -149,7 +149,6 @@ public class TimeslotManager implements UserDataProvider {
timeslotRepository.deleteById(id);
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#getId()
*/
@@ -158,20 +157,15 @@ public class TimeslotManager implements UserDataProvider {
return "partey-timeslots";
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#getUserData(java.lang.Long)
*/
@Override
public List<UserData> getUserData(Long userId) {
List<UserData> result = Lists.newArrayList();
for (Timeslot timeslot : getAllByOwner(userId)) {
result.add(timeslot);
}
List<UserData> result = Lists.newArrayList(getAllByOwner(userId));
return result;
}
/*
* @see de.bstly.we.businesslogic.UserDataProvider#purgeUserData(java.lang.Long)
*/