XYCertificationSkillsListCollectionViewModel.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // XYCertificationSkillsListCollectionViewModel.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/10/28.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYCertificationSkillsListCollectionViewModel.h"
  9. #import "XYSkillInfoModel.h"
  10. #import "XYFamilyAPIManager.h"
  11. @implementation XYCertificationSkillsListCollectionViewModel
  12. - (instancetype)init
  13. {
  14. self = [super init];
  15. if (self) {
  16. self.shouldPullDownToRefresh = YES;
  17. self.shouldBeginRefreshing = NO;
  18. }
  19. return self;
  20. }
  21. - (void)loadData:(SuccessHandler)success failure:(FailureHandler)failure {
  22. if (self.certificationSkillsType == CertificationSkillsTypeAuth) {
  23. [[XYFamilyAPIManager new] getSkillsAuthWithUserId:[XYUserInfoManager nowUser].userId successHandler:^(ZYLResponseModel *responseModel) {
  24. [self.dataSource removeAllObjects];
  25. for (NSDictionary *dict in responseModel.data[@"list"]) {
  26. XYSkillInfoModel *model = XYSkillInfoModel.new;
  27. [model yy_modelSetWithDictionary:dict];
  28. model.auditStatus = 1;
  29. [self.dataSource addObject:model];
  30. }
  31. XYSkillInfoModel *model = XYSkillInfoModel.new;
  32. [self.dataSource addObject:model];
  33. !success?:success(self.dataSource);
  34. } failureHandler:^(ZYLNetworkError *error) {
  35. !failure?:failure(error);
  36. }];
  37. }else {
  38. [[XYFamilyAPIManager new] getSkillsSubmitSuccessHandler:^(ZYLResponseModel *responseModel) {
  39. [self.dataSource removeAllObjects];
  40. for (NSDictionary *dict in responseModel.data[@"list"]) {
  41. XYSkillInfoModel *model = XYSkillInfoModel.new;
  42. [model yy_modelSetWithDictionary:dict];
  43. [self.dataSource addObject:model];
  44. }
  45. XYSkillInfoModel *model = XYSkillInfoModel.new;
  46. [self.dataSource addObject:model];
  47. !success?:success(self.dataSource);
  48. } failureHandler:^(ZYLNetworkError *error) {
  49. !failure?:failure(error);
  50. }];
  51. }
  52. }
  53. @end