parent
4d04b75c85
commit
85d28410c3
@ -0,0 +1,135 @@
|
|||||||
|
package self.cases.teams.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class Clubshenqing {
|
||||||
|
private String id;
|
||||||
|
private String clubName;
|
||||||
|
private String activityName;
|
||||||
|
private String description;
|
||||||
|
private Date startDate;
|
||||||
|
private Date endDate;
|
||||||
|
private String location;
|
||||||
|
private int maxParticipants;
|
||||||
|
private String contactPerson;
|
||||||
|
private String contactEmail;
|
||||||
|
private String contactPhone;
|
||||||
|
private boolean approved;
|
||||||
|
private Date createdAt;
|
||||||
|
private Date updatedAt;
|
||||||
|
|
||||||
|
// Getters and Setters
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClubName() {
|
||||||
|
return clubName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClubName(String clubName) {
|
||||||
|
this.clubName = clubName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivityName() {
|
||||||
|
return activityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityName(String activityName) {
|
||||||
|
this.activityName = activityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getStartDate() {
|
||||||
|
return startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(Date startDate) {
|
||||||
|
this.startDate = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(Date endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(String location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxParticipants() {
|
||||||
|
return maxParticipants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxParticipants(int maxParticipants) {
|
||||||
|
this.maxParticipants = maxParticipants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContactPerson() {
|
||||||
|
return contactPerson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContactPerson(String contactPerson) {
|
||||||
|
this.contactPerson = contactPerson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContactEmail() {
|
||||||
|
return contactEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContactEmail(String contactEmail) {
|
||||||
|
this.contactEmail = contactEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContactPhone() {
|
||||||
|
return contactPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContactPhone(String contactPhone) {
|
||||||
|
this.contactPhone = contactPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isApproved() {
|
||||||
|
return approved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApproved(boolean approved) {
|
||||||
|
this.approved = approved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedAt() {
|
||||||
|
return createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Date createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdatedAt() {
|
||||||
|
return updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Date updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,380 @@
|
|||||||
|
package self.cases.teams.teaa;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SheYuan {
|
||||||
|
|
||||||
|
private Map<Integer, Member> members;
|
||||||
|
|
||||||
|
public SheYuan() {
|
||||||
|
members = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inner class to represent a Member
|
||||||
|
public static class Member {
|
||||||
|
private int memberId;
|
||||||
|
private String name;
|
||||||
|
private String email;
|
||||||
|
private String password;
|
||||||
|
private LocalDate dateOfBirth;
|
||||||
|
private String address;
|
||||||
|
private String phoneNumber;
|
||||||
|
private boolean isActive;
|
||||||
|
private String groupName;
|
||||||
|
private List<Integer> friendIds;
|
||||||
|
|
||||||
|
public Member(int memberId, String name, String email, String password, LocalDate dateOfBirth, String address, String phoneNumber) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
this.name = name;
|
||||||
|
this.email = email;
|
||||||
|
this.password = password;
|
||||||
|
this.dateOfBirth = dateOfBirth;
|
||||||
|
this.address = address;
|
||||||
|
this.phoneNumber = phoneNumber;
|
||||||
|
this.isActive = true;
|
||||||
|
this.friendIds = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateOfBirth() {
|
||||||
|
return dateOfBirth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhoneNumber() {
|
||||||
|
return phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deactivate() {
|
||||||
|
this.isActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupName() {
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupName(String groupName) {
|
||||||
|
this.groupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getFriendIds() {
|
||||||
|
return friendIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFriend(int friendId) {
|
||||||
|
friendIds.add(friendId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFriend(int friendId) {
|
||||||
|
friendIds.remove((Integer) friendId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Member{" +
|
||||||
|
"memberId=" + memberId +
|
||||||
|
", name='" + name + '\\' +
|
||||||
|
", email='" + email + '\\' +
|
||||||
|
", password='" + password + '\\' +
|
||||||
|
", dateOfBirth=" + dateOfBirth +
|
||||||
|
", address='" + address + '\\' +
|
||||||
|
", phoneNumber='" + phoneNumber + '\\' +
|
||||||
|
", isActive=" + isActive +
|
||||||
|
", groupName='" + groupName + '\\' +
|
||||||
|
", friendIds=" + friendIds +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String newName) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String newEmail) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String newPassword) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateOfBirth(LocalDate newDateOfBirth) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String newAddress) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhoneNumber(String newPhoneNumber) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getLastLoginDate() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to add a member
|
||||||
|
public void addMember(int memberId, String name, String email, String password, LocalDate dateOfBirth, String address, String phoneNumber) {
|
||||||
|
if (members.containsKey(memberId)) {
|
||||||
|
throw new IllegalArgumentException("Member already exists");
|
||||||
|
}
|
||||||
|
members.put(memberId, new Member(memberId, name, email, password, dateOfBirth, address, phoneNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to remove a member
|
||||||
|
public void removeMember(int memberId) {
|
||||||
|
if (!members.containsKey(memberId)) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
members.remove(memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members
|
||||||
|
public List<Member> listAllMembers() {
|
||||||
|
return new ArrayList<>(members.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to find a member by ID
|
||||||
|
public Member findMemberById(int memberId) {
|
||||||
|
return members.get(memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to deactivate a member
|
||||||
|
public void deactivateMember(int memberId) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
member.deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to update member information
|
||||||
|
public void updateMember(int memberId, String newName, String newEmail, String newPassword, LocalDate newDateOfBirth, String newAddress, String newPhoneNumber) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
member.setName(newName);
|
||||||
|
member.setEmail(newEmail);
|
||||||
|
member.setPassword(newPassword);
|
||||||
|
member.setDateOfBirth(newDateOfBirth);
|
||||||
|
member.setAddress(newAddress);
|
||||||
|
member.setPhoneNumber(newPhoneNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by email
|
||||||
|
public List<Member> searchMembersByEmail(String email) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getEmail().toLowerCase().contains(email.toLowerCase()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by phone number
|
||||||
|
public List<Member> searchMembersByPhoneNumber(String phoneNumber) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getPhoneNumber().equals(phoneNumber))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by date of birth
|
||||||
|
public List<Member> searchMembersByDateOfBirth(LocalDate dateOfBirth) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getDateOfBirth().equals(dateOfBirth))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by address
|
||||||
|
public List<Member> searchMembersByAddress(String address) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getAddress().toLowerCase().contains(address.toLowerCase()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by active status
|
||||||
|
public List<Member> searchMembersByActiveStatus(boolean isActive) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.isActive() == isActive)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to assign a member to a group
|
||||||
|
public void assignMemberToGroup(int memberId, String groupName) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
member.setGroupName(groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to unassign a member from a group
|
||||||
|
public void unassignMemberFromGroup(int memberId) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
member.setGroupName(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members assigned to a group
|
||||||
|
public List<Member> listMembersAssignedToGroup(String groupName) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getGroupName() != null && m.getGroupName().equals(groupName))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all groups a member is assigned to
|
||||||
|
public List<String> listGroupsForMember(int memberId) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
return Collections.singletonList(member.getGroupName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members with more than 10 active friends
|
||||||
|
public List<Member> listMembersWithMoreThanTenActiveFriends() {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getFriendIds().size() > 10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who are active in any group
|
||||||
|
public List<Member> listActiveMembersInAnyGroup() {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(Member::isActive)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members that have been registered within the last month
|
||||||
|
public List<Member> listRecentRegistrations() {
|
||||||
|
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> !m.getDateOfBirth().isBefore(oneMonthAgo))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year
|
||||||
|
public List<Member> listMembersLoggedInInLastYear() {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last month and have more than 10 active friends
|
||||||
|
public List<Member> listMembersLoggedInInLastMonthWithMoreThanTenActiveFriends() {
|
||||||
|
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneMonthAgo)) && m.getFriendIds().size() > 10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriends() {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroup(String groupName) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddress(String groupName, String address) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumber(String groupName, String address, String phoneNumber) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActive(String groupName, String address, String phoneNumber) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificName(String groupName, String address, String phoneNumber, String name) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmail(String groupName, String address, String phoneNumber, String name, String email) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPassword(String groupName, String address, String phoneNumber, String name, String email, String password) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email) && m.getPassword().equals(password))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirth(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email) && m.getPassword().equals(password) && m.getDateOfBirth().equals(dateOfBirth))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth and address
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddress(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth, String addressDetail) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email) && m.getPassword().equals(password) && m.getDateOfBirth().equals(dateOfBirth) && m.getAddress().equals(addressDetail))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth and address and phone number
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddressAndPhoneNumber(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth, String addressDetail, String phoneNumberDetail) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email) && m.getPassword().equals(password) && m.getDateOfBirth().equals(dateOfBirth) && m.getAddress().equals(addressDetail) && m.getPhoneNumber().equals(phoneNumberDetail))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,380 @@
|
|||||||
|
package self.cases.teams.teaa;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SheZhangManage {
|
||||||
|
|
||||||
|
private Map<Integer, Member> members;
|
||||||
|
|
||||||
|
public SheZhangManage() {
|
||||||
|
members = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inner class to represent a Member
|
||||||
|
public static class Member {
|
||||||
|
private int memberId;
|
||||||
|
private String name;
|
||||||
|
private String email;
|
||||||
|
private String password;
|
||||||
|
private LocalDate dateOfBirth;
|
||||||
|
private String address;
|
||||||
|
private String phoneNumber;
|
||||||
|
private boolean isActive;
|
||||||
|
private String groupName;
|
||||||
|
private List<Integer> friendIds;
|
||||||
|
|
||||||
|
public Member(int memberId, String name, String email, String password, LocalDate dateOfBirth, String address, String phoneNumber) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
this.name = name;
|
||||||
|
this.email = email;
|
||||||
|
this.password = password;
|
||||||
|
this.dateOfBirth = dateOfBirth;
|
||||||
|
this.address = address;
|
||||||
|
this.phoneNumber = phoneNumber;
|
||||||
|
this.isActive = true;
|
||||||
|
this.friendIds = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getDateOfBirth() {
|
||||||
|
return dateOfBirth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhoneNumber() {
|
||||||
|
return phoneNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deactivate() {
|
||||||
|
this.isActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupName() {
|
||||||
|
return groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupName(String groupName) {
|
||||||
|
this.groupName = groupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getFriendIds() {
|
||||||
|
return friendIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFriend(int friendId) {
|
||||||
|
friendIds.add(friendId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFriend(int friendId) {
|
||||||
|
friendIds.remove((Integer) friendId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Member{" +
|
||||||
|
"memberId=" + memberId +
|
||||||
|
", name='" + name + '\\' +
|
||||||
|
", email='" + email + '\\' +
|
||||||
|
", password='" + password + '\\' +
|
||||||
|
", dateOfBirth=" + dateOfBirth +
|
||||||
|
", address='" + address + '\\' +
|
||||||
|
", phoneNumber='" + phoneNumber + '\\' +
|
||||||
|
", isActive=" + isActive +
|
||||||
|
", groupName='" + groupName + '\\' +
|
||||||
|
", friendIds=" + friendIds +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String newName) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String newEmail) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateOfBirth(LocalDate newDateOfBirth) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String newPassword) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhoneNumber(String newPhoneNumber) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String newAddress) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Instant getLastLoginDate() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to add a member
|
||||||
|
public void addMember(int memberId, String name, String email, String password, LocalDate dateOfBirth, String address, String phoneNumber) {
|
||||||
|
if (members.containsKey(memberId)) {
|
||||||
|
throw new IllegalArgumentException("Member already exists");
|
||||||
|
}
|
||||||
|
members.put(memberId, new Member(memberId, name, email, password, dateOfBirth, address, phoneNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to remove a member
|
||||||
|
public void removeMember(int memberId) {
|
||||||
|
if (!members.containsKey(memberId)) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
members.remove(memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members
|
||||||
|
public List<Member> listAllMembers() {
|
||||||
|
return new ArrayList<>(members.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to find a member by ID
|
||||||
|
public Member findMemberById(int memberId) {
|
||||||
|
return members.get(memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to deactivate a member
|
||||||
|
public void deactivateMember(int memberId) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
member.deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to update member information
|
||||||
|
public void updateMember(int memberId, String newName, String newEmail, String newPassword, LocalDate newDateOfBirth, String newAddress, String newPhoneNumber) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
member.setName(newName);
|
||||||
|
member.setEmail(newEmail);
|
||||||
|
member.setPassword(newPassword);
|
||||||
|
member.setDateOfBirth(newDateOfBirth);
|
||||||
|
member.setAddress(newAddress);
|
||||||
|
member.setPhoneNumber(newPhoneNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by email
|
||||||
|
public List<Member> searchMembersByEmail(String email) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getEmail().toLowerCase().contains(email.toLowerCase()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by phone number
|
||||||
|
public List<Member> searchMembersByPhoneNumber(String phoneNumber) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getPhoneNumber().equals(phoneNumber))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by date of birth
|
||||||
|
public List<Member> searchMembersByDateOfBirth(LocalDate dateOfBirth) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getDateOfBirth().equals(dateOfBirth))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by address
|
||||||
|
public List<Member> searchMembersByAddress(String address) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getAddress().toLowerCase().contains(address.toLowerCase()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to search for members by active status
|
||||||
|
public List<Member> searchMembersByActiveStatus(boolean isActive) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.isActive() == isActive)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to assign a member to a group
|
||||||
|
public void assignMemberToGroup(int memberId, String groupName) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
member.setGroupName(groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to unassign a member from a group
|
||||||
|
public void unassignMemberFromGroup(int memberId) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
member.setGroupName(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members assigned to a group
|
||||||
|
public List<Member> listMembersAssignedToGroup(String groupName) {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getGroupName() != null && m.getGroupName().equals(groupName))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all groups a member is assigned to
|
||||||
|
public List<String> listGroupsForMember(int memberId) {
|
||||||
|
Member member = members.get(memberId);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("Member not found");
|
||||||
|
}
|
||||||
|
return Collections.singletonList(member.getGroupName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members with more than 10 active friends
|
||||||
|
public List<Member> listMembersWithMoreThanTenActiveFriends() {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getFriendIds().size() > 10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who are active in any group
|
||||||
|
public List<Member> listActiveMembersInAnyGroup() {
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(Member::isActive)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members that have been registered within the last month
|
||||||
|
public List<Member> listRecentRegistrations() {
|
||||||
|
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> !m.getDateOfBirth().isBefore(oneMonthAgo))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year
|
||||||
|
public List<Member> listMembersLoggedInInLastYear() {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last month and have more than 10 active friends
|
||||||
|
public List<Member> listMembersLoggedInInLastMonthWithMoreThanTenActiveFriends() {
|
||||||
|
LocalDate oneMonthAgo = LocalDate.now().minusMonths(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneMonthAgo)) && m.getFriendIds().size() > 10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriends() {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroup(String groupName) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddress(String groupName, String address) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumber(String groupName, String address, String phoneNumber) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActive(String groupName, String address, String phoneNumber) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificName(String groupName, String address, String phoneNumber, String name) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmail(String groupName, String address, String phoneNumber, String name, String email) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPassword(String groupName, String address, String phoneNumber, String name, String email, String password) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email) && m.getPassword().equals(password))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirth(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email) && m.getPassword().equals(password) && m.getDateOfBirth().equals(dateOfBirth))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth and address
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddress(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth, String addressDetail) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email) && m.getPassword().equals(password) && m.getDateOfBirth().equals(dateOfBirth) && m.getAddress().equals(addressDetail))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to list all members who have logged in within the last year and have more than 10 active friends in a specific group and have a specific address and phone number and are active and have a specific name and email and password and date of birth and address and phone number
|
||||||
|
public List<Member> listMembersLoggedInInLastYearWithMoreThanTenActiveFriendsInGroupAndSpecificAddressAndPhoneNumberAndActiveAndSpecificNameAndEmailAndPasswordAndDateOfBirthAndAddressAndPhoneNumber(String groupName, String address, String phoneNumber, String name, String email, String password, LocalDate dateOfBirth, String addressDetail, String phoneNumberDetail) {
|
||||||
|
LocalDate oneYearAgo = LocalDate.now().minusYears(1);
|
||||||
|
return members.values().stream()
|
||||||
|
.filter(m -> m.getLastLoginDate().isAfter(Instant.from(oneYearAgo)) && m.getFriendIds().size() > 10 && m.getGroupName().equals(groupName) && m.getAddress().equals(address) && m.getPhoneNumber().equals(phoneNumber) && m.isActive() && m.getName().equals(name) && m.getEmail().equals(email) && m.getPassword().equals(password) && m.getDateOfBirth().equals(dateOfBirth) && m.getAddress().equals(addressDetail) && m.getPhoneNumber().equals(phoneNumberDetail))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package self.cases.teams.utils;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class IDUtil {
|
||||||
|
public static String makeIDByCurrent() {
|
||||||
|
return UUID.randomUUID().toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue