123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //
- // XYCertificationSkillsListCollectionViewModel.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/10/28.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYCertificationSkillsListCollectionViewModel.h"
- #import "XYSkillInfoModel.h"
- #import "XYFamilyAPIManager.h"
- @implementation XYCertificationSkillsListCollectionViewModel
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- self.shouldPullDownToRefresh = YES;
- self.shouldBeginRefreshing = NO;
- }
- return self;
- }
- - (void)loadData:(SuccessHandler)success failure:(FailureHandler)failure {
- if (self.certificationSkillsType == CertificationSkillsTypeAuth) {
- [[XYFamilyAPIManager new] getSkillsAuthWithUserId:[XYUserInfoManager nowUser].userId successHandler:^(ZYLResponseModel *responseModel) {
- [self.dataSource removeAllObjects];
-
- for (NSDictionary *dict in responseModel.data[@"list"]) {
- XYSkillInfoModel *model = XYSkillInfoModel.new;
- [model yy_modelSetWithDictionary:dict];
- model.auditStatus = 1;
- [self.dataSource addObject:model];
- }
- XYSkillInfoModel *model = XYSkillInfoModel.new;
- [self.dataSource addObject:model];
- !success?:success(self.dataSource);
- } failureHandler:^(ZYLNetworkError *error) {
- !failure?:failure(error);
- }];
- }else {
- [[XYFamilyAPIManager new] getSkillsSubmitSuccessHandler:^(ZYLResponseModel *responseModel) {
- [self.dataSource removeAllObjects];
-
- for (NSDictionary *dict in responseModel.data[@"list"]) {
- XYSkillInfoModel *model = XYSkillInfoModel.new;
- [model yy_modelSetWithDictionary:dict];
- [self.dataSource addObject:model];
- }
- XYSkillInfoModel *model = XYSkillInfoModel.new;
- [self.dataSource addObject:model];
- !success?:success(self.dataSource);
- } failureHandler:^(ZYLNetworkError *error) {
- !failure?:failure(error);
- }];
- }
- }
- @end
|