Initial commit
This commit is contained in:
+80
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// UMComFeedEditDataController.h
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by umeng on 16/5/3.
|
||||
// Copyright © 2016年 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UMCommunitySDK/UMComDataRequestManager.h>
|
||||
|
||||
@class CLLocation, UMComFeed;
|
||||
@interface UMComFeedEditDataController : NSObject
|
||||
|
||||
|
||||
/**
|
||||
消息文字内容
|
||||
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *text;
|
||||
|
||||
/**
|
||||
消息标题
|
||||
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *title;
|
||||
|
||||
/**
|
||||
消息创建者的用户id
|
||||
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *uid;
|
||||
|
||||
/**
|
||||
消息的图片附件,images中的对象只可以是UIImage类对象或者直接是图片的urlString
|
||||
|
||||
*/
|
||||
@property (nonatomic, strong) NSArray *images;
|
||||
|
||||
/**
|
||||
消息的相关话题
|
||||
|
||||
*/
|
||||
@property (nonatomic, strong) NSArray *topics;
|
||||
|
||||
/**
|
||||
@相关好友
|
||||
|
||||
*/
|
||||
@property (nonatomic, strong) NSArray *atUsers;
|
||||
|
||||
/**
|
||||
地理位置描述
|
||||
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *locationDescription;
|
||||
|
||||
/**
|
||||
地理位置坐标对象
|
||||
|
||||
*/
|
||||
@property (nonatomic, strong) CLLocation *location;
|
||||
|
||||
/**
|
||||
消息类型
|
||||
*/
|
||||
@property (nonatomic, strong) NSNumber *type;
|
||||
|
||||
/**
|
||||
自定义字段
|
||||
*/
|
||||
@property (nonatomic, copy) NSString * customContent;
|
||||
|
||||
|
||||
- (void)createFeedWithCompletion:(UMComDataRequestCompletion)completion;
|
||||
|
||||
- (void)forwardFeedWithFeed:(UMComFeed *)feed
|
||||
completion:(UMComDataRequestCompletion)completion;
|
||||
|
||||
@end
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// UMComFeedEditDataController.m
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by umeng on 16/5/3.
|
||||
// Copyright © 2016年 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UMComFeedEditDataController.h"
|
||||
#import <UMComDataStorage/UMComFeed.h>
|
||||
#import <UMCommunitySDK/UMComDataTypeDefine.h>
|
||||
#import <UMCommunitySDK/UMComSession.h>
|
||||
#import "UMComNotificationMacro.h"
|
||||
|
||||
@implementation UMComFeedEditDataController
|
||||
|
||||
- (void)createFeedWithCompletion:(UMComDataRequestCompletion)completion
|
||||
{
|
||||
NSArray *topic_ids = nil;
|
||||
if (self.topics.count > 0) {
|
||||
topic_ids = [self.topics valueForKeyPath:@"topicID"];
|
||||
}
|
||||
NSArray *uids = nil;
|
||||
if (self.atUsers.count > 0) {
|
||||
uids = [self.atUsers valueForKeyPath:@"uid"];
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[UMComDataRequestManager feedCreateWithContent:self.text
|
||||
title:self.title
|
||||
location:self.location
|
||||
locationName:self.locationDescription
|
||||
related_uids:uids
|
||||
topic_ids:topic_ids
|
||||
images:self.images
|
||||
type:self.type
|
||||
custom:self.customContent completion:^(NSDictionary *responseObject, NSError *error) {
|
||||
|
||||
if (responseObject && [responseObject isKindOfClass:[NSDictionary class]] && !error) {
|
||||
id feed = [responseObject valueForKey:UMComModelDataKey];
|
||||
if (feed && [feed isKindOfClass:[UMComFeed class]]) {
|
||||
[weakSelf createFeedSucceedWithFeed:feed completion:completion];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (completion) {
|
||||
completion(responseObject,error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
- (void)forwardFeedWithFeed:(UMComFeed *)forwordFeed completion:(UMComDataRequestCompletion)completion
|
||||
{
|
||||
NSArray *topic_ids = nil;
|
||||
if (self.topics.count > 0) {
|
||||
topic_ids = [self.topics valueForKeyPath:@"topicID"];
|
||||
}
|
||||
NSArray *uids = nil;
|
||||
if (self.atUsers.count > 0) {
|
||||
uids = [self.atUsers valueForKeyPath:@"uid"];
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[[UMComDataRequestManager defaultManager] feedForwardWithFeedID:forwordFeed.feedID
|
||||
content:self.text
|
||||
topic_ids:topic_ids
|
||||
relatedUids:uids
|
||||
feedType:[self.type integerValue]
|
||||
locationName:self.locationDescription location:self.location
|
||||
custom:self.customContent completion:^(NSDictionary *responseObject, NSError *error) {
|
||||
|
||||
if (responseObject && [responseObject isKindOfClass:[NSDictionary class]] && !error) {
|
||||
UMComFeed *feed = [responseObject valueForKey:UMComModelDataKey];
|
||||
if (feed && [feed isKindOfClass:[UMComFeed class]]) {
|
||||
if (forwordFeed.origin_feed) {
|
||||
NSInteger feedCount = [forwordFeed.forward_count integerValue];
|
||||
feedCount += 1;
|
||||
forwordFeed.forward_count = @(feedCount);
|
||||
}
|
||||
[weakSelf createFeedSucceedWithFeed:feed completion:completion];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (completion) {
|
||||
completion(nil,error);
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (void)createFeedSucceedWithFeed:(UMComFeed *)newFeed completion:(UMComDataRequestCompletion)completion
|
||||
{
|
||||
UMComUser *loginUser = [UMComSession sharedInstance].loginUser;
|
||||
loginUser.feed_count = @(loginUser.feed_count.integerValue + 1);
|
||||
if (completion) {
|
||||
completion(newFeed,nil);
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationPostFeedResultNotification object:newFeed];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user