Commit 9f212bfe authored by yueming lu's avatar yueming lu

修改数据

parent 6538bc46
......@@ -19,12 +19,12 @@
NSDictionary *data = dict[@"params"];
GMPhobosPageViewModel *model = [[GMPhobosPageViewModel alloc] init];
//共有参数
model.tableName = name;
model.table_name = name;
model.data = [GMPhobosTool dictionaryToJsonString:data];
NSTimeInterval time = [[NSDate date] timeIntervalSince1970] * 1000;
model.messageItemId = [NSString stringWithFormat:@"%.f*%lld", time, mach_absolute_time()];
model.message_item_id = [NSString stringWithFormat:@"%.f/%lld", time, mach_absolute_time()];
model.status = PhobosDataSendStatus_wait;
model.phobosType = phobosType;
model.phobos_type = phobosType;
model.api = urlapi;
model.immediately = status;
//私有参数
......
......@@ -20,15 +20,15 @@ typedef NS_ENUM(int, PhobosDataSendStatus) {
@interface GMPhobosSqulitModel : NSObject
/// 唯一标识(用于筛选)
@property (nonatomic, strong) NSString *messageItemId;
@property (nonatomic, strong) NSString *message_item_id;
/// 埋点类型
@property (nonatomic, strong) NSString *phobosType;
@property (nonatomic, strong) NSString *phobos_type;
/// 内容
@property (nonatomic, strong) NSString *data;
/// 路径
@property (nonatomic, strong) NSString *api;
///插入表格名称
@property (nonatomic, strong) NSString *tableName;
@property (nonatomic, strong) NSString *table_name;
/// 数据状态
@property (nonatomic, assign) PhobosDataSendStatus status;
///是否是立刻发的埋点
......
......@@ -16,12 +16,12 @@
tableName:(NSString *)name
immediately:(BOOL)status{
GMPhobosSqulitModel *model = [GMPhobosSqulitModel new];
model.tableName = name;
model.table_name = name;
model.data = [GMPhobosTool dictionaryToJsonString:data];
NSTimeInterval time = [[NSDate date] timeIntervalSince1970] * 1000;
model.messageItemId = [NSString stringWithFormat:@"%.f*%lld", time, mach_absolute_time()];
model.message_item_id = [NSString stringWithFormat:@"%.f/%lld", time, mach_absolute_time()];
model.status = PhobosDataSendStatus_wait;
model.phobosType = phobosType;
model.phobos_type = phobosType;
model.api = urlapi;
model.immediately = status;
return model;
......
......@@ -129,7 +129,7 @@ static PhobosDataManager *dataManager;
- (void)insertModel:(GMPhobosSqulitModel *)squlitModel {
BOOL insertType = [_squlitManager gm_insertTable:squlitModel.tableName model:squlitModel];
BOOL insertType = [_squlitManager gm_insertTable:squlitModel.table_name model:squlitModel];
if (!insertType) {//如果插入失败,就直接发送给服务器
[self sendModelArray:@[squlitModel]];
} else if (squlitModel.immediately) {//需要立刻发送的埋点
......@@ -138,7 +138,7 @@ static PhobosDataManager *dataManager;
self.messageCont++;
[self disposeSendDataWithImmediately:NO];
}
NSLog(@"插入%@状态%d count:%d",squlitModel.phobosType, insertType,_messageCont);
NSLog(@"插入%@状态%d count:%d",squlitModel.phobos_type, insertType,_messageCont);
}
#pragma mark - 获取待发送数据并修改状态为“发送”
......@@ -198,8 +198,8 @@ static PhobosDataManager *dataManager;
#pragma mark - 上报数据成功
- (void)sendSuccess:(NSArray<GMPhobosSqulitModel*> *)entities {
for (GMPhobosSqulitModel *model in entities) {
NSString *whereStr = [NSString stringWithFormat:@"where messageItemId = '%@'", model.messageItemId];
bool status = [_squlitManager gm_deleteTable:model.tableName whereFormat:whereStr];
NSString *whereStr = [NSString stringWithFormat:@"where message_item_id = '%@'", model.message_item_id];
bool status = [_squlitManager gm_deleteTable:model.table_name whereFormat:whereStr];
NSLog(@"删除状态:%d", status);
}
}
......@@ -207,8 +207,8 @@ static PhobosDataManager *dataManager;
#pragma mark - 上报数据失败
- (void)sendError:(NSArray<GMPhobosSqulitModel*> *)entities {
for (GMPhobosSqulitModel *model in entities) {
NSString *whereStr = [NSString stringWithFormat:@"where messageItemId = '%@'", model.messageItemId];
bool status = [_squlitManager gm_updateTable:model.tableName
NSString *whereStr = [NSString stringWithFormat:@"where message_item_id = '%@'", model.message_item_id];
bool status = [_squlitManager gm_updateTable:model.table_name
dicOrModel: @{@"status":@(PhobosDataSendStatus_error)}
whereFormat:whereStr];
NSLog(@"发送失败后修改状态:%d",status);
......
......@@ -242,11 +242,11 @@
}
- (void)setMessageId:(NSString *)messageId {
objc_setAssociatedObject(self, @selector(messageItemId), messageId, OBJC_ASSOCIATION_COPY_NONATOMIC);
objc_setAssociatedObject(self, @selector(messageId), messageId, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (NSString *)messageId {
NSString *messageId = objc_getAssociatedObject(self, @selector(messageItemId));
NSString *messageId = objc_getAssociatedObject(self, @selector(messageId));
return messageId == nil ? @"" : messageId;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment