working on document view/edit
This commit is contained in:
@@ -4,5 +4,6 @@ dependencies{
|
||||
implementation(project(":core"))
|
||||
implementation("de.srsoftware:configuration.api:1.0.2")
|
||||
implementation("de.srsoftware:tools.jdbc:1.3.2")
|
||||
implementation("de.srsoftware:tools.util:2.0.3")
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,16 @@ public class CompanyModule implements CompanyService {
|
||||
return members;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Company> listCompaniesOf(UmbrellaUser user) throws UmbrellaException {
|
||||
return companyDb.listCompaniesOf(user.id());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean membership(long companyId, long userId) throws UmbrellaException {
|
||||
return companyDb.getMembers(companyId).contains(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserService userService() {
|
||||
return users;
|
||||
|
||||
@@ -6,6 +6,7 @@ import static de.srsoftware.tools.jdbc.Query.select;
|
||||
import static de.srsoftware.umbrella.company.Constants.TABLE_COMPANIES;
|
||||
import static de.srsoftware.umbrella.company.Constants.TABLE_COMPANIES_USERS;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||
|
||||
import de.srsoftware.umbrella.company.api.CompanyDb;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
@@ -32,7 +33,20 @@ public class SqliteDb implements CompanyDb {
|
||||
rs.close();
|
||||
return ids;
|
||||
} catch (SQLException e) {
|
||||
throw new UmbrellaException("Failed to load members of company {0}",companyId);
|
||||
throw databaseException("Failed to load members of company {0}",companyId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Company> listCompaniesOf(long userId) throws UmbrellaException {
|
||||
try {
|
||||
var rs = select("*").from(TABLE_COMPANIES).leftJoin(ID,TABLE_COMPANIES_USERS,COMPANY_ID).where(USER_ID,equal(userId)).exec(db);
|
||||
var companies = new HashSet<Company>();
|
||||
while (rs.next()) companies.add(Company.of(rs));
|
||||
rs.close();
|
||||
return companies;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException("Failed to load companies for user {0}",userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +60,7 @@ public class SqliteDb implements CompanyDb {
|
||||
if (company == null) throw new UmbrellaException("Could not load company {0}",companyId);
|
||||
return company;
|
||||
} catch (SQLException e){
|
||||
throw new UmbrellaException("Could not load company {0}",companyId);
|
||||
throw databaseException("Could not load company {0}",companyId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,7 @@ import java.util.Collection;
|
||||
public interface CompanyDb {
|
||||
Collection<Long> getMembers(long companyId) throws UmbrellaException;
|
||||
|
||||
Collection<Company> listCompaniesOf(long id) throws UmbrellaException;
|
||||
|
||||
Company load(long companyId) throws UmbrellaException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user