implemented listing of list members
This commit is contained in:
@@ -5,8 +5,10 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.srsoftware.widerhall.Constants.*;
|
||||
import static de.srsoftware.widerhall.Constants.STATE;
|
||||
@@ -59,6 +61,27 @@ public class ListMember {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static Map<User,Integer> of(String listEmail) throws SQLException {
|
||||
var rs = Database.open()
|
||||
.query("SELECT * FROM "+TABLE_NAME)
|
||||
.where(LIST_EMAIL,listEmail)
|
||||
.exec();
|
||||
var temp = new HashMap<String,Integer>();
|
||||
while (rs.next()) temp.put(rs.getString(USER_EMAIL),rs.getInt(STATE));
|
||||
var result = new HashMap<User,Integer>();
|
||||
User.loadAll(temp.keySet())
|
||||
.stream()
|
||||
.forEach(user -> result.put(user,temp.get(user.email())));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String stateText(int state) {
|
||||
var words = new ArrayList<String>();
|
||||
if ((state & STATE_OWNER) > 0) words.add("owener");
|
||||
if ((state & STATE_SUBSCRIBER) > 0) words.add("subscriber");
|
||||
return String.join(", ",words);
|
||||
}
|
||||
|
||||
private ListMember save() throws SQLException {
|
||||
Database.open().insertInto(TABLE_NAME)
|
||||
.values(Map.of(LIST_EMAIL,listEmail,
|
||||
|
||||
Reference in New Issue
Block a user