freactoring to get company list work in efficient way
This commit is contained in:
@@ -52,12 +52,14 @@ public class Constants {
|
||||
public static final String PARENT_TASK_ID = "parent_task_id";
|
||||
public static final String PASS = "pass";
|
||||
public static final String PASSWORD = "password";
|
||||
public static final String PERMISSION = "permission";
|
||||
public static final String POST = "POST";
|
||||
public static final String PROJECT_ID = "project_id";
|
||||
|
||||
public static final String RECEIVERS = "receivers";
|
||||
public static final String REDIRECT = "redirect";
|
||||
public static final String RENDERED = "rendered";
|
||||
|
||||
public static final String SENDER = "sender";
|
||||
public static final String SETTINGS = "settings";
|
||||
public static final String SHOW_CLOSED = "show_closed";
|
||||
@@ -69,13 +71,14 @@ public class Constants {
|
||||
public static final String STATUS_CODE = "code";
|
||||
public static final String STRING = "string";
|
||||
public static final String SUBJECT = "subject";
|
||||
public static final String TABLE_SETTINGS = "settings";
|
||||
|
||||
public static final String TABLE_SETTINGS = "settings";
|
||||
public static final String TEMPLATE = "template";
|
||||
public static final String TEXT = "text";
|
||||
public static final String THEME = "theme";
|
||||
public static final String TITLE = "title";
|
||||
public static final String TOKEN = "token";
|
||||
|
||||
public static final String UMBRELLA = "Umbrella";
|
||||
public static final String URL = "url";
|
||||
public static final String USER = "user";
|
||||
|
||||
@@ -5,13 +5,14 @@ import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Company;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CompanyService {
|
||||
Company get(long companyId) throws UmbrellaException;
|
||||
|
||||
Collection<UmbrellaUser> getMembers(long companyId) throws UmbrellaException;
|
||||
|
||||
Collection<Company> listCompaniesOf(UmbrellaUser user) throws UmbrellaException;
|
||||
Map<Long,Company> listCompaniesOf(UmbrellaUser user) throws UmbrellaException;
|
||||
|
||||
boolean membership(long companyId, long userId) throws UmbrellaException;
|
||||
|
||||
|
||||
@@ -4,9 +4,10 @@ package de.srsoftware.umbrella.core.api;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.Project;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ProjectService {
|
||||
public Collection<Project> listProjectsOfCompany(long companyId, boolean includeClosed) throws UmbrellaException;
|
||||
|
||||
public Collection<Project> listCompanyProjects(long companyId, boolean includeClosed) throws UmbrellaException;
|
||||
public Map<Long,Project> listUserProjects(long userId, boolean includeClosed) throws UmbrellaException;
|
||||
CompanyService companyService();
|
||||
}
|
||||
|
||||
@@ -2,4 +2,16 @@
|
||||
package de.srsoftware.umbrella.core.model;
|
||||
|
||||
|
||||
public record Member(UmbrellaUser user, Permission permission){ }
|
||||
import de.srsoftware.tools.Mappable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.PERMISSION;
|
||||
import static de.srsoftware.umbrella.core.Constants.USER;
|
||||
|
||||
public record Member(UmbrellaUser user, Permission permission) implements Mappable {
|
||||
@Override
|
||||
public Map<String, Object> toMap() {
|
||||
return Map.of(USER,user.toMap(),PERMISSION,permission.name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public record Project(long id, String name, String description, Status status, L
|
||||
map.put(STATUS,Map.of(STATUS_CODE,status.code(), NAME,status.name()));
|
||||
map.put(COMPANY_ID,companyId);
|
||||
map.put(SHOW_CLOSED,showClosed);
|
||||
map.put(MEMBERS,members == null ? List.of() : members);
|
||||
map.put(MEMBERS,members == null ? List.of() : members.stream().map(Member::toMap).toList());
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user