preparing location search
This commit is contained in:
@@ -207,7 +207,7 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, Item> find(Collection<Owner> owners, Collection<String> keys, boolean fulltext) {
|
public Map<Long, Item> findItems(Collection<Owner> owners, Collection<String> keys, boolean fulltext) {
|
||||||
try {
|
try {
|
||||||
var items = new HashMap<Long,Item>();
|
var items = new HashMap<Long,Item>();
|
||||||
var ownerCodes = owners.stream().map(Owner::dbCode).toArray();
|
var ownerCodes = owners.stream().map(Owner::dbCode).toArray();
|
||||||
@@ -230,6 +230,11 @@ public class SqliteDb extends BaseDb implements StockDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, Location> findLocations(Collection<Owner> owners, Collection<String> keys, boolean fulltext) {
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<DbLocation> listChildLocations(long parentId) {
|
public Collection<DbLocation> listChildLocations(long parentId) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import java.util.Map;
|
|||||||
public interface StockDb {
|
public interface StockDb {
|
||||||
Property addNewProperty(long itemId, String name, Object value, String unit);
|
Property addNewProperty(long itemId, String name, Object value, String unit);
|
||||||
Location delete(DbLocation location);
|
Location delete(DbLocation location);
|
||||||
Map<Long, Item> find(Collection<Owner> owners, Collection<String> keys, boolean fulltext);
|
Map<Long, Item> findItems(Collection<Owner> owners, Collection<String> keys, boolean fulltext);
|
||||||
|
Map<Long, Location> findLocations(Collection<Owner> owners, Collection<String> keys, boolean fulltext);
|
||||||
Collection<DbLocation> listChildLocations(long parentId);
|
Collection<DbLocation> listChildLocations(long parentId);
|
||||||
Collection<DbLocation> listCompanyLocations(Company company);
|
Collection<DbLocation> listCompanyLocations(Company company);
|
||||||
Collection<Item> listItemsAt(Location location);
|
Collection<Item> listItemsAt(Location location);
|
||||||
|
|||||||
@@ -459,12 +459,13 @@ public class StockModule extends BaseHandler implements StockService {
|
|||||||
private boolean postSearch(UmbrellaUser user, HttpExchange ex) throws IOException {
|
private boolean postSearch(UmbrellaUser user, HttpExchange ex) throws IOException {
|
||||||
var json = json(ex);
|
var json = json(ex);
|
||||||
if (!(json.has(KEY) && json.get(KEY) instanceof String key)) throw missingField(KEY);
|
if (!(json.has(KEY) && json.get(KEY) instanceof String key)) throw missingField(KEY);
|
||||||
var keys = Arrays.asList(key.split(" "));
|
var keys = Arrays.asList(key.split(" "));
|
||||||
var fulltext = json.has(FULLTEXT) && json.get(FULLTEXT) instanceof Boolean val && val;
|
var fulltext = json.has(FULLTEXT) && json.get(FULLTEXT) instanceof Boolean val && val;
|
||||||
Set<Owner> owners = new HashSet<>(companyService().listCompaniesOf(user).values());
|
Set<Owner> owners = new HashSet<>(companyService().listCompaniesOf(user).values());
|
||||||
owners.add(user);
|
owners.add(user);
|
||||||
var items = stockDb.find(owners,keys,fulltext);
|
var items = stockDb.findItems(owners,keys,fulltext);
|
||||||
return sendContent(ex,mapValues(items));
|
var locations = stockDb.findLocations(owners,keys,fulltext);
|
||||||
|
return sendContent(ex,Map.of("items",mapValues(items),"locations",mapValues(locations)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user