67 lines
2.5 KiB
Objective-C
67 lines
2.5 KiB
Objective-C
//
|
|
// RoomModePresenter.m
|
|
// YuMi
|
|
//
|
|
// Created by P on 2024/12/23.
|
|
//
|
|
|
|
#import "RoomModePresenter.h"
|
|
|
|
#import "Api+RoomSetting.h"
|
|
|
|
@implementation RoomModePresenter
|
|
|
|
- (void)loadRoomLevelInfo:(NSInteger)roomUid
|
|
success:(void(^)(RoomLevelInfoModel *model))success
|
|
failure:(void(^)(NSError *error))failure {
|
|
[Api roomLevelInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
if (success) {
|
|
RoomLevelInfoModel *model = [RoomLevelInfoModel modelWithJSON:data.data];
|
|
NSMutableArray *tempArray_micSkin = @[[RoomMicInfoModel emptySkinModel]].mutableCopy;
|
|
[tempArray_micSkin addObjectsFromArray:model.micSkins];
|
|
NSMutableArray *tempArray_micEffect = @[[RoomMicInfoModel emptyEffectModel]].mutableCopy;
|
|
[tempArray_micEffect addObjectsFromArray:model.micEffects];
|
|
model.micEffects = tempArray_micEffect.copy;
|
|
model.micSkins = tempArray_micSkin.copy;
|
|
success(model);
|
|
}
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
if (failure) {
|
|
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
|
|
}
|
|
} showLoading:YES errorToast:YES] roomUid:@(roomUid).stringValue];
|
|
}
|
|
|
|
- (void)updateRoomMode:(RoomType)type
|
|
micSkinID:(NSInteger)micSkinID
|
|
micEffectID:(NSInteger)micEffectID
|
|
forRoom:(RoomInfoModel *)roomInfo
|
|
success:(void(^)(void))success
|
|
failure:(void(^)(NSError *error))failure {
|
|
NSMutableDictionary * params = [NSMutableDictionary dictionary];
|
|
NSString * ticket = [AccountInfoStorage instance].getTicket;
|
|
[params setObject:ticket forKey:@"ticket"];
|
|
[params setObject:@(roomInfo.uid).stringValue forKey:@"uid"];
|
|
[params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"];
|
|
if (roomInfo.title.length > 0) {
|
|
[params setObject:roomInfo.title forKey:@"title"];
|
|
}
|
|
|
|
[params setObject:@(micSkinID) forKey:@"usedMicSkinId"];
|
|
[params setObject:@(micEffectID) forKey:@"usedMicEffectId"];
|
|
|
|
[params setObject:@(type) forKey:@"type"];
|
|
|
|
[Api ownerUpdateRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
if (success) {
|
|
success();
|
|
}
|
|
} fail:^(NSInteger code, NSString * _Nullable msg) {
|
|
if (failure) {
|
|
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
|
|
}
|
|
} showLoading:YES errorToast:YES] params:params];
|
|
}
|
|
|
|
@end
|