Skip to content

Commit f3d228a

Browse files
committed
添加项目内接口
1 parent d39a775 commit f3d228a

File tree

7 files changed

+181
-14
lines changed

7 files changed

+181
-14
lines changed

Coding_iOS/Controllers/ProjectViewController.m

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ - (void)refreshWithNewIndex:(NSInteger)newIndex{
327327
});
328328
((ProjectTasksView *)curView).selctUserBlock = ^(NSString *owner) {
329329
weakSelf.userId = owner;
330+
[weakSelf resetTaskCount];
331+
[weakSelf loadTasksLabels];
330332
};
331333
}
332334
break;
@@ -759,7 +761,58 @@ - (void)assignmentWithlistView:(ProjectTasksView *)listView {
759761

760762
- (void)resetTaskCount {
761763
__weak typeof(self) weakSelf = self;
762-
[[Coding_NetAPIManager sharedManager] request_project_tasks_countWithProjectId:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
764+
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"][@"finished"] integerValue];
767+
NSInteger ownerProcessing = [data[@"data"][@"processing"] integerValue];
768+
769+
weakSelf.myFliterMenu.items = @[[NSString stringWithFormat:@"所有任务(%ld", ownerDone + ownerProcessing],
770+
weakSelf.myFliterMenu.items[1],
771+
weakSelf.myFliterMenu.items[2]
772+
];
773+
if (_role == TaskRoleTypeAll) {
774+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", ownerProcessing],
775+
[NSString stringWithFormat:@"已完成的(%ld", ownerDone]
776+
];
777+
}
778+
779+
}];
780+
781+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithUserId:_userId role:TaskRoleTypeWatcher project_id:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
782+
NSInteger watcherDone = [data[@"data"][@"finished"] integerValue];
783+
NSInteger watcherProcessing = [data[@"data"][@"processing"] integerValue];
784+
785+
weakSelf.myFliterMenu.items = @[weakSelf.myFliterMenu.items[0],
786+
[NSString stringWithFormat:@"我关注的(%ld", watcherDone + watcherProcessing],
787+
weakSelf.myFliterMenu.items[2]
788+
];
789+
if (_role == TaskRoleTypeWatcher) {
790+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", watcherProcessing],
791+
[NSString stringWithFormat:@"已完成的(%ld", watcherDone]
792+
];
793+
}
794+
795+
}];
796+
797+
[[Coding_NetAPIManager sharedManager] request_tasks_searchWithUserId:_userId role:TaskRoleTypeCreator project_id:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
798+
NSInteger creatorDone = [data[@"data"][@"finished"] integerValue];
799+
NSInteger creatorProcessing = [data[@"data"][@"processing"] integerValue];
800+
801+
weakSelf.myFliterMenu.items = @[weakSelf.myFliterMenu.items[0],
802+
weakSelf.myFliterMenu.items[1],
803+
[NSString stringWithFormat:@"我创建的(%ld", creatorDone + creatorProcessing]
804+
];
805+
if (_role == TaskRoleTypeCreator) {
806+
weakSelf.screenView.tastArray = @[[NSString stringWithFormat:@"进行中的(%ld", creatorProcessing],
807+
[NSString stringWithFormat:@"已完成的(%ld", creatorDone]
808+
];
809+
}
810+
811+
812+
}];
813+
814+
return;
815+
[[Coding_NetAPIManager sharedManager] request_project_user_tasks_countsWithProjectId:_myProject.id.stringValue memberId:_userId andBlock:^(id data, NSError *error) {
763816
NSInteger ownerDone = [data[@"data"][@"ownerDone"] integerValue];
764817
NSInteger ownerProcessing = [data[@"data"][@"ownerProcessing"] integerValue];
765818

@@ -793,7 +846,7 @@ - (void)resetTaskCount {
793846

794847
- (void)loadTasksLabels {
795848
__weak typeof(self) weakSelf = self;
796-
[[Coding_NetAPIManager sharedManager] request_projects_tasks_labelsWithRole:_role projectId:_myProject.id.stringValue andBlock:^(id data, NSError *error) {
849+
[[Coding_NetAPIManager sharedManager] request_projects_tasks_labelsWithRole:_role projectId:_myProject.id.stringValue projectName:_myProject.name memberId:_userId andBlock:^(id data, NSError *error) {
797850
if (data != nil) {
798851
weakSelf.screenView.labels = data;
799852
}

Coding_iOS/Models/Tasks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef NS_ENUM(NSInteger, TaskEntranceType){
2222

2323
typedef NS_ENUM(NSInteger, TaskRoleType)
2424
{
25-
TaskRoleTypeOwner = 0, //执行者 /所有任务
25+
TaskRoleTypeOwner = 0, //执行者
2626
TaskRoleTypeWatcher, //关注者
2727
TaskRoleTypeCreator, //创建者
2828
TaskRoleTypeAll, //所有任务

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ typedef NS_ENUM(NSInteger, PurposeType) {
168168
- (void)request_tasks_searchWithUserId:(NSString *)userId role:(TaskRoleType )role project_id:(NSString *)project_id keyword:(NSString *)keyword status:(NSString *)status label:(NSString *)label page:(NSInteger)page andBlock:(void (^)(id data, NSError *error))block;
169169
- (void)request_project_tasks_countWithProjectId:(NSString *)projectId andBlock:(void (^)(id data, NSError *error))block;
170170

171+
//项目内
172+
- (void)request_project_task_countWithProjectId:(NSString *)projectId andBlock:(void (^)(id data, NSError *error))block;
173+
- (void)request_project_user_tasks_countsWithProjectId:(NSString *)projectId memberId:(NSString *)memberId andBlock:(void (^)(id data, NSError *error))block;
174+
- (void)request_tasks_searchWithUserId:(NSString *)userId role:(TaskRoleType )role project_id:(NSString *)project_id andBlock:(void (^)(id data, NSError *error))block;
175+
- (void)request_projects_tasks_labelsWithRole:(TaskRoleType)role projectId:(NSString *)projectId projectName:(NSString *)projectName memberId:(NSString *)memberId andBlock:(void (^)(id data, NSError *error))block;
171176

172177

173178
#pragma mark - User

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 116 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,18 +1473,25 @@ - (void)request_ChangeWatcher:(User *)watcher ofTask:(Task *)task andBlock:(void
14731473
}
14741474

14751475
- (void)request_projects_tasks_labelsWithRole:(TaskRoleType)role projectId:(NSString *)projectId andBlock:(void (^)(id data, NSError *error))block {
1476+
NSString *roleStr;
1477+
NSDictionary *param;
14761478
NSArray *roleArray = @[@"owner", @"watcher", @"creator"];
1477-
if (role >= roleArray.count) {
1478-
return;
1479+
if (role < roleArray.count) {
1480+
roleStr = roleArray[role];
1481+
}
1482+
1483+
if (roleStr != nil) {
1484+
param = @{@"role": roleStr};
14791485
}
1486+
14801487
NSString *urlStr;
14811488
if (projectId == nil) {
14821489
urlStr = @"api/projects/tasks/labels";
14831490
} else {
14841491
urlStr = [NSString stringWithFormat:@"api/project/%@/tasks/labels", projectId];
14851492
}
14861493

1487-
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:urlStr withParams:@{@"role": roleArray[role]} withMethodType:Get andBlock:^(id data, NSError *error) {
1494+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:urlStr withParams:param withMethodType:Get andBlock:^(id data, NSError *error) {
14881495
NSArray *dataArray = data[@"data"];
14891496
NSMutableDictionary *pinyinDict = @{}.mutableCopy;
14901497
for (NSDictionary *dict in dataArray) {
@@ -1568,6 +1575,112 @@ - (void)request_project_tasks_countWithProjectId:(NSString *)projectId andBlock:
15681575
}];
15691576
}
15701577

1578+
- (void)request_project_task_countWithProjectId:(NSString *)projectId andBlock:(void (^)(id data, NSError *error))block {
1579+
1580+
NSString *urlStr;
1581+
if (projectId == nil) {
1582+
urlStr = @"api/tasks/count";
1583+
} else {
1584+
urlStr = [NSString stringWithFormat:@"api/project/%@/task/count", projectId];
1585+
}
1586+
1587+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:urlStr withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
1588+
if (data) {
1589+
block(data, nil);
1590+
}else{
1591+
block(nil, error);
1592+
}
1593+
}];
1594+
}
1595+
1596+
- (void)request_project_user_tasks_countsWithProjectId:(NSString *)projectId memberId:(NSString *)memberId andBlock:(void (^)(id data, NSError *error))block {
1597+
1598+
NSString *urlStr;
1599+
if (memberId == nil) {
1600+
urlStr = @"api/tasks/search";
1601+
} else {
1602+
urlStr = [NSString stringWithFormat:@"api/project/%@/user/%@/tasks/counts", projectId, memberId];
1603+
}
1604+
1605+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:urlStr withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
1606+
if (data) {
1607+
block(data, nil);
1608+
}else{
1609+
block(nil, error);
1610+
}
1611+
}];
1612+
}
1613+
1614+
- (void)request_tasks_searchWithUserId:(NSString *)userId role:(TaskRoleType )role project_id:(NSString *)project_id andBlock:(void (^)(id data, NSError *error))block {
1615+
NSMutableDictionary *param = @{@"page": @(1), @"pageSize": @(1)}.mutableCopy;
1616+
if (userId != nil) {
1617+
[param setValue:userId forKey:@"owner"];
1618+
}
1619+
if (project_id != nil) {
1620+
[param setValue:project_id forKey:@"project_id"];
1621+
}
1622+
1623+
NSArray *roleArray = @[@"owner", @"watcher", @"creator"];
1624+
if (role < roleArray.count) {
1625+
[param setValue:[Login curLoginUser].id.stringValue forKey:roleArray[role]];
1626+
1627+
}
1628+
1629+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:@"api/tasks/search" withParams:param withMethodType:Get andBlock:^(id data, NSError *error) {
1630+
1631+
if (data) {
1632+
block(data, nil);
1633+
}else{
1634+
block(nil, error);
1635+
}
1636+
}];
1637+
}
1638+
1639+
- (void)request_projects_tasks_labelsWithRole:(TaskRoleType)role projectId:(NSString *)projectId projectName:(NSString *)projectName memberId:(NSString *)memberId andBlock:(void (^)(id data, NSError *error))block {
1640+
NSString *roleStr;
1641+
NSArray *roleArray = @[@"owner", @"watcher", @"creator"];
1642+
if (role < roleArray.count) {
1643+
roleStr = roleArray[role];
1644+
}
1645+
NSString *urlStr;
1646+
NSDictionary *param;
1647+
if (projectId != nil && memberId != nil) {
1648+
urlStr = [NSString stringWithFormat:@"api/project/%@/user/%@/tasks/labels", projectId, memberId];
1649+
param = @{@"role": roleStr};
1650+
} else {
1651+
if (role == TaskRoleTypeWatcher || role == TaskRoleTypeCreator) {
1652+
urlStr = [NSString stringWithFormat:@"api/project/%@/tasks/labels", projectId];
1653+
param = @{@"role": roleStr};
1654+
} else {
1655+
urlStr = [NSString stringWithFormat:@"api/user/%@/project/%@/task/label?withCount=true", [Login curLoginUser].global_key, projectName];
1656+
}
1657+
}
1658+
1659+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:urlStr withParams:param withMethodType:Get andBlock:^(id data, NSError *error) {
1660+
NSArray *dataArray = data[@"data"];
1661+
NSMutableDictionary *pinyinDict = @{}.mutableCopy;
1662+
for (NSDictionary *dict in dataArray) {
1663+
NSString *pinyinName = [dict[@"name"] transformToPinyin];
1664+
[pinyinDict setObject:dict forKey:pinyinName];
1665+
}
1666+
1667+
NSArray *nameSortArray = [[pinyinDict allKeys] sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
1668+
1669+
NSMutableArray *newPinyinData = @[].mutableCopy;
1670+
for (NSString *pinyinName in nameSortArray) {
1671+
[newPinyinData addObject:pinyinDict[pinyinName]];
1672+
}
1673+
1674+
if (data) {
1675+
block(newPinyinData, nil);
1676+
}else{
1677+
block(nil, error);
1678+
}
1679+
}];
1680+
1681+
}
1682+
1683+
15711684
#pragma mark User
15721685
- (void)request_AddUser:(User *)user ToProject:(Project *)project andBlock:(void (^)(id data, NSError *error))block{
15731686
// 一次添加多个成员(逗号分隔):users=102,4 (以后只支持 gk,不支持 id 了)

Coding_iOS/Views/Cell/ScreenCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ - (void)creatView {
5555
_titleLab=[[UILabel alloc] init];
5656
_titleLab.font=[UIFont systemFontOfSize:15];
5757
[self.contentView addSubview:_titleLab];
58-
_titleLab.sd_layout.leftSpaceToView(_tagButton, 17).centerYEqualToView(self.contentView).heightIs(21).rightSpaceToView(_selImageView, 15);
58+
_titleLab.sd_layout.leftSpaceToView(_tagButton, 17).rightSpaceToView(_selImageView, 15).topSpaceToView(self.contentView, 15).bottomSpaceToView(self.contentView, 15);
5959

6060
}
6161

Coding_iOS/Views/Cell/TaskSelectionCell.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ - (void)creatView {
3838

3939
[self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
4040
self.backgroundColor=[UIColor clearColor];
41-
_titleLab=[[UILabel alloc] initWithFrame:CGRectMake(20, 0, 200, 50)];
41+
_titleLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 200, 50)];
4242
_titleLab.font=[UIFont systemFontOfSize:15];
4343
[self.contentView addSubview:_titleLab];
44-
_titleLab.sd_layout.leftSpaceToView(self.contentView, 20).topSpaceToView(self.contentView, 0).bottomSpaceToView(self.contentView, 0).widthIs(200);
44+
_titleLab.sd_layout.leftSpaceToView(self.contentView, 20).topSpaceToView(self.contentView, 15).bottomSpaceToView(self.contentView, 15).widthIs(200);
4545

4646
_selImageView = [[UIImageView alloc] init];
4747
_selImageView.image = [UIImage imageNamed:@"a1-select"];

Coding_iOS/Views/ScreenView.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
101101
}
102102

103103
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
104-
if (indexPath.row == 0) {
105-
return 60;
106-
} else {
107-
return 44;
108-
}
104+
return 50;
109105
}
110106

111107
#pragma mark UISearchBarDelegate

0 commit comments

Comments
 (0)