@@ -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 了)
0 commit comments