forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectTopics.m
More file actions
executable file
·79 lines (70 loc) · 2.34 KB
/
ProjectTopics.m
File metadata and controls
executable file
·79 lines (70 loc) · 2.34 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// ProjectTopics.m
// Coding_iOS
//
// Created by 王 原闯 on 14-8-20.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "ProjectTopics.h"
@implementation ProjectTopics
- (instancetype)init
{
self = [super init];
if (self) {
_propertyArrayMap = [NSDictionary dictionaryWithObjectsAndKeys:
@"ProjectTopic", @"list", nil];
_page = [NSNumber numberWithInteger:1];
_pageSize = [NSNumber numberWithInteger:20];
_labelID = [NSNumber numberWithInteger:0];
_canLoadMore = YES;
_isLoading = _willLoadMore = NO;
_queryType = TopicQueryTypeAll;
_labelType = LabelOrderTypeUpdate;
}
return self;
}
+ (ProjectTopics *)topicsWithPro:(Project *)project queryType:(TopicQueryType)type
{
ProjectTopics *topics = [[ProjectTopics alloc] init];
topics.project = project;
topics.queryType = type;
return topics;
}
- (NSDictionary *)toParams
{
NSDictionary *dict;
if (_labelID && [_labelID integerValue] > 0 ) {
dict = @{@"page" : (_willLoadMore? [NSNumber numberWithInteger:_page.intValue+1] : [NSNumber numberWithInteger:1]),
@"pageSize" : _pageSize,
@"type" : (_queryType == TopicQueryTypeAll ? @"all" : @"my"),
@"orderBy" : [NSNumber numberWithInteger:_labelType],
@"labelId" : _labelID
};
} else {
dict = @{@"page" : (_willLoadMore? [NSNumber numberWithInteger:_page.intValue+1] : [NSNumber numberWithInteger:1]),
@"pageSize" : _pageSize,
@"type" : (_queryType == TopicQueryTypeAll ? @"all" : @"my"),
@"orderBy" : [NSNumber numberWithInteger:_labelType]
};
}
return dict;
}
- (NSString *)toRequestPath
{
NSString *path;
path = [NSString stringWithFormat:@"api/user/%@/project/%@/topics/mobile", _project.owner_user_name, _project.name];
return path;
}
- (void)configWithTopics:(ProjectTopics *)resultA
{
self.page = resultA.page;
self.totalPage = resultA.totalPage;
self.totalRow = resultA.totalRow;
if (_willLoadMore) {
[self.list addObjectsFromArray:resultA.list];
}else{
self.list = [NSMutableArray arrayWithArray:resultA.list];
}
self.canLoadMore = self.page.intValue < self.totalPage.intValue;
}
@end