Browse Source

db 提交up

openlockPPP 1 year ago
parent
commit
4e2938f42a

+ 8 - 0
jiaPei.xcodeproj/project.pbxproj

@@ -101,6 +101,8 @@
 		90798B0B2A52722300E68461 /* NYComplaintListViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 90798B092A52722300E68461 /* NYComplaintListViewCell.xib */; };
 		90798B0F2A52AE2600E68461 /* ComplaintDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 90798B0E2A52AE2600E68461 /* ComplaintDataModel.m */; };
 		90798B122A53E87800E68461 /* NYComplaintListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 90798B112A53E87800E68461 /* NYComplaintListViewModel.m */; };
+		908E6E642A89CCFC0090F00A /* DrCityInfoThree.json in Resources */ = {isa = PBXBuildFile; fileRef = 908E6E632A89CCFC0090F00A /* DrCityInfoThree.json */; };
+		908E6E662A8A08E40090F00A /* cities.json in Resources */ = {isa = PBXBuildFile; fileRef = 908E6E652A8A08E40090F00A /* cities.json */; };
 		90B0F6862A70E9E300B448DC /* QCloudTTS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90B0F6852A70E9E300B448DC /* QCloudTTS.framework */; };
 		90B0F68A2A711C5E00B448DC /* NYVoiceManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 90B0F6892A711C5E00B448DC /* NYVoiceManager.m */; };
 		90BA2E822A3177B50029A54A /* NYTheoryTimeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 90BA2E802A3177B50029A54A /* NYTheoryTimeVC.m */; };
@@ -1827,6 +1829,8 @@
 		90798B0E2A52AE2600E68461 /* ComplaintDataModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ComplaintDataModel.m; sourceTree = "<group>"; };
 		90798B102A53E87800E68461 /* NYComplaintListViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NYComplaintListViewModel.h; sourceTree = "<group>"; };
 		90798B112A53E87800E68461 /* NYComplaintListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NYComplaintListViewModel.m; sourceTree = "<group>"; };
+		908E6E632A89CCFC0090F00A /* DrCityInfoThree.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = DrCityInfoThree.json; sourceTree = "<group>"; };
+		908E6E652A8A08E40090F00A /* cities.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = cities.json; sourceTree = "<group>"; };
 		90B0F6852A70E9E300B448DC /* QCloudTTS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = QCloudTTS.framework; sourceTree = "<group>"; };
 		90B0F6882A711C5E00B448DC /* NYVoiceManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NYVoiceManager.h; sourceTree = "<group>"; };
 		90B0F6892A711C5E00B448DC /* NYVoiceManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NYVoiceManager.m; sourceTree = "<group>"; };
@@ -8028,6 +8032,8 @@
 		D081CCEB27F156380054317F /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				908E6E652A8A08E40090F00A /* cities.json */,
+				908E6E632A89CCFC0090F00A /* DrCityInfoThree.json */,
 				90626F3C2A204BC300C8FA05 /* kt_jq.db */,
 				D05A6FB327F30AE600C096DB /* jsjp_user.db */,
 				D081CCF127F15A280054317F /* hc.db */,
@@ -10232,6 +10238,7 @@
 				D0DF83EC27D1A8BF00547504 /* RQVipAlertHeaderCollectionReusableView.xib in Resources */,
 				D0295BAC243F0B8A00B46AB1 /* 1-4-86.jpg in Resources */,
 				D0295C62243F0B8B00B46AB1 /* 1-8-15.jpg in Resources */,
+				908E6E662A8A08E40090F00A /* cities.json in Resources */,
 				D057C1CC29F50FC5002F4AB2 /* RQPlaceVideoListCell.xib in Resources */,
 				D0295C32243F0B8B00B46AB1 /* 1-1-28.jpg in Resources */,
 				D0294818243F07E300B46AB1 /* 评价1@3x.png in Resources */,
@@ -10484,6 +10491,7 @@
 				D0295C5D243F0B8B00B46AB1 /* 1-11-1.jpg in Resources */,
 				D0295D7D243F0B8C00B46AB1 /* voice18.mp3 in Resources */,
 				D0D68D41289009A800600C5C /* RQExamResultHeaderView.xib in Resources */,
+				908E6E642A89CCFC0090F00A /* DrCityInfoThree.json in Resources */,
 				D0295B77243F0B8A00B46AB1 /* 1-6-9.jpg in Resources */,
 				D0295C21243F0B8B00B46AB1 /* 1-11-12.jpg in Resources */,
 				D0295D22243F0B8C00B46AB1 /* 1-10-12.jpg in Resources */,

BIN
jiaPei.xcworkspace/xcuserdata/mimasigeling.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 0
jiaPei/Modules/HomePageModule/ViewModel/HomePage/RQHomePageViewModel.m

@@ -34,6 +34,7 @@
     
     ///配置数据
     [self rq_configureData];
+    
 }
 
 #pragma mark - PrivateMethod

+ 3 - 0
jiaPei/Modules/OtherModules/YDTQuestionModule/Modules/RQYDTXCQuestionModule.m

@@ -277,6 +277,8 @@ static id rq_ydtXcQuestionModule = nil;
     NSString *midStr = [NSString stringWithFormat:@"AND strTppe = %ld",[self getMidWithChapterName:chapterName]];
     NSString *orderSqlStr = @"web_note.ID + 0 ASC";
     NSString *queryStr = [NSString stringWithFormat:@"SELECT * FROM %@ %@ WHERE %@ AND %@ AND cityid = 0 %@ ORDER BY %@",questionTableNameStr, collectStr, queryCarTypeStr, querySubjectTypeStr, midStr, orderSqlStr];
+    
+    queryStr = [queryStr stringByReplacingOccurrencesOfString:@"cityid = 0" withString:[NSString stringWithFormat:@"(cityid = 0 or cityid = %@)",RQ_USER_MANAGER.city_dbId]];
     return [self queryQuestionWithQueryStr:queryStr];
 }
 
@@ -343,6 +345,7 @@ static id rq_ydtXcQuestionModule = nil;
 - (NSInteger)getQuestionNumWithWithSubject:(RQHomePageSubjectType)subject exerciseType:(RQExerciseType)exerciseType {
     NSString *queryStr = [self getQuestionQueryStrWithSubject:subject exerciseType:exerciseType];
     NSString *numQueryStr = [NSString stringWithFormat:@"%@ %@",@"SELECT COUNT(*) AS countNum" ,[queryStr componentsSeparatedByString:@"SELECT *"].lastObject];
+    numQueryStr = [numQueryStr stringByReplacingOccurrencesOfString:@"cityid = 0" withString:[NSString stringWithFormat:@"(cityid = 0 or cityid = %@)",RQ_USER_MANAGER.city_dbId]];
     __block NSInteger countNum = 0;
     if (_databaseQueue) {
         [_databaseQueue inDatabase:^(FMDatabase * _Nonnull db) {

File diff suppressed because it is too large
+ 0 - 0
jiaPei/Modules/OtherModules/YDTQuestionModule/Resources/DrCityInfoThree.json


File diff suppressed because it is too large
+ 0 - 0
jiaPei/Modules/OtherModules/YDTQuestionModule/Resources/cities.json


BIN
jiaPei/Modules/OtherModules/YDTQuestionModule/Resources/hc.db


BIN
jiaPei/Modules/OtherModules/YDTQuestionModule/Resources/kc.db


BIN
jiaPei/Modules/OtherModules/YDTQuestionModule/Resources/mtc.db


BIN
jiaPei/Modules/OtherModules/YDTQuestionModule/Resources/xc.db


+ 5 - 0
jiaPei/Utils/Manager/UserManager/RQUserManager.h

@@ -23,6 +23,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, readwrite, copy) NSString *cykhPxkmStr;
 /// 试看次数
 @property (nonatomic, readwrite, assign) NSInteger tryLookCount;
+/// citycode
+@property (nonatomic, strong) NSString *city_dbId;
 
 /// 单例
 + (instancetype) sharedInstance;
@@ -69,6 +71,9 @@ NS_ASSUME_NONNULL_BEGIN
 /// 获取了dict value
 - (id)getParamsKey:(NSString *)key;
 
+/// 获取了 db cityid
+- (id)getCityidByName:(NSString *)name;
+- (id)getCityidByCode:(NSString *)code;
 
 @end
 

+ 127 - 2
jiaPei/Utils/Manager/UserManager/RQUserManager.m

@@ -23,7 +23,8 @@ NSString *const RQUserDataConfigureCompleteUserInfoKey = @"RQUserDataConfigureCo
 @property (nonatomic, readwrite, strong) RQUserModel *currentUser;
 @property (nonatomic, readwrite, assign) BOOL 		  isObserve;
 @property (nonatomic, readwrite, strong) RQLoginViewModel *loginViewModel;
-
+@property (nonatomic, strong) NSArray *cityData;
+@property (nonatomic, strong) NSArray *cityCodeData;
 @end
 
 @implementation RQUserManager
@@ -162,6 +163,7 @@ static id rq_userManager = nil;
 }
 
 - (void)loginUser:(RQUserModel *)user{
+    _city_dbId = nil;
 	/// 保存用户
 	[self saveUser:user];
 	
@@ -191,7 +193,7 @@ static id rq_userManager = nil;
     RQ_VIP_Module.isSubject4Vip = NO;
     RQ_VIP_Module.isSubjectAllVip = NO;
     RQ_VIP_Module.videoVipModel = nil;
-    
+    _city_dbId = nil;
     NSInteger localVersion = [[RQ_APP_VERSION stringByReplacingOccurrencesOfString:@"." withString:@""] integerValue];
     [[RQ_HTTP_Service getJsjpSet] subscribeNext:^(NSArray *setArr) {
         [setArr.rac_sequence.signal subscribeNext:^(RQDictInfoModel *dictInfoModel) {
@@ -276,7 +278,130 @@ static id rq_userManager = nil;
     return value;
 }
 
+/// 获取了 db cityid
+- (id)getCityidByCode:(NSString *)code
+{
+    NSString *cityid = @"0";
+    NSString *city = @"";
+    NSArray *cityCodeArray = self.cityCodeData;
+    if(cityCodeArray){
+        for (int i=0; i<cityCodeArray.count; i++) {
+            NSString *ccode = cityCodeArray[i][@"code"];
+            NSString *cname = cityCodeArray[i][@"name"];
+            if ([ccode isEqualToString:code]){
+                city = cname;
+                break;
+            }
+        }
+    }
+    if (city.length>0){
+        cityid = [self getCityidByName:city];
+    }
+    return cityid;
+}
+
+
+- (id)getCityidByName:(NSString *)name
+{
+    NSString *cityid = @"0";
+    NSArray *cityArray = self.cityData;
+    if(cityArray){
+        NSDictionary *item = [self getRecursive:cityArray name:name];
+        if ([item isKindOfClass:[NSDictionary class]]) {
+            NSString *cid = item[@"id"];
+            NSString *cname = item[@"name"];
+            cityid = cid;
+        }
+    }
+    return cityid;
+}
+
+- (id)getRecursive:(NSArray *)cityArray name:(NSString *)name{
+    if(cityArray){
+        for (int i=0; i<cityArray.count; i++) {
+            NSString *cid = cityArray[i][@"id"];
+            NSString *cname = cityArray[i][@"name"];
+            NSArray  *citys = cityArray[i][@"cities"];
+            NSLog(@"cityid = %@  and   cityname = %@",cid,cname);
+            if ([cname containsString:@"市"]){
+                if ([cname isEqualToString:name]){
+                    return cityArray[i];
+                }
+            }else{
+                if (citys!=nil&&citys.count>0){
+                    id list = [self getRecursive:citys name:name];
+                    if(list){
+                        return list;
+                    }
+                }
+            }
+        }
+    }
+    return nil;
+}
+
 #pragma mark - LazyLoad
+
+- (NSString *)city_dbId{
+    if(!_city_dbId){
+        _city_dbId = [self getCityidByName:RQ_USER_MANAGER.currentUser.cityName];
+    }
+    return _city_dbId;
+}
+- (NSArray *)cityCodeData{
+    if(!_cityCodeData){
+        @autoreleasepool {
+                NSString *filePath = [[NSBundle mainBundle] pathForResource:@"cities" ofType:@"json"];
+                if (filePath) {
+                    NSError *error = nil;
+                    NSData *jsonData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error];
+                    if (!error) {
+                        NSError *jsonError = nil;
+                        NSArray *jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&jsonError];
+                        
+                        if (!jsonError && [jsonDictionary isKindOfClass:[NSArray class]]) {
+                            _cityCodeData = jsonDictionary;
+                        } else {
+                            NSLog(@"Error parsing JSON: %@", jsonError);
+                        }
+                    } else {
+                        NSLog(@"Error reading file: %@", error);
+                    }
+                } else {
+                    NSLog(@"JSON file not found.");
+                }
+            
+            }
+    }
+    return _cityCodeData;
+}
+- (NSArray *)cityData{
+    if(!_cityData){
+        @autoreleasepool {
+                NSString *filePath = [[NSBundle mainBundle] pathForResource:@"DrCityInfoThree" ofType:@"json"];
+                if (filePath) {
+                    NSError *error = nil;
+                    NSData *jsonData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error];
+                    if (!error) {
+                        NSError *jsonError = nil;
+                        NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&jsonError];
+                        
+                        if (!jsonError && [jsonDictionary isKindOfClass:[NSDictionary class]]) {
+                            _cityData = jsonDictionary[@"provinces"];
+                        } else {
+                            NSLog(@"Error parsing JSON: %@", jsonError);
+                        }
+                    } else {
+                        NSLog(@"Error reading file: %@", error);
+                    }
+                } else {
+                    NSLog(@"JSON file not found.");
+                }
+            
+            }
+    }
+    return _cityData;
+}
 - (RQLoginViewModel *)loginViewModel {
     if (!_loginViewModel) {
         _loginViewModel = [[RQLoginViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:nil];

Some files were not shown because too many files changed in this diff