Skip to content

Commit 3da5312

Browse files
committed
新标签接口 批量修改接口
1 parent 26a6630 commit 3da5312

6 files changed

Lines changed: 189 additions & 84 deletions

File tree

Coding_iOS/Controllers/EditLabelViewController.m

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ - (void)viewDidLoad {
4646
self.title = @"标签管理";
4747
self.navigationController.title = @"标签管理";
4848

49-
if (!_isSaveChange) {
49+
//if (!_isSaveChange) {
5050
self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithBtnTitle:@"完成" target:self action:@selector(okBtnClick)];
5151
self.navigationItem.rightBarButtonItem.enabled = FALSE;
52-
}
52+
//}
5353

5454
self.view.backgroundColor = kColorTableSectionBg;
5555

@@ -146,26 +146,27 @@ - (void)okBtnClick
146146
//_curProTopic.mdTitle = _tempArray;
147147
//_curProTopic.mdContent = _tempArray;
148148

149-
//self.navigationItem.rightBarButtonItem.enabled = NO;
150-
// if (_isSaveChange) {
151-
// @weakify(self);
152-
// [[Coding_NetAPIManager sharedManager] request_ModifyProjectTpoic:self.curProTopic andBlock:^(id data, NSError *error) {
153-
// @strongify(self);
154-
// self.navigationItem.rightBarButtonItem.enabled = YES;
155-
// if (data) {
156-
// _curProTopic.labels = [NSMutableArray arrayWithArray:_curProTopic.mdLabels];
157-
// if (self.topicChangedBlock) {
158-
// self.topicChangedBlock();
159-
// }
160-
// [self.navigationController popViewControllerAnimated:YES];
161-
// }
162-
// }];
163-
// } else {
149+
self.navigationItem.rightBarButtonItem.enabled = NO;
150+
if (_isSaveChange) {
151+
152+
@weakify(self);
153+
[[Coding_NetAPIManager sharedManager] request_ModifyProjectTpoicLabel:self.curProTopic andBlock:^(id data, NSError *error) {
154+
@strongify(self);
155+
self.navigationItem.rightBarButtonItem.enabled = YES;
156+
if (data) {
157+
_curProTopic.labels = [NSMutableArray arrayWithArray:_curProTopic.mdLabels];
158+
if (self.topicChangedBlock) {
159+
self.topicChangedBlock();
160+
}
161+
[self.navigationController popViewControllerAnimated:YES];
162+
}
163+
}];
164+
} else {
164165
if (self.topicChangedBlock) {
165166
self.topicChangedBlock();
166167
}
167168
[self.navigationController popViewControllerAnimated:YES];
168-
//}
169+
}
169170
}
170171

171172
- (void)addBtnClick:(UIButton *)sender
@@ -274,40 +275,40 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
274275
}
275276
}
276277
if (add) {
277-
if (_isSaveChange) {
278-
__weak typeof(self) weakSelf = self;
279-
[[Coding_NetAPIManager sharedManager] request_ProjectTopic_AddLabel_WithPath:[self toMedifyPath:lbl.id] andBlock:^(id data, NSError *error) {
280-
if (!error) {
281-
[_tempArray addObject:lbl];
282-
weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
283-
} else {
284-
cell.selectBtn.selected = FALSE;
285-
}
286-
}];
287-
[_tempArray addObject:lbl];
288-
self.navigationItem.rightBarButtonItem.enabled = YES;
289-
} else {
278+
// if (_isSaveChange) {
279+
// __weak typeof(self) weakSelf = self;
280+
// [[Coding_NetAPIManager sharedManager] request_ProjectTopic_AddLabel_WithPath:[self toMedifyPath:lbl.id] andBlock:^(id data, NSError *error) {
281+
// if (!error) {
282+
// [_tempArray addObject:lbl];
283+
// weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
284+
// } else {
285+
// cell.selectBtn.selected = FALSE;
286+
// }
287+
// }];
288+
// [_tempArray addObject:lbl];
289+
// self.navigationItem.rightBarButtonItem.enabled = YES;
290+
// } else {
290291
[_tempArray addObject:lbl];
291292
self.navigationItem.rightBarButtonItem.enabled = YES;
292-
}
293+
//}
293294
}
294295
} else {
295296
for (ProjectTopicLabel *tempLbl in _tempArray) {
296297
if ([tempLbl.id integerValue] == [lbl.id integerValue]) {
297-
if (_isSaveChange) {
298-
__weak typeof(self) weakSelf = self;
299-
[[Coding_NetAPIManager sharedManager] request_ProjectTopic_DelLabel_WithPath:[self toMedifyPath:lbl.id] andBlock:^(id data, NSError *error) {
300-
if (!error) {
301-
[_tempArray removeObject:tempLbl];
302-
weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
303-
} else {
304-
cell.selectBtn.selected = TRUE;
305-
}
306-
}];
307-
} else {
298+
// if (_isSaveChange) {
299+
// __weak typeof(self) weakSelf = self;
300+
// [[Coding_NetAPIManager sharedManager] request_ProjectTopic_DelLabel_WithPath:[self toMedifyPath:lbl.id] andBlock:^(id data, NSError *error) {
301+
// if (!error) {
302+
// [_tempArray removeObject:tempLbl];
303+
// weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
304+
// } else {
305+
// cell.selectBtn.selected = TRUE;
306+
// }
307+
// }];
308+
// } else {
308309
[_tempArray removeObject:tempLbl];
309310
self.navigationItem.rightBarButtonItem.enabled = YES;
310-
}
311+
//}
311312
break;
312313
}
313314
}

Coding_iOS/Models/ProjectTopic.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
+ (ProjectTopic *)feedbackTopic;
4141
+ (ProjectTopic *)topicWithPro:(Project *)pro;
4242
+ (ProjectTopic *)topicWithId:(NSNumber *)topicId;
43-
- (NSString *)toTopicPath;
4443

44+
- (NSString *)toTopicPath;
4545
- (NSDictionary *)toEditParams;
46+
47+
- (NSString *)toLabelPath;
4648
- (NSDictionary *)toLabelParams;
4749

4850
- (NSString *)toAddTopicPath;

Coding_iOS/Models/ProjectTopic.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,18 @@ - (NSDictionary *)toEditParams
8181
@"label" : tempAry};
8282
}
8383

84+
- (NSString *)toLabelPath
85+
{
86+
return [NSString stringWithFormat:@"api/user/%@/project/%@/topics/%d/labels", _project.owner_user_name, _project.name, self.id.intValue];
87+
}
88+
8489
- (NSDictionary *)toLabelParams
8590
{
8691
NSMutableArray *tempAry = [NSMutableArray arrayWithCapacity:_mdLabels.count];
8792
for (ProjectTopicLabel *lbl in _mdLabels) {
8893
[tempAry addObject:lbl.id];
8994
}
90-
return @{@"label" : tempAry};
95+
return @{@"label_id" : tempAry};
9196
}
9297

9398
- (NSString *)toAddTopicPath

Coding_iOS/Util/Manager/Coding_NetAPIManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,14 @@
9494
- (void)request_DoComment_WithProjectTpoic:(ProjectTopic *)proTopic andBlock:(void (^)(id data, NSError *error))block;
9595
- (void)request_ProjectTopic_Delete_WithObj:(ProjectTopic *)proTopic andBlock:(void (^)(id data, NSError *error))block;
9696

97+
- (void)request_ModifyProjectTpoicLabel:(ProjectTopic *)proTopic
98+
andBlock:(void (^)(id data, NSError *error))block;
9799
- (void)request_ProjectTopic_Count_WithPath:(NSString *)path
98100
andBlock:(void (^)(id data, NSError *error))block;
101+
- (void)request_ProjectTopic_LabelAll_WithPath:(NSString *)path
102+
andBlock:(void (^)(id data, NSError *error))block;
103+
- (void)request_ProjectTopic_LabelMy_WithPath:(NSString *)path
104+
andBlock:(void (^)(id data, NSError *error))block;
99105
- (void)request_ProjectTopic_AddLabel_WithPath:(NSString *)path
100106
andBlock:(void (^)(id data, NSError *error))block;
101107
- (void)request_ProjectTopic_DelLabel_WithPath:(NSString *)path

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -804,14 +804,15 @@ - (void)request_ProjectTopic_WithObj:(ProjectTopic *)proTopic andBlock:(void (^)
804804
}
805805
- (void)request_ModifyProjectTpoicLabel:(ProjectTopic *)proTopic andBlock:(void (^)(id data, NSError *error))block
806806
{
807-
[MobClick event:kUmeng_Event_Request label:@"项目讨论详情_修改标签"];
807+
[MobClick event:kUmeng_Event_Request label:@"项目讨论_批量修改标签"];
808808
proTopic.isTopicEditLoading = YES;
809-
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[proTopic toTopicPath] withParams:[proTopic toLabelParams] withMethodType:Put andBlock:^(id data, NSError *error) {
809+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:[proTopic toLabelPath]
810+
withParams:[proTopic toLabelParams]
811+
withMethodType:Post
812+
andBlock:^(id data, NSError *error) {
810813
proTopic.isTopicEditLoading = NO;
811814
if (data) {
812-
id resultData = [data valueForKeyPath:@"data"];
813-
ProjectTopic *resultT = [NSObject objectOfClass:@"ProjectTopic" fromJSON:resultData];
814-
block(resultT, nil);
815+
block(data, nil);
815816
} else {
816817
block(nil, error);
817818
}
@@ -904,6 +905,42 @@ - (void)request_ProjectTopic_Count_WithPath:(NSString *)path
904905
}
905906
}];
906907
}
908+
- (void)request_ProjectTopic_LabelAll_WithPath:(NSString *)path
909+
andBlock:(void (^)(id data, NSError *error))block
910+
{
911+
[MobClick event:kUmeng_Event_Request label:@"项目讨论所有被使用标签"];
912+
913+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path
914+
withParams:nil
915+
withMethodType:Get
916+
andBlock:^(id data, NSError *error) {
917+
if (data) {
918+
id resultData = [data valueForKeyPath:@"data"];
919+
NSArray *resultA = [NSObject arrayFromJSON:resultData ofObjects:@"ProjectTopicLabel"];
920+
block(resultA, nil);
921+
} else {
922+
block(nil, error);
923+
}
924+
}];
925+
}
926+
- (void)request_ProjectTopic_LabelMy_WithPath:(NSString *)path
927+
andBlock:(void (^)(id data, NSError *error))block
928+
{
929+
[MobClick event:kUmeng_Event_Request label:@"项目讨论与我相关被使用标签"];
930+
931+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path
932+
withParams:nil
933+
withMethodType:Get
934+
andBlock:^(id data, NSError *error) {
935+
if (data) {
936+
id resultData = [data valueForKeyPath:@"data"];
937+
NSArray *resultA = [NSObject arrayFromJSON:resultData ofObjects:@"ProjectTopicLabel"];
938+
block(resultA, nil);
939+
} else {
940+
block(nil, error);
941+
}
942+
}];
943+
}
907944

908945
- (void)request_ProjectTopic_AddLabel_WithPath:(NSString *)path
909946
andBlock:(void (^)(id data, NSError *error))block

0 commit comments

Comments
 (0)