forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectFolder.m
More file actions
executable file
·80 lines (77 loc) · 2.39 KB
/
ProjectFolder.m
File metadata and controls
executable file
·80 lines (77 loc) · 2.39 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
80
//
// ProjectFolder.m
// Coding_iOS
//
// Created by Ease on 14/11/13.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "ProjectFolder.h"
@implementation ProjectFolder
+ (ProjectFolder *)defaultFolder{
ProjectFolder *folder = [[ProjectFolder alloc] init];
folder.file_id = [NSNumber numberWithInteger:0];
folder.name = @"默认文件夹";
return folder;
}
+ (ProjectFolder *)folderWithId:(NSNumber *)file_id{
ProjectFolder *folder = [[ProjectFolder alloc] init];
folder.sub_folders = [NSMutableArray array];
folder.file_id = file_id;
return folder;
}
- (ProjectFolder *)hasFolderWithId:(NSNumber *)file_id{
if (!file_id || !_file_id) {
return nil;
}
if (_file_id.integerValue == file_id.integerValue) {
return self;
}else{
for (ProjectFolder *sub_folder in self.sub_folders) {
if (sub_folder.file_id.integerValue == file_id.integerValue) {
return sub_folder;
}
}
}
return nil;
}
- (instancetype)init
{
self = [super init];
if (self) {
_propertyArrayMap = [NSDictionary dictionaryWithObjectsAndKeys:
@"ProjectFolder", @"sub_folders", nil];
}
return self;
}
- (BOOL)isDefaultFolder{
return !(_file_id && _file_id.integerValue != 0);
}
- (BOOL)canCreatSubfolder{
return !((_parent_id && _parent_id.integerValue != 0) || [self isDefaultFolder]);
}
- (NSInteger)fileCountIncludeSub{
NSInteger fileCount = self.count.integerValue;
for (ProjectFolder *subFolder in self.sub_folders) {
fileCount += subFolder.fileCountIncludeSub;
}
return fileCount;
}
- (NSString *)toFilesPath{
return [NSString stringWithFormat:@"api/project/%@/files/%@", _project_id.stringValue, _file_id.stringValue];
}
- (NSDictionary *)toFilesParams{
return @{@"height": @"90",
@"width": @"90",
@"page" : @"1",
@"pageSize": @"9999"};
}
- (NSString *)toRenamePath{
return [NSString stringWithFormat:@"api/project/%@/dir/%@/name/%@", _project_id.stringValue, _file_id.stringValue, _next_name];
}
- (NSString *)toDeletePath{
return [NSString stringWithFormat:@"api/project/%@/rmdir/%@", _project_id.stringValue, _file_id.stringValue];
}
- (NSString *)toMoveToPath{
return [NSString stringWithFormat:@"api/project/%@/files/moveto/%@", _project_id.stringValue, _file_id.stringValue];
}
@end