DynamicViewModel.m
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// DynamicViewModel.m
// DreamSleep
//
// Created by peter on 2022/9/24.
//
#import "DynamicViewModel.h"
@implementation DynamicViewModel
- (instancetype)init {
if (self = [super init]) {
self.selectedPhotos = [NSMutableArray array];
self.selectedAssets = [NSMutableArray array];
self.content = @"";
self.imgs_url = @"";
}
return self;
}
- (NSURLSessionDataTask *)publishDynamicWithCompletion:(void (^)(DynamicViewModel *viewModel))completion {
NSString *api = @"publish_dynamic_data";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(content:\"%@\",imgs_url:\"%@\")}", api, self.content, self.imgs_url];
return [DynamicViewModel httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户发布动态接口apiDic:%@", apiDic);
NSDictionary *resultDic = apiDic[@"result"];
self.myDynModel = [ComDynModel yy_modelWithDictionary:resultDic];
self.resCode = DSResCodeSuccess;
completion(self);
} failure:^(id _Nonnull failureInfo) {
self.resCode = [failureInfo[@"errorCode"] integerValue];
self.errMessage = failureInfo[@"errMessage"];
completion(self);
}];
}
@end