提交
This commit is contained in:
78
SweetParty/Expand/UserData/BJUserManager.h
Executable file
78
SweetParty/Expand/UserData/BJUserManager.h
Executable file
@@ -0,0 +1,78 @@
|
||||
//
|
||||
// UserManager.h
|
||||
// MoHuanXingYu
|
||||
//
|
||||
// Created by aa on 2019/6/12.
|
||||
// Copyright © 2019 MoHuanXingYu. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface BJUserInfo : NSObject
|
||||
|
||||
|
||||
/*用户token*/
|
||||
@property(nonatomic, copy) NSString *login_token;
|
||||
/*用户头像*/
|
||||
@property(nonatomic, copy) NSString *head_pic;
|
||||
/*用户昵称*/
|
||||
@property(nonatomic, copy) NSString *nick_name;
|
||||
/*用户token*/
|
||||
@property(nonatomic, copy) NSString *uid;
|
||||
/*用户user_name(手机号)*/
|
||||
@property(nonatomic, copy) NSString *user_name;
|
||||
/*TXIM user_sig*/
|
||||
@property(nonatomic, copy) NSString *user_sig;
|
||||
|
||||
@property(nonatomic, copy) NSString *guild_id;
|
||||
|
||||
/***********下面方法暂时废弃**********/
|
||||
//@property (nonatomic,copy)NSString *userid;//用户id
|
||||
@property (nonatomic,copy)NSString *headimgurl;//头像
|
||||
@property (nonatomic,copy)NSString *phone;//手机号
|
||||
@property (nonatomic,copy)NSString *username;//用户名
|
||||
@property (nonatomic,copy)NSString *nickname;//用户昵称
|
||||
@property (nonatomic,copy)NSString *token;//用户token
|
||||
//@property (nonatomic,copy)NSString *birthday;//生日
|
||||
@property (nonatomic,copy)NSString *openid;//
|
||||
|
||||
@property (nonatomic,copy)NSString *ry_token;//
|
||||
@property (nonatomic,copy)NSString *ry_uid;//
|
||||
|
||||
|
||||
@property (nonatomic,copy)NSString *sex;//性别
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@interface BJUserManager : NSObject
|
||||
|
||||
/// 刷新并存储用户信息
|
||||
/// @param finishBlock 回调
|
||||
+ (void)bj_refreshUserInfo:(void(^)(BOOL isOk))finishBlock;
|
||||
|
||||
/**
|
||||
存储用户信息
|
||||
@param dic 服务器获取来的用户信息字典
|
||||
@return 存储结果
|
||||
*/
|
||||
+ (BOOL)saveUserInfo:(NSDictionary *)dic;
|
||||
|
||||
/**
|
||||
取用户信息
|
||||
@return 返回用户信息模型
|
||||
*/
|
||||
+ (BJUserInfo *)userInfo;
|
||||
|
||||
/**
|
||||
清空用户信息
|
||||
@return 清空结果
|
||||
*/
|
||||
+ (BOOL)clearUserInfo;
|
||||
|
||||
@end
|
||||
|
||||
91
SweetParty/Expand/UserData/BJUserManager.m
Executable file
91
SweetParty/Expand/UserData/BJUserManager.m
Executable file
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// UserManager.m
|
||||
// MoHuanXingYu
|
||||
//
|
||||
// Created by aa on 2019/6/12.
|
||||
// Copyright © 2019 MoHuanXingYu. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BJUserManager.h"
|
||||
|
||||
@implementation BJUserInfo
|
||||
- (NSString *)login_token {
|
||||
return C_string(GVUSER.token);
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation BJUserManager
|
||||
|
||||
+ (void)onUpdatePhoneHistory:(NSString *)head_pic user_name:(NSString *)user_name {
|
||||
if (user_name.length <= 0) {
|
||||
return;
|
||||
}
|
||||
NSArray *arr = [[NSUserDefaults standardUserDefaults] objectForKey:Login_Phone_History];
|
||||
NSMutableArray *mArr = [[NSMutableArray alloc] initWithArray:arr];
|
||||
NSInteger index = -1;
|
||||
for (NSInteger i = 0; i < mArr.count; i++) {
|
||||
NSDictionary *dict = mArr[i];
|
||||
if ([user_name isEqualToString:dict[@"user_name"]]) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
NSDictionary *dict = @{@"head_pic":head_pic, @"user_name":user_name};
|
||||
if (index == -1) {
|
||||
[mArr insertObject:dict atIndex:0];
|
||||
}else {
|
||||
mArr[index] = dict;
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] setObject:[mArr copy] forKey:Login_Phone_History];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
+ (void)bj_refreshUserInfo:(void(^)(BOOL isOk))finishBlock {
|
||||
[RCMicHTTP postWithURLString:@"/api/user/get_user_info" parameters:nil response:^(RCMicHTTPResult *result) {
|
||||
if (result.success) {
|
||||
if (result.errorCode == 200 && [result.content isKindOfClass:NSDictionary.class]) {
|
||||
[BJUserManager saveUserInfo:result.content];
|
||||
finishBlock? finishBlock(YES) : nil;
|
||||
}else {
|
||||
finishBlock? finishBlock(NO) : nil;
|
||||
// [SVProgressHUD showInfoWithStatus:result.message];
|
||||
}
|
||||
}else {
|
||||
finishBlock? finishBlock(NO) : nil;
|
||||
// [SVProgressHUD showInfoWithStatus:@"网络错误"];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
+ (BOOL)saveUserInfo:(NSDictionary *)dic {
|
||||
GVUSER.rawUserDict = dic;
|
||||
NSString *loginToken = [dic safeStringForKey:@"login_token"];
|
||||
if (loginToken.length > 0) {
|
||||
GVUSER.token = loginToken;
|
||||
}
|
||||
|
||||
[BJUserManager onUpdatePhoneHistory:[dic safeStringForKey:@"head_pic"] user_name:[dic safeStringForKey:@"user_name"]];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
+ (BJUserInfo *)userInfo {
|
||||
NSDictionary *data = GVUSER.rawUserDict;
|
||||
if ([data isKindOfClass:NSDictionary.class] && data.allKeys.count>0) {
|
||||
BJUserInfo *model = [BJUserInfo mj_objectWithKeyValues:data];
|
||||
return model;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (BOOL)clearUserInfo
|
||||
{
|
||||
GVUSER.rawUserDict = @{};
|
||||
GVUSER.token = @"";
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
121
SweetParty/Expand/UserData/MLRoomInformationModel.h
Executable file
121
SweetParty/Expand/UserData/MLRoomInformationModel.h
Executable file
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// MLRoomInformationModel.h
|
||||
// MoHuanXingYu
|
||||
//
|
||||
// Created by aa on 2019/6/14.
|
||||
// Copyright © 2019 MoHuanXingYu. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface MLRoomInformationModel : NSObject
|
||||
//房间ID
|
||||
@property(nonatomic, copy) NSString *rid;
|
||||
//房间号
|
||||
@property(nonatomic, copy) NSString *room_number;
|
||||
//房间名字
|
||||
@property(nonatomic, copy) NSString *room_name;
|
||||
//房间封面
|
||||
@property(nonatomic, copy) NSString *room_cover;
|
||||
//厅主ID
|
||||
@property(nonatomic, copy) NSString *room_owner_uid;
|
||||
//房间公告
|
||||
@property(nonatomic, copy) NSString *room_intro;
|
||||
//房间是否在线
|
||||
@property(nonatomic, copy) NSString *is_online;
|
||||
//游客数量
|
||||
@property(nonatomic, copy) NSString *visitor_num;
|
||||
//直播间背景图片
|
||||
@property(nonatomic, copy) NSString *room_background_image;
|
||||
//是否收藏了该直播间,1,收藏,2,未收藏
|
||||
@property(nonatomic, copy) NSString *is_collect;
|
||||
//厅主魅力值
|
||||
@property(nonatomic, copy) NSString *room_owner_meili;
|
||||
//欢迎语,系统通知
|
||||
@property(nonatomic, copy) NSString *room_welcome;
|
||||
//身份,1房主,2管理员,其他普通用户
|
||||
@property(nonatomic, copy) NSString *identity;
|
||||
/*是否显示转盘*/
|
||||
@property(nonatomic, strong) NSString *box_off;
|
||||
|
||||
/*房主信息*/
|
||||
@property(nonatomic, strong) NSDictionary *room_owner_info;
|
||||
|
||||
|
||||
/*-----------------下面属性废弃----------------*/
|
||||
@property (nonatomic, strong) NSString *openid;
|
||||
@property (nonatomic, strong) NSString *uid;
|
||||
@property (nonatomic, strong) NSString *room_type;
|
||||
@property (nonatomic, strong) NSString *week_star;
|
||||
@property (nonatomic, strong) NSString *ranking;
|
||||
@property (nonatomic, strong) NSString *freshTime;
|
||||
@property (nonatomic, strong) NSString *numid;
|
||||
@property (nonatomic, strong) NSString *updated_at;
|
||||
@property (nonatomic, strong) NSString *sex;
|
||||
@property (nonatomic, strong) NSString *nickname;
|
||||
@property(nonatomic, copy) NSString *bright_num;//靓号,为空不是靓号
|
||||
@property(nonatomic, copy) NSString *room_people;//房间在线人数
|
||||
@property(nonatomic, copy) NSString *send_gift_price;//判断是否显示金蛋或宝箱,1显示,0不显示
|
||||
|
||||
@property (nonatomic, strong) NSString *room_status;
|
||||
@property (nonatomic, strong) NSString *roomBlack;
|
||||
@property (nonatomic, strong) NSString *secret_chat;
|
||||
@property (nonatomic, strong) NSString *roomAdmin;
|
||||
@property (nonatomic, strong) NSString *is_top;
|
||||
//进入房间的用户的身份判断
|
||||
//1房主 4评委 2管理员 5一般用户
|
||||
@property (nonatomic, strong) NSString *user_type;
|
||||
@property (nonatomic, strong) NSString *room_background;
|
||||
|
||||
@property (nonatomic, strong) NSString *created_at;
|
||||
@property (nonatomic, strong) NSString *room_pass;
|
||||
@property (nonatomic, strong) NSString *is_popular;
|
||||
@property (nonatomic, strong) NSString *name;
|
||||
@property (nonatomic, strong) NSString *giftPrice;
|
||||
@property (nonatomic, strong) NSString *headimgurl;
|
||||
|
||||
@property (nonatomic, strong) NSString *is_mykeep;//1: 已收藏 2:为收藏
|
||||
|
||||
@property (nonatomic, strong) NSString *is_sound;
|
||||
@property (nonatomic, strong) NSString *is_speak;
|
||||
@property (nonatomic, strong) NSString *uid_sound;
|
||||
@property (nonatomic, strong) NSString *uid_black;
|
||||
@property (nonatomic, assign) BOOL isBanned;
|
||||
@property (nonatomic, strong) NSString *is_afk;
|
||||
@property (nonatomic, strong) NSString *back_img;
|
||||
@property (nonatomic, strong) NSString *hot;
|
||||
@property (nonatomic, strong) NSString *mic_color;
|
||||
@property (nonatomic, strong) NSString *txk;
|
||||
|
||||
@property(nonatomic, copy) NSString *meili;//新增主播魅力值
|
||||
|
||||
+(instancetype)currentAccount;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface MLRoomInformationManager : NSObject
|
||||
|
||||
/**
|
||||
存储用户信息
|
||||
@param dic 服务器获取来的用户信息字典
|
||||
@return <#return value description#>
|
||||
*/
|
||||
+ (BOOL)saveUserInfo:(MLRoomInformationModel *)dic;
|
||||
|
||||
/**
|
||||
取用户信息
|
||||
@return 返回用户信息模型
|
||||
*/
|
||||
+ (MLRoomInformationModel *)userInfo;
|
||||
|
||||
/**
|
||||
清空用户信息
|
||||
@return <#return value description#>
|
||||
*/
|
||||
+ (BOOL)clearUserInfo;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
97
SweetParty/Expand/UserData/MLRoomInformationModel.m
Executable file
97
SweetParty/Expand/UserData/MLRoomInformationModel.m
Executable file
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// MLRoomInformationModel.m
|
||||
// MoHuanXingYu
|
||||
//
|
||||
// Created by aa on 2019/6/14.
|
||||
// Copyright © 2019 MoHuanXingYu. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MLRoomInformationModel.h"
|
||||
|
||||
#import <MJExtension.h>
|
||||
@implementation MLRoomInformationModel
|
||||
|
||||
|
||||
+(instancetype)currentAccount{
|
||||
|
||||
|
||||
static MLRoomInformationModel *account;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
if (!account) {
|
||||
account = [[MLRoomInformationModel alloc] init];
|
||||
account.isBanned = YES;
|
||||
}
|
||||
});
|
||||
return account;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation MLRoomInformationManager
|
||||
|
||||
|
||||
+ (BOOL)saveUserInfo:(MLRoomInformationModel *)dic
|
||||
{
|
||||
return [NSKeyedArchiver archiveRootObject:[dic mj_keyValues] toFile:[self path]];
|
||||
}
|
||||
|
||||
+ (MLRoomInformationModel *)userInfo
|
||||
{
|
||||
id data = [NSKeyedUnarchiver unarchiveObjectWithFile:[self path]];
|
||||
MLRoomInformationModel *model = [MLRoomInformationModel mj_objectWithKeyValues:data];
|
||||
model.isBanned = YES;
|
||||
return model;
|
||||
}
|
||||
|
||||
+ (BOOL)clearUserInfo
|
||||
{
|
||||
NSFileManager *defaultManager = [NSFileManager defaultManager];
|
||||
if ([defaultManager isDeletableFileAtPath:[self path]])
|
||||
{
|
||||
//删除归档文件
|
||||
return [defaultManager removeItemAtPath:[self path] error:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Documents/ 保存应用程序的重要数据文件和用户数据文件等。用户数据基本上都放在这个位置(例如从网上下载的图片或音乐文件),该文件夹在应用程序更新时会自动备份,在连接iTunes时也可以自动同步备份其中的数据。
|
||||
|
||||
Library:这个目录下有两个子目录,可创建子文件夹。可以用来放置您希望被备份但不希望被用户看到的数据。该路径下的文件夹,除Caches以外,都会被iTunes备份.
|
||||
|
||||
Library/Caches: 保存应用程序使用时产生的支持文件和缓存文件(保存应用程序再次启动过程中需要的信息),还有日志文件最好也放在这个目录。iTunes 同步时不会备份该目录并且可能被其他工具清理掉其中的数据。
|
||||
Library/Preferences: 保存应用程序的偏好设置文件。NSUserDefaults类创建的数据和plist文件都放在这里。会被iTunes备份。
|
||||
|
||||
@return <#return value description#>
|
||||
*/
|
||||
+(NSString *)path
|
||||
{
|
||||
// 获取沙盒根目录路径
|
||||
// NSString *homeDir = NSHomeDirectory();
|
||||
// // 获取Documents目录路径
|
||||
// NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) firstObject];
|
||||
// //获取Library的目录路径
|
||||
// NSString *libDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES) lastObject];
|
||||
// // 获取cache目录路径
|
||||
// NSString *cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) firstObject];
|
||||
// // 获取tmp目录路径
|
||||
NSString *tmpDir = NSTemporaryDirectory();
|
||||
// // 获取应用程序程序包中资源文件路径的方法:
|
||||
// NSString *bundle = [[NSBundle mainBundle] bundlePath];
|
||||
|
||||
NSString *name = @"MLRoomInformationModel";
|
||||
NSString *type = @"sql";
|
||||
|
||||
NSString *allName = [NSString stringWithFormat:@"%@.%@",name,type];
|
||||
|
||||
return [tmpDir stringByAppendingPathComponent:allName];;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user