forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.m
More file actions
128 lines (113 loc) · 3.47 KB
/
Project.m
File metadata and controls
128 lines (113 loc) · 3.47 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
// Project.m
// Coding_iOS
//
// Created by Ease on 15/4/23.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#import "Project.h"
#import "Login.h"
@implementation Project
- (instancetype)init
{
self = [super init];
if (self) {
_isStaring = _isWatching = _isLoadingMember = _isLoadingDetail = NO;
_recommended = [NSNumber numberWithInteger:0];
}
return self;
}
- (void)setFull_name:(NSString *)full_name{
_full_name = full_name;
NSArray *components = [_full_name componentsSeparatedByString:@"/"];
if (components.count == 2) {
if (!_owner_user_name) {
_owner_user_name = components[0];
}
if (_name) {
_name = components[1];
}
}
}
+(Project *)project_All{
Project *pro = [[Project alloc] init];
pro.id = [NSNumber numberWithInteger:-1];
return pro;
}
+ (Project *)project_FeedBack{
Project *pro = [[Project alloc] init];
pro.id = [NSNumber numberWithInteger:38894];//iOS公开项目
pro.is_public = [NSNumber numberWithBool:YES];
return pro;
}
-(NSString *)toProjectPath{
return @"api/project";
}
-(NSDictionary *)toCreateParams{
NSString *type;
if ([self.is_public isEqual:@YES]) {
type = @"1";
}else{
type = @"2";
}
return @{@"name":self.name,
@"description":self.description_mine,
@"type":type,
@"gitEnabled":@"true",
@"gitReadmeEnabled":@"true",
@"gitIgnore":@"no",
@"gitLicense":@"no",
// @"importFrom":@"no",
@"vcsType":@"git"};
}
-(NSString *)toUpdatePath{
return [self toProjectPath];
}
-(NSDictionary *)toUpdateParams{
return @{@"name":self.name,
@"description":self.description_mine,
@"id":self.id
// @"default_branch":[NSNull null]
};
}
-(NSString *)toUpdateIconPath{
return [NSString stringWithFormat:@"api/project/%@/project_icon",self.id];
}
-(NSString *)toDeletePath{
return [NSString stringWithFormat:@"api/user/%@/project/%@",self.owner_user_name, self.name];
}
- (NSString *)toMembersPath{
if ([_id isKindOfClass:[NSNumber class]]) {
return [NSString stringWithFormat:@"api/project/%d/members", self.id.intValue];
}else{
return [NSString stringWithFormat:@"api/user/%@/project/%@/members", _owner_user_name, _name];
}
}
- (NSDictionary *)toMembersParams{
return @{@"page" : [NSNumber numberWithInteger:1],
@"pageSize" : [NSNumber numberWithInteger:500]};
}
- (NSString *)toUpdateVisitPath{
if (self.owner_user_name.length > 0 && self.name.length > 0) {
return [NSString stringWithFormat:@"api/user/%@/project/%@/update_visit", self.owner_user_name, self.name];
}else{
return [NSString stringWithFormat:@"api/project/%d/update_visit", self.id.intValue];
}
}
- (NSString *)toDetailPath{
return [NSString stringWithFormat:@"api/user/%@/project/%@", self.owner_user_name, self.name];
}
- (NSString *)localMembersPath{
return [NSString stringWithFormat:@"%@_MembersPath", self.id.stringValue];
}
- (NSString *)toBranchOrTagPath:(NSString *)path{
return [NSString stringWithFormat:@"api/user/%@/project/%@/git/%@", self.owner_user_name, self.name, path];
}
//- (NSString *)description_mine{
// if (_description_mine && _description_mine.length > 0) {
// return _description_mine;
// }else{
// return @"未填写";
// }
//}
@end