ソースを参照

feat: 修改baseUrl, 新增请求方法

YuJing 1 ヶ月 前
コミット
faa52d2205

+ 2 - 2
commons/basic/src/main/ets/apis/YTRequest.ets

@@ -13,9 +13,9 @@ import { userInfo } from '../models/UserInfo';
 import { yTRouter } from '../utils/YTRouter';
 
 
-export const baseURL: string = 'https://hm.ytpm.net/prod-activity'
+// export const baseURL: string = 'https://hm.ytpm.net/prod-activity'
 
-// export const baseURL: string = 'http://192.168.1.160:48103'
+export const baseURL: string = 'http://192.168.1.160:48104'
 
 export const instance = axios.create({
   baseURL,

+ 60 - 1
features/feature/src/main/ets/Apis/ApiUrl.ets

@@ -1,3 +1,62 @@
 export class ApiUrl{
-
+  /**
+   * @description 获取所有食谱列表
+   * @method GET
+   */
+  static getAllRecipes = '/babyFoodRecipe/getAllRecipe'
+  /**
+   * @description 获取食物详情信息
+   * @method GET
+   */
+  static getFoodDetail = '/babyFoodRecipe/getRecipeDetail'
+  /**
+   * @description 获取本周所有采购清单
+   * @method GET
+   */
+  static getWeeklyPurchaseList = '/babyFoodShoppingList/getAllShoppingList'
+  /**
+   * @description 已购买状态修改(0=未购买 | 1=已购买)
+   * @method POST
+   */
+  static updatePurchaseStatus = '/babyFoodShoppingList/updateState'
+  /**
+   * @description 菜品下拉列表
+   * @method GET
+   */
+  static getDishList = '/babyFoodWeeklyPlan/getCuisineList'
+  /**
+   * @description 获取本周食谱计划
+   * @method GET
+   */
+  static getWeeklyPlan = '/babyFoodWeeklyPlan/getWeeklyPlan'
+  /**
+   * @description 编辑本周食谱
+   * @method POST
+   */
+  static updateWeeklyPlan = '/babyFoodWeeklyPlan/updateWeeklyPlan'
+  /**
+   * @description 添加宝宝信息
+   * @method POST
+   */
+  static addBabyInfo = '/babyInfo/addBabyInfo'
+  /**
+   * @description 查询宝宝列表
+   * @method GET
+   */
+  static getBabyList = '/babyInfo/babyInfoList'
+  /**
+   * @description 删除宝宝信息
+   * @method DELETE
+   */
+  static deleteBabyInfo = '/babyInfo/deleteBabyInfos'
+  /**
+   * @description 根据id查询宝宝信息
+   * @method GET
+   */
+  static getBabyInfoById = '/babyInfo/getBabyInfoById'
+  /**
+   * @description 修改宝宝信息
+   * @method POST
+   */
+  static updateBabyInfo = '/babyInfo/updateBabyInfo'
 }

+ 67 - 0
features/feature/src/main/ets/Apis/BabyFoodApi.ets

@@ -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)
+  }
+}

+ 70 - 0
features/feature/src/main/ets/model/Index.ets

@@ -0,0 +1,70 @@
+// 食谱
+export class Recipe {
+  id?: string;
+  name?: string;
+  description?: string;
+  cookingTime?: number;
+  difficulty?: string;
+  ingredients?: string[];
+  steps?: string[];
+  imageUrl?: string;
+  tags?: string[] | null;
+  nutritionInfo?: object;
+  monthRange?: string;
+}
+
+// 食物详细信息
+export class FoodDetail {
+  id?: string;
+  name?: string;
+  description?: string;
+  cookingTime?: string;
+  difficulty?: boolean;
+  ingredients?: string[];
+  steps?: string[];
+  imageUrl?: string;
+  tags?: string;
+  nutritionInfo?: string;
+  monthRange?: string;
+}
+
+// 采购清单
+export class PurchaseList {
+  amount?: number;
+  foodRecipeId?: number;
+  foodWeeklyPlanId?: number;
+  id?: number;
+  ingredientName?: string;
+  purchased?: boolean;
+  unit?: string;
+}
+
+// 菜品菜单
+export class Cuisine {
+  id?: number;
+  name?: string;
+}
+
+// 宝宝信息
+export class BabyInfo {
+  avatarUrl?: string;
+  backgroundUrl?: string;
+  birthday?: string;
+  gender?: number;
+  id?: number;
+  name?: string;
+  userId?: number
+
+  // 浅拷贝方法
+  clone(): BabyInfo {
+    const cloned = new BabyInfo();
+    cloned.avatarUrl = this.avatarUrl;
+    cloned.backgroundUrl = this.backgroundUrl;
+    cloned.birthday = this.birthday;
+    cloned.gender = this.gender;
+    cloned.id = this.id;
+    cloned.name = this.name;
+    cloned.userId = this.userId;
+    return cloned;
+  }
+}