|
| 1 | +// |
| 2 | +// Project.m |
| 3 | +// Coding_iOS |
| 4 | +// |
| 5 | +// Created by Ease on 15/4/23. |
| 6 | +// Copyright (c) 2015年 Coding. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#import "Project.h" |
| 10 | +#import "Login.h" |
| 11 | + |
| 12 | +@implementation Project |
| 13 | +- (instancetype)init |
| 14 | +{ |
| 15 | + self = [super init]; |
| 16 | + if (self) { |
| 17 | + _isStaring = _isWatching = _isLoadingMember = _isLoadingDetail = NO; |
| 18 | + _readMeHeight = 1; |
| 19 | + _recommended = [NSNumber numberWithInteger:0]; |
| 20 | + } |
| 21 | + return self; |
| 22 | +} |
| 23 | ++(Project *)project_All{ |
| 24 | + Project *pro = [[Project alloc] init]; |
| 25 | + pro.id = [NSNumber numberWithInteger:-1]; |
| 26 | + return pro; |
| 27 | +} |
| 28 | + |
| 29 | ++ (Project *)project_FeedBack{ |
| 30 | + Project *pro = [[Project alloc] init]; |
| 31 | + pro.id = [NSNumber numberWithInteger:38894];//iOS公开项目 |
| 32 | + pro.is_public = [NSNumber numberWithBool:YES]; |
| 33 | + return pro; |
| 34 | +} |
| 35 | + |
| 36 | +-(NSString *)toProjectPath{ |
| 37 | + return @"api/project"; |
| 38 | +} |
| 39 | + |
| 40 | +-(NSDictionary *)toCreateParams{ |
| 41 | + |
| 42 | + NSString *type; |
| 43 | + if ([self.is_public isEqual:@YES]) { |
| 44 | + type = @"1"; |
| 45 | + }else{ |
| 46 | + type = @"2"; |
| 47 | + } |
| 48 | + |
| 49 | + return @{@"name":self.name, |
| 50 | + @"description":self.description_mine, |
| 51 | + @"type":type, |
| 52 | + @"gitEnabled":@"true", |
| 53 | + @"gitReadmeEnabled":@"true", |
| 54 | + @"gitIgnore":@"no", |
| 55 | + @"gitLicense":@"no", |
| 56 | + // @"importFrom":@"no", |
| 57 | + @"vcsType":@"git"}; |
| 58 | +} |
| 59 | + |
| 60 | +-(NSString *)toUpdatePath{ |
| 61 | + return [self toProjectPath]; |
| 62 | +} |
| 63 | + |
| 64 | +-(NSDictionary *)toUpdateParams{ |
| 65 | + return @{@"name":self.name, |
| 66 | + @"description":self.description_mine, |
| 67 | + @"id":self.id |
| 68 | + // @"default_branch":[NSNull null] |
| 69 | + }; |
| 70 | +} |
| 71 | + |
| 72 | +-(NSString *)toUpdateIconPath{ |
| 73 | + return [NSString stringWithFormat:@"api/project/%@/project_icon",self.id]; |
| 74 | +} |
| 75 | + |
| 76 | +-(NSString *)toDeletePath{ |
| 77 | + return [NSString stringWithFormat:@"api/project/%@",self.id]; |
| 78 | +} |
| 79 | + |
| 80 | +-(NSDictionary *)toDeleteParamsWithPassword:(NSString *)password{ |
| 81 | + return @{@"user_name":[Login curLoginUser].name, |
| 82 | + @"name":self.name, |
| 83 | + @"porject_id":[self.id stringValue], |
| 84 | + @"password":[password sha1Str]}; |
| 85 | +} |
| 86 | + |
| 87 | +- (NSString *)toMembersPath{ |
| 88 | + return [NSString stringWithFormat:@"api/project/%d/members", self.id.intValue]; |
| 89 | +} |
| 90 | +- (NSDictionary *)toMembersParams{ |
| 91 | + return @{@"page" : [NSNumber numberWithInteger:1], |
| 92 | + @"pageSize" : [NSNumber numberWithInteger:500]}; |
| 93 | +} |
| 94 | +- (NSString *)toUpdateVisitPath{ |
| 95 | + if (self.owner_user_name.length > 0 && self.name.length > 0) { |
| 96 | + return [NSString stringWithFormat:@"api/user/%@/project/%@/update_visit", self.owner_user_name, self.name]; |
| 97 | + }else{ |
| 98 | + return [NSString stringWithFormat:@"api/project/%d/update_visit", self.id.intValue]; |
| 99 | + } |
| 100 | +} |
| 101 | +- (NSString *)toDetailPath{ |
| 102 | + return [NSString stringWithFormat:@"api/user/%@/project/%@", self.owner_user_name, self.name]; |
| 103 | +} |
| 104 | +- (NSString *)localMembersPath{ |
| 105 | + return [NSString stringWithFormat:@"%@_MembersPath", self.id.stringValue]; |
| 106 | +} |
| 107 | + |
| 108 | +- (NSString *)toBranchOrTagPath:(NSString *)path{ |
| 109 | + return [NSString stringWithFormat:@"api/user/%@/project/%@/git/%@", self.owner_user_name, self.name, path]; |
| 110 | +} |
| 111 | +- (NSString *)description_mine{ |
| 112 | + if (_description_mine && _description_mine.length > 0) { |
| 113 | + return _description_mine; |
| 114 | + }else{ |
| 115 | + return @"未填写"; |
| 116 | + } |
| 117 | +} |
| 118 | +@end |
0 commit comments