47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
|
package com.bib.essensbestellungsverwaltung;
|
||
|
|
||
|
import java.util.List;
|
||
|
|
||
|
public class FoodMgr {
|
||
|
public static long createFood(String[] foodData, String[] allergyData){
|
||
|
String[] foodH = {"name","description","isDessert","food_typeid"};
|
||
|
String[] food_restrictionH = {"foodid","allergyid"};
|
||
|
long id = Database.insert("food",foodH,foodData);
|
||
|
if(allergyData.length > 0){
|
||
|
String sId = String.valueOf(id);
|
||
|
for (String allergyId : allergyData) {
|
||
|
String[] food_restrictionD = {sId,allergyId};
|
||
|
Database.insert("food_restriction",food_restrictionH, food_restrictionD);
|
||
|
}
|
||
|
}
|
||
|
return id;
|
||
|
}
|
||
|
|
||
|
public static long createFood_plan(String[] food_planData){
|
||
|
String[] food_planH = {"date","food1","food2","dessert1","dessert2"};
|
||
|
return Database.insert("food_plan",food_planH,food_planData);
|
||
|
}
|
||
|
|
||
|
public static List<String> getFood(boolean isDessert){
|
||
|
String[] foodH = {"isDessert"};
|
||
|
String[] foodD = {(isDessert ? "1" : "0")};
|
||
|
return Database.select("food",foodH,foodD);
|
||
|
}
|
||
|
|
||
|
public static List<String> getVeganFood(boolean isDessert){
|
||
|
String[] foodH = {"isDessert","food_typeid"};
|
||
|
String[] foodD = {(isDessert ? "1" : "0"),"1"};
|
||
|
return Database.select("food",foodH,foodD);
|
||
|
}
|
||
|
|
||
|
public static List<String> getFood_plan(String date){
|
||
|
String[] food_planH = {"date"};
|
||
|
String[] food_planD = {date};
|
||
|
return Database.select("food_plan",food_planH,food_planD);
|
||
|
}
|
||
|
|
||
|
public static List<String> getFoodById(long id){
|
||
|
return Database.getEntryById("food",id);
|
||
|
}
|
||
|
}
|