import 'package:flutter_common/utils/convert_utils.dart'; import 'package:flutter_common/utils/http_utils.dart'; import 'package:food_hub_app/config/app_config.dart'; import 'package:food_hub_app/models/moment.dart'; final httpUtil = HttpUtil(baseUrl: AppConfig.baseApiUrl); Future addMomentApi(Moment moment) { return httpUtil.post("/moment", data: moment); } Future updateMomentApi(int id, Moment moment) { return httpUtil.put("/moment/$id", data: moment); } Future deleteMomentApi(int id) { return httpUtil.delete("/moment/$id"); } Future> queryMomentListApi() { return httpUtil.get>( "/moment", converter: (data) => convertList(data, Moment.fromJson), ); } Future queryMomentByPageApi(int currentPage, int pageSize) { return httpUtil.get( "/moment/page", queryParameters: {"currentPage": currentPage, "pageSize": pageSize}, converter: (data) => PageMoment.fromJson(data), ); } Future addMomentCommentApi(int id, String content) { return httpUtil.post("/moment/$id/comment", data: content); } Future addMomentLikeApi(int id) { return httpUtil.post("/food/moment/$id/like"); } Future deleteMomentLikeApi(int id) { return httpUtil.delete("/food/moment/$id/like"); }