Skip to content

Commit 2c488e6

Browse files
张达棣张达棣
authored andcommitted
更新项目内的任务数量接口
1 parent 2f66f8f commit 2c488e6

2 files changed

Lines changed: 77 additions & 63 deletions

File tree

Coding_iOS/Controllers/ProjectViewController.m

Lines changed: 75 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -760,53 +760,86 @@ - (void)assignmentWithlistView:(ProjectTasksView *)listView {
760760
- (void)resetTaskCount {
761761
__weak typeof(self) weakSelf = self;
762762

763-
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithUserId:_userId role:TaskRoleTypeAll project_id:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
764-
NSInteger ownerDone, ownerProcessing;
765-
763+
if (_userId != nil) {
766764

767-
if (_userId == nil) {
768-
ownerDone = [data[@"data"][@"done"] integerValue];
769-
ownerProcessing = [data[@"data"][@"processing"] integerValue];
770-
} else {
771-
ownerDone = [data[@"data"][@"finished"] integerValue];
772-
ownerProcessing = [data[@"data"][@"processing"] integerValue];
773-
}
765+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithUserId:_userId role:TaskRoleTypeAll project_id:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
766+
NSInteger ownerDone = [data[@"data"][@"memberDone"] integerValue];
767+
NSInteger ownerProcessing = [data[@"data"][@"memberProcessing"] integerValue];
768+
NSInteger watcherDone = [data[@"data"][@"watcherDone"] integerValue];
769+
NSInteger watcherProcessing = [data[@"data"][@"watcherProcessing"] integerValue];
770+
NSInteger creatorDone = [data[@"data"][@"creatorDone"] integerValue];
771+
NSInteger creatorProcessing = [data[@"data"][@"creatorProcessing"] integerValue];
772+
773+
weakSelf.myFliterMenu.items = @[[NSString stringWithFormat:@"所有任务(%ld", ownerDone + ownerProcessing],
774+
[NSString stringWithFormat:@"我关注的(%ld", ownerDone + ownerProcessing],
775+
[NSString stringWithFormat:@"我创建的(%ld", ownerDone + ownerProcessing]
776+
];
777+
if (_role == TaskRoleTypeAll) {
778+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", ownerProcessing],
779+
[NSString stringWithFormat:@"已完成的(%ld", ownerDone]
780+
];
781+
}
774782

775-
weakSelf.myFliterMenu.items = @[[NSString stringWithFormat:@"所有任务(%ld", ownerDone + ownerProcessing],
776-
weakSelf.myFliterMenu.items[1],
777-
weakSelf.myFliterMenu.items[2]
778-
];
779-
if (_role == TaskRoleTypeAll) {
780-
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", ownerProcessing],
781-
[NSString stringWithFormat:@"已完成的(%ld", ownerDone]
782-
];
783-
}
783+
if (_role == TaskRoleTypeWatcher) {
784+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", watcherProcessing],
785+
[NSString stringWithFormat:@"已完成的(%ld", watcherDone]
786+
];
787+
}
788+
789+
if (_role == TaskRoleTypeCreator) {
790+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", creatorProcessing],
791+
[NSString stringWithFormat:@"已完成的(%ld", creatorDone]
792+
];
793+
}
784794

785-
}];
786-
787-
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithUserId:_userId role:TaskRoleTypeWatcher project_id:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
788-
NSInteger watcherDone = [data[@"data"][@"watcherDone"] integerValue];
789-
NSInteger watcherProcessing = [data[@"data"][@"watcherProcessing"] integerValue];
790-
NSInteger creatorDone = [data[@"data"][@"creatorDone"] integerValue];
791-
NSInteger creatorProcessing = [data[@"data"][@"creatorProcessing"] integerValue];
792-
793-
weakSelf.myFliterMenu.items = @[weakSelf.myFliterMenu.items[0],
794-
[NSString stringWithFormat:@"我关注的(%ld", watcherDone + watcherProcessing],
795-
[NSString stringWithFormat:@"我创建的(%ld", creatorDone + creatorProcessing]
796-
];
797-
if (_role == TaskRoleTypeWatcher) {
798-
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", watcherProcessing],
799-
[NSString stringWithFormat:@"已完成的(%ld", watcherDone]
800-
];
801-
}
795+
796+
}];
797+
798+
} else {
799+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithUserId:nil role:TaskRoleTypeAll project_id:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
800+
NSInteger ownerDone, ownerProcessing;
801+
802+
803+
ownerDone = [data[@"data"][@"done"] integerValue];
804+
ownerProcessing = [data[@"data"][@"processing"] integerValue];
805+
806+
weakSelf.myFliterMenu.items = @[[NSString stringWithFormat:@"所有任务(%ld", ownerDone + ownerProcessing],
807+
weakSelf.myFliterMenu.items[1],
808+
weakSelf.myFliterMenu.items[2]
809+
];
810+
if (_role == TaskRoleTypeAll) {
811+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", ownerProcessing],
812+
[NSString stringWithFormat:@"已完成的(%ld", ownerDone]
813+
];
814+
}
815+
816+
}];
802817

803-
if (_role == TaskRoleTypeCreator) {
804-
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", creatorProcessing],
805-
[NSString stringWithFormat:@"已完成的(%ld", creatorDone]
806-
];
807-
}
818+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithUserId:nil role:TaskRoleTypeWatcher project_id:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
819+
NSInteger watcherDone = [data[@"data"][@"watcherDone"] integerValue];
820+
NSInteger watcherProcessing = [data[@"data"][@"watcherProcessing"] integerValue];
821+
NSInteger creatorDone = [data[@"data"][@"creatorDone"] integerValue];
822+
NSInteger creatorProcessing = [data[@"data"][@"creatorProcessing"] integerValue];
823+
824+
weakSelf.myFliterMenu.items = @[weakSelf.myFliterMenu.items[0],
825+
[NSString stringWithFormat:@"我关注的(%ld", watcherDone + watcherProcessing],
826+
[NSString stringWithFormat:@"我创建的(%ld", creatorDone + creatorProcessing]
827+
];
828+
if (_role == TaskRoleTypeWatcher) {
829+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", watcherProcessing],
830+
[NSString stringWithFormat:@"已完成的(%ld", watcherDone]
831+
];
832+
}
833+
834+
if (_role == TaskRoleTypeCreator) {
835+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", creatorProcessing],
836+
[NSString stringWithFormat:@"已完成的(%ld", creatorDone]
837+
];
838+
}
839+
840+
}];
808841

809-
}];
842+
}
810843
}
811844

812845
- (void)loadTasksLabels {

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,21 +1613,6 @@ - (void)request_project_user_tasks_countsWithProjectId:(NSString *)projectId mem
16131613

16141614
- (void)request_tasks_searchWithUserId:(NSString *)userId role:(TaskRoleType )role project_id:(NSString *)project_id andBlock:(void (^)(id data, NSError *error))block {
16151615

1616-
/*
1617-
NSMutableDictionary *param = @{@"page": @(1), @"pageSize": @(1)}.mutableCopy;
1618-
if (userId != nil) {
1619-
[param setValue:userId forKey:@"owner"];
1620-
}
1621-
if (project_id != nil) {
1622-
[param setValue:project_id forKey:@"project_id"];
1623-
}
1624-
1625-
NSArray *roleArray = @[@"owner", @"watcher", @"creator"];
1626-
if (role < roleArray.count) {
1627-
[param setValue:[Login curLoginUser].id.stringValue forKey:roleArray[role]];
1628-
1629-
}
1630-
*/
16311616
NSString *urlStr;
16321617
NSDictionary *param;
16331618
if (userId == nil) { //无成员时
@@ -1637,12 +1622,8 @@ - (void)request_tasks_searchWithUserId:(NSString *)userId role:(TaskRoleType )ro
16371622
urlStr = [NSString stringWithFormat:@"api/project/%@/task/count", project_id];
16381623
}
16391624
} else { //有成员时
1640-
if (role == TaskRoleTypeWatcher || role == TaskRoleTypeCreator) { //创建和关注
1641-
urlStr = [NSString stringWithFormat:@"api/project/%@/user/%@/tasks/counts", project_id, userId];
1642-
} else {
1643-
urlStr = @"api/tasks/search";
1644-
param = @{@"owner": userId, @"project_id": project_id};
1645-
}
1625+
urlStr = [NSString stringWithFormat:@"api/project/%@/user/%@/tasks/counts", project_id, userId];
1626+
16461627
}
16471628

16481629
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:urlStr withParams:param withMethodType:Get andBlock:^(id data, NSError *error) {

0 commit comments

Comments
 (0)