YZY 4 months ago
parent 4d04b75c85
commit 85d28410c3

@ -145,7 +145,7 @@
<workItem from="1744187732630" duration="3771000" />
<workItem from="1744197535410" duration="1873000" />
<workItem from="1744199899989" duration="1551000" />
<workItem from="1744202106298" duration="2978000" />
<workItem from="1744202106298" duration="4976000" />
</task>
<servers />
</component>

@ -0,0 +1,124 @@
package self.cases.teams.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import self.cases.teams.entity.Clubshenqing;
import self.cases.teams.msg.R;
import java.util.List;
@Controller
@RequestMapping("/clubshenqing")
public class ClubshenqingController {
protected static final Logger Log = LoggerFactory.getLogger(ClubshenqingController.class);
@Autowired
private ClubshenqingService clubshenqingService;
@PostMapping("/create")
@ResponseBody
public R createActivity(@RequestBody Clubshenqing activity) {
// 验证活动名称是否已存在
if (clubshenqingService.isActivityNameExists(activity.getActivityName())) {
return R.error("活动名称已存在");
}
// 创建活动
Clubshenqing createdActivity = clubshenqingService.createActivity(activity);
Log.info("新活动创建成功ID{}", createdActivity.getId());
return R.successData(createdActivity);
}
@PutMapping("/update")
@ResponseBody
public R updateActivity(@RequestBody Clubshenqing activity) {
// 验证活动是否存在
Clubshenqing existingActivity = clubshenqingService.getActivityById(activity.getId());
if (existingActivity == null) {
return R.error("活动不存在");
}
// 更新活动
Clubshenqing updatedActivity = clubshenqingService.updateActivity(activity);
Log.info("活动更新成功ID{}", updatedActivity.getId());
return R.successData(updatedActivity);
}
@GetMapping("/get/{id}")
@ResponseBody
public R getActivityById(@PathVariable String id) {
Clubshenqing activity = clubshenqingService.getActivityById(id);
if (activity == null) {
return R.error("活动不存在");
}
return R.successData(activity);
}
@GetMapping("/getAll")
@ResponseBody
public R getAllActivities() {
List<Clubshenqing> activities = clubshenqingService.getAllActivities();
return R.successData(activities);
}
@DeleteMapping("/delete/{id}")
@ResponseBody
public R deleteActivity(@PathVariable String id) {
clubshenqingService.deleteActivity(id);
Log.info("活动删除成功ID{}", id);
return R.success();
}
@GetMapping("/getByClubName/{clubName}")
@ResponseBody
public R getActivitiesByClubName(@PathVariable String clubName) {
List<Clubshenqing> activities = clubshenqingService.getActivitiesByClubName(clubName);
return R.successData(activities);
}
@GetMapping("/getApproved")
@ResponseBody
public R getApprovedActivities() {
List<Clubshenqing> activities = clubshenqingService.getApprovedActivities();
return R.successData(activities);
}
@GetMapping("/getPending")
@ResponseBody
public R getPendingActivities() {
List<Clubshenqing> activities = clubshenqingService.getPendingActivities();
return R.successData(activities);
}
@PutMapping("/approve/{id}")
@ResponseBody
public R approveActivity(@PathVariable String id) {
Clubshenqing activity = clubshenqingService.approveActivity(id);
if (activity == null) {
return R.error("活动不存在");
}
Log.info("活动审批成功ID{}", id);
return R.successData(activity);
}
@PutMapping("/reject/{id}")
@ResponseBody
public R rejectActivity(@PathVariable String id) {
Clubshenqing activity = clubshenqingService.rejectActivity(id);
if (activity == null) {
return R.error("活动不存在");
}
Log.info("活动拒绝成功ID{}", id);
return R.successData(activity);
}
}

@ -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;
}
}

@ -7,6 +7,8 @@ import java.util.HashMap;
*/
public class R extends HashMap<String, Object> {
/** 处理成功,响应码 */
public static final Integer SUCCESS_CODE = 0;

@ -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…
Cancel
Save