123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- //
- // XYFeedAPIManager.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/5/28.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYFeedAPIManager.h"
- /// 创建内容
- static NSString * const FEED_CREATE_FEED = @"api-app/v1/feed/createFeed";
- /// 获取相册
- static NSString * const FEED_GET_PHOTO_LIST = @"api-app/v1/feed/getPhotoList";
- /// 获取视频
- static NSString * const FEED_GET_VIDEO_LIST = @"api-app/v1/feed/getVideoList";
- /// 获取视频(游客)
- static NSString * const FEED_GET_VIDEO_LIST_GUEST = @"api-app/v1/feed/getVideoListGuest";
- /// 添加评论
- static NSString * const FEED_ADD_COMMENT = @"api-app/v1/feed/addComment";
- /// 获取评论
- static NSString * const FEED_GET_COMMENT_LIST = @"api-app/v1/feed/getCommentList";
- /// 获取子评论
- static NSString * const FEED_GET_CHILD_COMMENT_LIST = @"api-app/v1/feed/getChildCommentList";
- /// 添加动作
- static NSString * const FEED_ADD_ACTION = @"api-app/v1/feed/addAction";
- /// 删除内容
- static NSString * const DEL_FEED_ACTION = @"api-app/v1/feed/delFeed";
- /// 发现
- static NSString * const FEED_FINDLIST_PATH = @"api-app/v1/feed/getVideoStreamList";
- /// 删除评论
- static NSString * const FEED_DELETE_COMMENT = @"api-app/v1/feed/delComment";
- /// 删除内容
- static NSString * const FEED_DELETE_FEED = @"api-app/v1/feed/delFeed";
- /// 添加内容查看数
- static NSString * const FEED_ADD_VIEW_COUNT = @"api-app/v1/feed/addViewCount";
- /// 获取内容详情
- static NSString * const FEED_GET_FEED_DEAIL = @"api-app/v1/feed/getFeedDetail";
- /// 创建照片墙
- static NSString * const FEED_CREATE_PHOTO_WALL = @"api-app/v1/feed/createPhotoWall";
- /// 获取照片墙列表
- static NSString * const FEED_GET_PHOTO_WALL_LIST = @"api-app/v1/feed/getPhotoWallList";
- /// 删除照片墙
- static NSString * const FEED_DELETE_PHOTO_WALL = @"api-app/v1/feed/deletePhotoWall";
- /// 获取内容按天分组分页列表
- static NSString * const FEED_GET_FEED_BY_DATA_PAGE_LIST = @"api-app/v1/feed/getFeedByDatePageList";
- /// 获取广场动态
- static NSString * const FEED_GET_SQUARE_FEED_LIST = @"api-app/v1/feed/getSquareFeedList";
- /// 点赞
- static NSString * const FEED_THUMBS_UP = @"api-app/v1/feed/thumbsUp";
- /// 随机获取一个三天内发表过状态的关注的用户
- static NSString * const FEED_USER_FOLLOW_NAME = @"api-app/v1/feed/getUserFollowName";
- /// 获取首页资讯接口
- static NSString * const FEED_GET_FEED_ACTIVITY_INFO_LIST = @"api-app/v1/feed/getFeedActivityInfoList";
- @implementation XYFeedAPIManager
- /// 创建内容
- /// @param parameters 参数 https://pt.laylib.com/console/api?p=120592570081591296&i=1162
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)createFeedWithParameters:(NSDictionary *)parameters successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_CREATE_FEED copy];
- config.instructions = @"创建内容";
-
- config.requestParameters = parameters;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取相册
- /// @param lastId 最后一条id
- /// @param userId 用户id 不传看自己
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getPhotoListWithLastId:(NSString *)lastId userId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_GET_PHOTO_LIST copy];
- config.instructions = @"获取相册";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
- [parameters setObject:lastId forKey:@"lastId"];
- if (StringIsNotEmpty(userId) && ![userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
- [parameters setObject:userId forKey:@"userId"];
- }
- config.requestParameters = parameters;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取视频列表
- /// @param lastId 最后一条id
- /// @param userId 用户id 不传看自己
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getVideoListWithLastId:(NSString *)lastId userId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- if ([XYUserInfoManager nowUser]) {
- config.urlPath = [FEED_GET_VIDEO_LIST copy];
- config.instructions = @"获取视频列表";
- }else {
- config.urlPath = [FEED_GET_VIDEO_LIST_GUEST copy];
- config.instructions = @"获取视频(游客)";
- }
- config.requestType = ZYLNetworkRequestTypeGet;
-
- NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
- [parameters addEntriesFromDictionary:@{@"lastId":lastId}];
- if (StringIsNotEmpty(userId) && ![userId isEqualToString:[XYUserInfoManager nowUser].userId]) {
- [parameters addEntriesFromDictionary:@{@"userId":userId}];
- }
- config.requestParameters = parameters;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 添加评论
- /// @param feedId 内容id
- /// @param replyId 答复id
- /// @param origReplyId 最顶层答复id
- /// @param replyUserId 答复用户id
- /// @param content 评论内容
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)feedAddCommentWithFeedId:(NSString *)feedId replyId:(NSString *)replyId origReplyId:(NSString *)origReplyId replyUserId:(NSString *)replyUserId content:(NSString *)content successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_ADD_COMMENT copy];
- config.instructions = @"添加评论";
-
- NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
- [parameters addEntriesFromDictionary:@{@"feedId":feedId}];
-
- if (StringIsNotEmpty(replyId)) {
- [parameters addEntriesFromDictionary:@{@"replyId":replyId}];
- }
- if (StringIsNotEmpty(origReplyId)) {
- [parameters addEntriesFromDictionary:@{@"origReplyId":origReplyId}];
- }
- if (StringIsNotEmpty(replyUserId)) {
- [parameters addEntriesFromDictionary:@{@"replyUserId":replyUserId}];
- }
- if (StringIsNotEmpty(content)) {
- [parameters addEntriesFromDictionary:@{@"content":content}];
- }
- config.requestParameters = parameters;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取评论
- /// @param feedId 内容id
- /// @param lastId 分页id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getCommentListWithFeedId:(NSString *)feedId lastId:(NSString *)lastId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_GET_COMMENT_LIST copy];
- config.instructions = @"获取评论";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
- [parameters addEntriesFromDictionary:@{@"feedId":feedId}];
-
- if (StringIsNotEmpty(lastId)) {
- [parameters addEntriesFromDictionary:@{@"lastId":lastId}];
- }
- config.requestParameters = parameters;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取子评论
- /// @param lastId 最后一条id
- /// @param commentId 当前评论的id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getChildCommentListWithLastId:(NSString *)lastId commentId:(NSString *)commentId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_GET_CHILD_COMMENT_LIST copy];
- config.instructions = @"获取子评论";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
- [parameters addEntriesFromDictionary:@{@"commentId":commentId}];
-
- if (StringIsNotEmpty(lastId)) {
- [parameters addEntriesFromDictionary:@{@"lastId":lastId}];
- }
- config.requestParameters = parameters;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 添加动作
- /// @param targetId 目标id
- /// @param actionType 动作类型 点赞:10 点赞取消:11 收藏:20 收藏-取消:21 分享:30
- /// @param targetType 目标类型 图文:10 照片:20 视频:30 评论:40
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)addActionWithTargetId:(NSString *)targetId actionType:(NSInteger)actionType targetType:(NSInteger)targetType successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_ADD_ACTION copy];
- config.instructions = @"添加动作";
-
- config.requestParameters = @{@"targetId":targetId, @"actionType":@(actionType), @"targetType":@(targetType)};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- //发现
- //Query lastId 最后一条id Long
- - (NSNumber *)getVideoStreamListWithLastId:(NSString *)lastId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler{
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_FINDLIST_PATH copy];
- config.instructions = @"发现";
- NSMutableDictionary *parm = [[NSMutableDictionary alloc] init];
- [parm setObject:lastId forKey:@"lastId"];
- config.requestParameters = parm;
- config.requestType = ZYLNetworkRequestTypeGet;
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 删除评论
- /// @param commentId 评论id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)delCommentWithCommentId:(NSString *)commentId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_DELETE_COMMENT copy];
- config.instructions = @"删除评论";
-
- config.requestParameters = @{@"commentId":commentId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 删除内容
- /// @param feedId 内容id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)delFeedWithFeedId:(NSString *)feedId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_DELETE_FEED copy];
- config.instructions = @"删除内容";
-
- config.requestParameters = @{@"feedId":feedId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 添加内容查看数
- /// @param feedId 内容id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)addViewCountWithFeedId:(NSString *)feedId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_ADD_VIEW_COUNT copy];
- config.instructions = @"添加内容查看数";
-
- config.requestParameters = @{@"feedId":feedId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- //获取内容详情
- //Query feedId 内容Id Long
- - (NSNumber *)getFeedDetailWithFeedId:(NSString *)feedId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler{
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_GET_FEED_DEAIL copy];
- config.instructions = @"获取内容详情";
- NSMutableDictionary *parm = [[NSMutableDictionary alloc] init];
- [parm setObject:feedId forKey:@"feedId"];
- config.requestParameters = parm;
- config.requestType = ZYLNetworkRequestTypeGet;
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 创建照片墙
- /// @param url 照片链接地址
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)createPhotoWallWithUrl:(NSString *)url successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_CREATE_PHOTO_WALL copy];
- config.instructions = @"创建照片墙";
-
- config.requestParameters = @{@"url":url};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取照片墙
- /// @param userId 用户id 不传则查询自己的照片墙
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getPhotoWallWithUserId:(NSString *)userId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_GET_PHOTO_WALL_LIST copy];
- config.instructions = @"获取照片墙";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- if (![[XYUserInfoManager nowUser].userId isEqualToString:userId] && StringIsNotEmpty(userId)) {
- config.requestParameters = @{@"userId":userId};
- }
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 删除照片墙
- /// @param photoWallId 照片墙id
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)deletePhotoWallWithiPhotoWallId:(NSString *)photoWallId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_DELETE_PHOTO_WALL copy];
- config.instructions = @"删除照片墙";
-
- config.requestParameters = @{@"id":photoWallId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取内容按天分组分页列表
- /// @param userId 用户id
- /// @param pageNum 当前页码
- /// @param pageSize 分页大小
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getFeedByDatePageListWithUserId:(NSString *)userId pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_GET_FEED_BY_DATA_PAGE_LIST copy];
- config.instructions = @"获取内容按天分组分页列表";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- if (StringIsEmpty(userId)) {
- config.requestParameters = @{@"userId":@"0", @"pageNum":@(pageNum), @"pageSize":@(pageSize)};
- }else {
- config.requestParameters = @{@"userId":userId, @"pageNum":@(pageNum), @"pageSize":@(pageSize)};
- }
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取广场动态
- /// @param pageNum 当前页码
- /// @param pageSize 分页大小
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getSquareFeedListWithPageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_GET_SQUARE_FEED_LIST copy];
- config.instructions = @"获取广场动态";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- config.requestParameters = @{@"pageNum":@(pageNum), @"pageSize":@(pageSize)};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 动态点赞
- /// @param feedId 动态ID
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)thumbsUpWithFeedId:(NSString *)feedId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_THUMBS_UP copy];
- config.instructions = @"动态点赞";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- config.requestParameters = @{@"feedId":feedId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 随机获取一个三天内发表过状态的关注的用户
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getUserFollowNameSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_USER_FOLLOW_NAME copy];
- config.instructions = @"随机获取一个三天内发表过状态的关注的用户";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /// 获取首页资讯接口
- /// @param successHandler 请求成功
- /// @param failureHandler 请求失败
- - (NSNumber *)getFeedActivityInfoListSuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [FEED_GET_FEED_ACTIVITY_INFO_LIST copy];
- config.instructions = @"获取首页资讯接口";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- @end
|