|
@@ -0,0 +1,67 @@
|
|
|
|
|
+import { UserInfo, YTRequest } from 'basic'
|
|
|
|
|
+import { BabyInfo, Cuisine, FoodDetail, PurchaseList, Recipe } from '../model/Index'
|
|
|
|
|
+import { ApiUrl } from './ApiUrl'
|
|
|
|
|
+
|
|
|
|
|
+export class BabyFoodApi{
|
|
|
|
|
+ // 获取所有食谱列表
|
|
|
|
|
+ static getAllRecipes(keyword?: string, monthRange?: string): Promise<Recipe[]> {
|
|
|
|
|
+ return YTRequest.get(ApiUrl.getAllRecipes, {keyword, monthRange})
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取食物详情信息
|
|
|
|
|
+ static getFoodDetail(id: string): Promise<FoodDetail> {
|
|
|
|
|
+ return YTRequest.get(ApiUrl.getFoodDetail, {id})
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取本周所有采购清单
|
|
|
|
|
+ static getWeeklyPurchaseList(babyId: number): Promise<PurchaseList[]> {
|
|
|
|
|
+ return YTRequest.get(ApiUrl.getWeeklyPurchaseList, {babyId})
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 已购买状态修改(0=未购买 | 1=已购买)
|
|
|
|
|
+ static updatePurchaseStatus(id: number): Promise<null> {
|
|
|
|
|
+ return YTRequest.post(ApiUrl.updatePurchaseStatus, null, {id})
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 菜品下拉列表
|
|
|
|
|
+ static getDishList(): Promise<Cuisine[]> {
|
|
|
|
|
+ return YTRequest.get(ApiUrl.getDishList)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 获取本周食谱计划
|
|
|
|
|
+ // todo
|
|
|
|
|
+ static getWeeklyPlan(babyId?: number, startDate?: string): Promise<Recipe[]> {
|
|
|
|
|
+ return YTRequest.get(ApiUrl.getWeeklyPlan, {babyId, startDate})
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 编辑本周食谱
|
|
|
|
|
+ // todo
|
|
|
|
|
+ static updateWeeklyPlan(weeklyPlan: Recipe[]): Promise<null> {
|
|
|
|
|
+ return YTRequest.post(ApiUrl.updateWeeklyPlan, weeklyPlan)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 添加宝宝信息
|
|
|
|
|
+ static addBabyInfo(babyInfo: BabyInfo): Promise<null> {
|
|
|
|
|
+ return YTRequest.post(ApiUrl.addBabyInfo, babyInfo)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询宝宝列表
|
|
|
|
|
+ static getBabyList(): Promise<UserInfo[]> {
|
|
|
|
|
+ return YTRequest.get(ApiUrl.getBabyList)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 删除宝宝信息
|
|
|
|
|
+ static deleteBabyInfo(id: number): Promise<null> {
|
|
|
|
|
+ return YTRequest.delete(ApiUrl.deleteBabyInfo, {id})
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 根据id查询宝宝信息
|
|
|
|
|
+ static getBabyInfoById(id: number): Promise<UserInfo> {
|
|
|
|
|
+ return YTRequest.get(ApiUrl.getBabyInfoById, {id})
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 修改宝宝信息
|
|
|
|
|
+ static updateBabyInfo(babyInfo: BabyInfo): Promise<null> {
|
|
|
|
|
+ return YTRequest.post(ApiUrl.updateBabyInfo, babyInfo)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|