|
@@ -1,7 +1,12 @@
|
|
|
import 'package:domain/constants/api_constants.dart';
|
|
|
+import 'package:domain/entity/myfollowing_list_entity.dart';
|
|
|
+import 'package:domain/entity/newsfeed_comment_publish_entity.dart';
|
|
|
+import 'package:domain/entity/newsfeed_detail_entity.dart';
|
|
|
+import 'package:domain/entity/newsfeed_following_entity.dart';
|
|
|
import 'package:domain/entity/newsfeed_foryou_entity.dart';
|
|
|
import 'package:domain/entity/newsfeed_news_entity.dart';
|
|
|
import 'package:domain/entity/server_time.dart';
|
|
|
+import 'package:plugin_platform/engine/toast/toast_engine.dart';
|
|
|
import 'package:plugin_platform/platform_export.dart';
|
|
|
import 'package:plugin_platform/http/dio_engine.dart';
|
|
|
import 'package:plugin_platform/http/http_result.dart';
|
|
@@ -16,22 +21,58 @@ import 'package:plugin_basic/provider/http_provider/http_provider.dart';
|
|
|
part 'common_newsfeed.g.dart';
|
|
|
|
|
|
@Riverpod(keepAlive: true)
|
|
|
-CommonNewsFeedRepository commonNewsFeedRepository(Ref ref) {
|
|
|
+CommonNewsFeedRespository commonNewsFeedRespository(Ref ref) {
|
|
|
final dioEngine = ref.watch(dioEngineProvider);
|
|
|
- return CommonNewsFeedRepository(dioEngine: dioEngine);
|
|
|
+ return CommonNewsFeedRespository(dioEngine: dioEngine);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 数据仓库
|
|
|
*/
|
|
|
-class CommonNewsFeedRepository {
|
|
|
+class CommonNewsFeedRespository {
|
|
|
DioEngine dioEngine;
|
|
|
|
|
|
- CommonNewsFeedRepository({required this.dioEngine});
|
|
|
+ CommonNewsFeedRespository({required this.dioEngine});
|
|
|
|
|
|
+ // news feed - news 列表
|
|
|
+ Future<HttpResult<Object>> fetchNewsList(
|
|
|
+ Map<String, dynamic>? data, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, dynamic> params = {};
|
|
|
+ params = data!;
|
|
|
+ Map<String, String> headers = {};
|
|
|
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
|
+ headers["Accept"] = "application/x.yyjobs-api.v1+json";
|
|
|
|
|
|
- // 获取 我关注的人
|
|
|
- Future<HttpResult<Object>> fetchMyFollowList(
|
|
|
+ final result = await dioEngine.requestNetResult(
|
|
|
+ // ApiConstants.apiServerTime, // api 地址
|
|
|
+ '/api/v1/user/news-feed/feed/news', // api 地址
|
|
|
+ params: params,
|
|
|
+ headers: headers,
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ isShowLoadingDialog: false, //是否展示默认的Loading弹窗
|
|
|
+ networkDebounce: true, //是否防抖防止重复请求
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = NewsfeedNewsEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert(data: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ // news feed - following 列表
|
|
|
+ Future<HttpResult<Object>> fetchFollowingList(
|
|
|
Map<String, dynamic>? data, {
|
|
|
CancelToken? cancelToken,
|
|
|
}) async {
|
|
@@ -43,7 +84,7 @@ class CommonNewsFeedRepository {
|
|
|
|
|
|
final result = await dioEngine.requestNetResult(
|
|
|
// ApiConstants.apiServerTime, // api 地址
|
|
|
- '/api/v1/user/me/index/follows', // api 地址
|
|
|
+ '/api/v1/user/news-feed/feed/following', // api 地址
|
|
|
params: params,
|
|
|
headers: headers,
|
|
|
method: HttpMethod.GET,
|
|
@@ -56,16 +97,203 @@ class CommonNewsFeedRepository {
|
|
|
if (result.isSuccess) {
|
|
|
//重新赋值data或list
|
|
|
final json = result.getDataJson();
|
|
|
- // var data = NewsfeedForyouEntity.fromJson(json!);
|
|
|
+ var data = NewsfeedFollowingEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert(data: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ // news feed - foryou 列表
|
|
|
+ Future<HttpResult<Object>> fetchForyouList(
|
|
|
+ Map<String, dynamic>? data, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, dynamic> params = {};
|
|
|
+ params = data!;
|
|
|
+ Map<String, String> headers = {};
|
|
|
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
|
+ headers["Accept"] = "application/x.yyjobs-api.v1+json";
|
|
|
+
|
|
|
+ final result = await dioEngine.requestNetResult(
|
|
|
+ // ApiConstants.apiServerTime, // api 地址
|
|
|
+ '/api/v1/user/news-feed/feed/for-you', // api 地址
|
|
|
+ params: params,
|
|
|
+ headers: headers,
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ isShowLoadingDialog: false, //是否展示默认的Loading弹窗
|
|
|
+ networkDebounce: true, //是否防抖防止重复请求
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = NewsfeedForyouEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert(data: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取 详情信息
|
|
|
+ Future<HttpResult<Object>> fetchNewsFeedDetailInfo(
|
|
|
+ Map<String, dynamic>? data, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, dynamic> params = {};
|
|
|
+ params = data!;
|
|
|
+ Map<String, String> headers = {};
|
|
|
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
|
+ headers["Accept"] = "application/x.yyjobs-api.v1+json";
|
|
|
+
|
|
|
+ final result = await dioEngine.requestNetResult(
|
|
|
+ // ApiConstants.apiServerTime, // api 地址
|
|
|
+ '/api/v1/user/news-feed/feed/detail', // api 地址
|
|
|
+ params: params,
|
|
|
+ headers: headers,
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ isShowLoadingDialog: false, //是否展示默认的Loading弹窗
|
|
|
+ networkDebounce: true, //是否防抖防止重复请求
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = NewsfeedDetailEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert(data: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提交评论
|
|
|
+ Future<HttpResult<Object>> fetchNewsfeedCommentSubmit(
|
|
|
+ Map<String, dynamic>? data, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, dynamic> params = {};
|
|
|
+ params = data!;
|
|
|
+ Map<String, String> headers = {};
|
|
|
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
|
+ headers["Accept"] = "application/x.yyjobs-api.v1+json";
|
|
|
+
|
|
|
+ final result = await dioEngine.requestNetResult(
|
|
|
+ // ApiConstants.apiServerTime, // api 地址
|
|
|
+ '/api/v1/user/news-feed/comment/publish', // api 地址
|
|
|
+ params: params,
|
|
|
+ headers: headers,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ isShowLoadingDialog: true, //是否展示默认的Loading弹窗
|
|
|
+ networkDebounce: true, //是否防抖防止重复请求
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = NewsfeedCommentPublishEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert(data: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ // news feed - post 发布newsfeed
|
|
|
+ Future<HttpResult<Object>> fetchNewsfeedPublish(
|
|
|
+ Map<String, dynamic>? data, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, dynamic> params = {};
|
|
|
+ params = data!;
|
|
|
+ Map<String, String> headers = {};
|
|
|
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
|
+ headers["Accept"] = "application/x.yyjobs-api.v1+json";
|
|
|
+
|
|
|
+ final result = await dioEngine.requestNetResult(
|
|
|
+ // ApiConstants.apiServerTime, // api 地址
|
|
|
+ '/api/v1/user/news-feed/index/publish', // api 地址
|
|
|
+ params: params,
|
|
|
+ headers: headers,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ isShowLoadingDialog: true, //是否展示默认的Loading弹窗
|
|
|
+ networkDebounce: true, //是否防抖防止重复请求
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ // var data = NewsfeedCommentPublishEntity.fromJson(json!);
|
|
|
//重新赋值data或list
|
|
|
return result.convert(data: json);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
}
|
|
|
return result.convert();
|
|
|
}
|
|
|
|
|
|
|
|
|
+ // 获取 我关注的人
|
|
|
+ Future<HttpResult<Object>> fetchMyFollowList(
|
|
|
+ Map<String, dynamic>? data, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, dynamic> params = {};
|
|
|
+ params = data!;
|
|
|
+ Map<String, String> headers = {};
|
|
|
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
|
+ headers["Accept"] = "application/x.yyjobs-api.v1+json";
|
|
|
+
|
|
|
+ final result = await dioEngine.requestNetResult(
|
|
|
+ // ApiConstants.apiServerTime, // api 地址
|
|
|
+ '/api/v1/user/me/index/follows', // api 地址
|
|
|
+ params: params,
|
|
|
+ headers: headers,
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ isShowLoadingDialog: false, //是否展示默认的Loading弹窗
|
|
|
+ networkDebounce: true, //是否防抖防止重复请求
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final ListJson = result.getListJson();
|
|
|
+ var data = ListJson!.map((e) => MyfollowingListEntity.fromJson(e!)).toList();
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert(list: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
// 获取 关注我的人
|
|
|
- Future<HttpResult<Object>> fetchMyFollowerList(
|
|
|
+ Future<HttpResult<Object>> fetchMyFlowerList(
|
|
|
Map<String, dynamic>? data, {
|
|
|
CancelToken? cancelToken,
|
|
|
}) async {
|
|
@@ -89,10 +317,50 @@ class CommonNewsFeedRepository {
|
|
|
//根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
if (result.isSuccess) {
|
|
|
//重新赋值data或list
|
|
|
- final json = result.getDataJson();
|
|
|
+ final ListJson = result.getListJson();
|
|
|
+ var data = ListJson!.map((e) => MyfollowingListEntity.fromJson(e!)).toList();
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert(list: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ // news feed 点赞/取消点赞
|
|
|
+ Future<HttpResult<Object>> fetchLikeClick(
|
|
|
+ Map<String, dynamic>? data, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, dynamic> params = {};
|
|
|
+ params = data!;
|
|
|
+ Map<String, String> headers = {};
|
|
|
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
|
+ headers["Accept"] = "application/x.yyjobs-api.v1+json";
|
|
|
+
|
|
|
+ final result = await dioEngine.requestNetResult(
|
|
|
+ // ApiConstants.apiServerTime, // api 地址
|
|
|
+ '/api/v1/user/news-feed/like/click', // api 地址
|
|
|
+ params: params,
|
|
|
+ headers: headers,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ isShowLoadingDialog: true, //是否展示默认的Loading弹窗
|
|
|
+ networkDebounce: true, //是否防抖防止重复请求
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final boolData = result.getDataDynamic();
|
|
|
// var data = NewsfeedForyouEntity.fromJson(json!);
|
|
|
//重新赋值data或list
|
|
|
- return result.convert(data: json);
|
|
|
+ return result.convert(data: boolData);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
}
|
|
|
return result.convert();
|
|
|
}
|
|
@@ -125,6 +393,10 @@ class CommonNewsFeedRepository {
|
|
|
// var data = NewsfeedForyouEntity.fromJson(json!);
|
|
|
//重新赋值data或list
|
|
|
return result.convert(data: json);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
}
|
|
|
return result.convert();
|
|
|
}
|
|
@@ -158,6 +430,10 @@ class CommonNewsFeedRepository {
|
|
|
// var data = NewsfeedDetailEntity.fromJson(json!);
|
|
|
//重新赋值data或list
|
|
|
return result.convert(data: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
}
|
|
|
return result.convert();
|
|
|
}
|
|
@@ -191,6 +467,10 @@ class CommonNewsFeedRepository {
|
|
|
// var data = NewsfeedDetailEntity.fromJson(json!);
|
|
|
//重新赋值data或list
|
|
|
return result.convert(data: data);
|
|
|
+ }else {
|
|
|
+ if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
|
|
|
+ ToastEngine.show("${result.errorMsg}");
|
|
|
+ }
|
|
|
}
|
|
|
return result.convert();
|
|
|
}
|