started implementing poll backend
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -12,6 +12,7 @@ public class ModuleRegistry {
|
||||
private FileService fileService;
|
||||
private MarkdownService markdownService;
|
||||
private NoteService noteService;
|
||||
private PollService pollService;
|
||||
private PostBox postBox;
|
||||
private ProjectService projectService;
|
||||
private StockService stockService;
|
||||
@@ -33,9 +34,10 @@ public class ModuleRegistry {
|
||||
case ContactService cs: singleton.contactService = cs; break;
|
||||
case DocumentService ds: singleton.documentService = ds; break;
|
||||
case FileService fs: singleton.fileService = fs; break;
|
||||
case StockService is: singleton.stockService = is; break;
|
||||
case StockService is: singleton.stockService = is; break;
|
||||
case MarkdownService ms: singleton.markdownService = ms; break;
|
||||
case NoteService ns: singleton.noteService = ns; break;
|
||||
case PollService ps: singleton.pollService = ps; break;
|
||||
case PostBox pb: singleton.postBox = pb; break;
|
||||
case ProjectService ps: singleton.projectService = ps; break;
|
||||
case TagService ts: singleton.tagService = ts; break;
|
||||
@@ -81,6 +83,10 @@ public class ModuleRegistry {
|
||||
return singleton.noteService;
|
||||
}
|
||||
|
||||
public static PollService pollService() {
|
||||
return singleton.pollService;
|
||||
}
|
||||
|
||||
public static PostBox postBox() {
|
||||
return singleton.postBox;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.core.api;
|
||||
|
||||
public interface PollService {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
import de.srsoftware.tools.Mappable;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.Util;
|
||||
import de.srsoftware.umbrella.core.api.Owner;
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public record Poll(String id, Owner owner, String name, String description, boolean isPrivate) implements Mappable {
|
||||
public static Poll of(ResultSet rs) throws SQLException {
|
||||
var id = rs.getString(Field.ID);
|
||||
var userId = rs.getLong(Field.USER_ID);
|
||||
var name = rs.getString(Field.NAME);
|
||||
var description = rs.getString(Field.DESCRIPTION);
|
||||
var isPrivate = rs.getBoolean(Field.PRIVATE);
|
||||
var owner = ModuleRegistry.userService().loadUser(userId);
|
||||
return new Poll(id,owner,name,description,isPrivate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(
|
||||
Field.ID, id,
|
||||
Field.OWNER, owner.toMap(),
|
||||
Field.NAME,name,
|
||||
Field.DESCRIPTION, Map.of(
|
||||
Field.SOURCE,description,
|
||||
Field.RENDERED,Util.markdown(description)
|
||||
),
|
||||
Field.PRIVATE, isPrivate
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user