Skip to content

Commit

Permalink
mapLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
mszren committed Jan 28, 2016
1 parent 6de7fa5 commit ea9e51a
Show file tree
Hide file tree
Showing 179 changed files with 170,265 additions and 3,224 deletions.
Binary file modified .DS_Store
Binary file not shown.
335 changes: 335 additions & 0 deletions Diary.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,4 @@
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Diary/AppDelegate.m"
timestampString = "475149371.126778"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "129"
endingLineNumber = "129"
landmarkName = "-application:didReceiveRemoteNotification:fetchCompletionHandler:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Binary file modified Diary/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Diary/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#pragma clang diagnostic pop
}


// if ([self checkIsExistUser]) {
[self loadHomeController];
Expand Down
Binary file added Diary/Common/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions Diary/Common/Base/AdapterProtocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AdapterProtocol.h
// Common
//
// Created by Owen on 15/7/23.
// Copyright (c) 2015年 Owen. All rights reserved.
//

#import <Foundation/Foundation.h>
@protocol AdapterProtocol <NSObject>
@required
- (id)adapterData:(NSDictionary *)rawData ByManager:(id)manager;
@end
15 changes: 15 additions & 0 deletions Diary/Common/Base/DataManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// DataManager.h
// Common
//
// Created by Owen on 15/8/12.
// Copyright (c) 2015年 Owen. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AdapterProtocol.h"

@interface DataManager : NSObject
- (NSDictionary *)fetchData:(NSDictionary *)rawData
ByAdapter:(id<AdapterProtocol>)adapter;
@end
22 changes: 22 additions & 0 deletions Diary/Common/Base/DataManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// DataManager.m
// Common
//
// Created by Owen on 15/8/12.
// Copyright (c) 2015年 Owen. All rights reserved.
//

#import "DataManager.h"

@interface DataManager ()
@end
@implementation DataManager
- (NSDictionary *)fetchData:(NSDictionary *)rawData
ByAdapter:(id<AdapterProtocol>)adapter {
if (adapter == nil) {
return rawData;
} else {
return [adapter adapterData:rawData ByManager:self];
}
}
@end
17 changes: 17 additions & 0 deletions Diary/Common/Base/DataProtocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// DataProtocol.h
// Common
//
// Created by Owen on 15/8/20.
// Copyright (c) 2015年 Owen. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AdapterProtocol.h"

@protocol DataProtocol <NSObject>
@required
@property(nonatomic, strong, readwrite) id fetchedRawData;
@required
- (id)fetchDataWithAdapter:(id<AdapterProtocol>)adapter;
@end
58 changes: 58 additions & 0 deletions Diary/Common/DB/DBManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// DBManager.h
// Common
//
// Created by Owen on 15/8/12.
// Copyright (c) 2015年 Owen. All rights reserved.
//

#import "DataManager.h"
#import "DataProtocol.h"
@class FMDatabase;
@interface DBManager : NSObject <DataProtocol> {
FMDatabase *db;
}
@property(nonatomic, retain) FMDatabase *db;

/*
@method getSingle:
@aSql 查询指定表,无参数查询(例如:select * from 表名),返回查询结果
@result NSDictionary *
*/
- (NSDictionary *)getSingle:(NSString *)aSql;

/*
@method getList:
@aSql 查询指定表,无参数查询(例如:select * from 表名),返回查询结果
@result NSDictionary *
*/
- (NSMutableArray *)getList:(NSString *)aSql;

/*
@method insertWithDictionary
@abstract 向指定表插入数据
@parameter aDic字典里包含一条记录,键是字段名,值是要插入的值
@result void
*/
- (void)insertWithTable:(NSString *)tableName Dictionary:(NSDictionary *)aDic;

/*
@method deleteWithDictionary: Dictionary:
@abstract 删除指定表里的数据
@parameter aSql删除sql语句,要这样写:delete from tablename where columnname1
= :columnname1 and(or) ...
aDic字典里是要删除条件,键是字段名;如果aDic为nil,则删除表里所有的数据
@result BOOL
*/
- (BOOL)deleteWithSql:(NSString *)aSql andDictionary:(NSDictionary *)aDic;

/*
@method updateWithSql: Dictionary:
@abstract 更新指定表里的数据
@parameter aSql更新sql语句,要这样写:update tablename set columnname1=?,...
where columnnamen = ? and(or) ...
aArray数组存储的是和?对应数据
@result BOOL
*/
- (BOOL)updateWithSql:(NSString *)aSql andArray:(NSArray *)aArray;
@end
132 changes: 132 additions & 0 deletions Diary/Common/DB/DBManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
//
// BaseDao.m
// Core
//
// Created by 曹亮 on 14/11/18.
// Copyright (c) 2014年 FamilyTree. All rights reserved.
//

#import "DBManager.h"
#import "FMDatabase.h"
#import "SharedDaBase.h"
#import "FMDatabaseAdditions.h"

@implementation DBManager
@synthesize db, fetchedRawData;

- (id)init {
if (self = [super init]) {
db = [[SharedDaBase sharedDataBase] db];
}
return self;
}

- (void)createTable:(NSDictionary *)dic{
//建表

NSMutableString *sql =
[[NSMutableString alloc] initWithFormat:@"create table if not exists travel(ID integer primary key autoincrement,"];

NSArray *keys = [dic allKeys];
for (NSString *str in keys) {
[sql appendFormat:@"%@,", str];

}
[sql replaceCharactersInRange:NSMakeRange([sql length] - 1, 1)
withString:@")"];

if (![db executeUpdate:sql]) {
NSLog(@"建表失败:%@",db.lastErrorMessage);
}else{

}


}

- (id)fetchDataWithAdapter:(id<AdapterProtocol>)adapter {
id resultData = nil;
if ([adapter respondsToSelector:@selector(adapterData:ByManager:)]) {
resultData = [adapter adapterData:self.fetchedRawData ByManager:self];
} else {
resultData = [self.fetchedRawData mutableCopy];
}
return resultData;
}

// SELECT
- (NSDictionary *)getSingle:(NSString *)aSql {
FMResultSet *rs = [db executeQuery:aSql];
[rs next];
NSDictionary *resultDictionary = rs.resultDictionary;
[rs close];
return resultDictionary;
}

// SELECT
- (NSMutableArray *)getList:(NSString *)aSql {

NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:0];
FMResultSet *rs = [db executeQuery:aSql];
while ([rs next]) {
id tr = [rs resultDictionary];
if (nil == tr) {
[rs close];
return nil;
}
[result addObject:tr];
}
[rs close];
return result;
}

- (void)insertWithTable:(NSString *)tableName Dictionary:(NSDictionary *)aDic {
if ([aDic count] <= 0) {
return;
}

[self createTable:aDic];

NSMutableString *sql =
[[NSMutableString alloc] initWithFormat:@"INSERT INTO %@(", tableName];
NSMutableString *para = [[NSMutableString alloc] initWithString:@" VALUES ("];
NSArray *keys = [aDic allKeys];
for (NSString *str in keys) {
[sql appendFormat:@"%@,", str];
[para appendFormat:@":%@,", str];
}
[sql replaceCharactersInRange:NSMakeRange([sql length] - 1, 1)
withString:@")"];
[para replaceCharactersInRange:NSMakeRange([para length] - 1, 1)
withString:@")"];
[sql appendString:para];
[db executeUpdate:sql withParameterDictionary:aDic];
if ([db hadError]) {
NSLog(@"Err %d: %@", [db lastErrorCode], [db lastErrorMessage]);
}
}

- (BOOL)deleteWithSql:(NSString *)aSql andDictionary:(NSDictionary *)aDic {
BOOL success = YES;
if (aDic) {
[db executeUpdate:aSql withParameterDictionary:aDic];
} else {
[db executeUpdate:aSql];
}

if ([db hadError]) {
NSLog(@"Err %d: %@", [db lastErrorCode], [db lastErrorMessage]);
success = NO;
}
return success;
}
- (BOOL)updateWithSql:(NSString *)aSql andArray:(NSArray *)aArray {
BOOL success = YES;
[db executeUpdate:aSql withArgumentsInArray:aArray];
if ([db hadError]) {
NSLog(@"Err %d: %@", [db lastErrorCode], [db lastErrorMessage]);
success = NO;
}
return success;
}
@end
14 changes: 14 additions & 0 deletions Diary/Common/DB/TravelDBManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// TravelDBManager.h
// Common
//
// Created by Owen on 15/8/12.
// Copyright (c) 2015年 Owen. All rights reserved.
//

#import "DBManager.h"

@interface TravelDBManager : DBManager
- (NSArray *)getTravelsByUserID:(NSInteger)userID;
- (void)addTravel:(NSDictionary *)dic;
@end
20 changes: 20 additions & 0 deletions Diary/Common/DB/TravelDBManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// TravelDBManager.m
// Common
//
// Created by Owen on 15/8/12.
// Copyright (c) 2015年 Owen. All rights reserved.
//

#import "TravelDBManager.h"

@implementation TravelDBManager
- (NSArray *)getTravelsByUserID:(NSInteger)userID {
NSString *strSql = [NSString stringWithFormat:@"SELECT * FROM travel "];
return [self getList:strSql];
}

- (void)addTravel:(NSDictionary *)dic {
[self insertWithTable:@"travel" Dictionary:dic];
}
@end
Binary file added Diary/Common/DBHelper/.DS_Store
Binary file not shown.
Loading

0 comments on commit ea9e51a

Please sign in to comment.