Commit 9553352261db0c732e59918a45903343fee15b2a

Authored by liushiyu
1 parent 96998f93

修改DB命名

metaCode.xcodeproj/project.pbxproj
... ... @@ -62,7 +62,7 @@
62 62 7C4931342A307B58000E44B4 /* slide_down.gif in Resources */ = {isa = PBXBuildFile; fileRef = 7C4931332A307B58000E44B4 /* slide_down.gif */; };
63 63 7C4931362A307B60000E44B4 /* slide_up.gif in Resources */ = {isa = PBXBuildFile; fileRef = 7C4931352A307B60000E44B4 /* slide_up.gif */; };
64 64 7C4931382A307BDB000E44B4 /* CNHomePageGuideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C4931372A307BDB000E44B4 /* CNHomePageGuideView.swift */; };
65   - 7C7C62F62A4D72E9007A912E /* CNIdentityDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C7C62F52A4D72E9007A912E /* CNIdentityDB.swift */; };
  65 + 7C7C62F62A4D72E9007A912E /* CNLiveIdentityDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C7C62F52A4D72E9007A912E /* CNLiveIdentityDB.swift */; };
66 66 7C83B43E2A52B8BA004BF4A4 /* CNHomePageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83B43D2A52B8BA004BF4A4 /* CNHomePageViewModel.swift */; };
67 67 7C83B4402A52BB2B004BF4A4 /* CNGlobalEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83B43F2A52BB2B004BF4A4 /* CNGlobalEnum.swift */; };
68 68 7C83B4422A541EBF004BF4A4 /* CALayer+CNLiveExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C83B4412A541EBF004BF4A4 /* CALayer+CNLiveExtensions.swift */; };
... ... @@ -163,7 +163,7 @@
163 163 7C4931332A307B58000E44B4 /* slide_down.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = slide_down.gif; sourceTree = "<group>"; };
164 164 7C4931352A307B60000E44B4 /* slide_up.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = slide_up.gif; sourceTree = "<group>"; };
165 165 7C4931372A307BDB000E44B4 /* CNHomePageGuideView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomePageGuideView.swift; sourceTree = "<group>"; };
166   - 7C7C62F52A4D72E9007A912E /* CNIdentityDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNIdentityDB.swift; sourceTree = "<group>"; };
  166 + 7C7C62F52A4D72E9007A912E /* CNLiveIdentityDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveIdentityDB.swift; sourceTree = "<group>"; };
167 167 7C83B43D2A52B8BA004BF4A4 /* CNHomePageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomePageViewModel.swift; sourceTree = "<group>"; };
168 168 7C83B43F2A52BB2B004BF4A4 /* CNGlobalEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNGlobalEnum.swift; sourceTree = "<group>"; };
169 169 7C83B4412A541EBF004BF4A4 /* CALayer+CNLiveExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CALayer+CNLiveExtensions.swift"; sourceTree = "<group>"; };
... ... @@ -336,6 +336,14 @@
336 336 path = Util;
337 337 sourceTree = "<group>";
338 338 };
  339 + 79579CAA2AAAE905006E5B38 /* Database */ = {
  340 + isa = PBXGroup;
  341 + children = (
  342 + 7C7C62F52A4D72E9007A912E /* CNLiveIdentityDB.swift */,
  343 + );
  344 + path = Database;
  345 + sourceTree = "<group>";
  346 + };
339 347 7963988A2A260B3300D045EB /* Classes */ = {
340 348 isa = PBXGroup;
341 349 children = (
... ... @@ -408,6 +416,7 @@
408 416 796398922A260C0100D045EB /* Config */ = {
409 417 isa = PBXGroup;
410 418 children = (
  419 + 79579CAA2AAAE905006E5B38 /* Database */,
411 420 7CD675512A29C04B008354C1 /* CNLiveConfigstant.swift */,
412 421 790D01812A2D88FC00C5978D /* CNLiveConfigMacro.swift */,
413 422 790D01902A2DAC5E00C5978D /* CNLiveConfigFontMacro.swift */,
... ... @@ -483,14 +492,6 @@
483 492 path = Environment;
484 493 sourceTree = "<group>";
485 494 };
486   - 7C7C62F42A4D72BA007A912E /* DB */ = {
487   - isa = PBXGroup;
488   - children = (
489   - 7C7C62F52A4D72E9007A912E /* CNIdentityDB.swift */,
490   - );
491   - path = DB;
492   - sourceTree = "<group>";
493   - };
494 495 7C83B43C2A52B899004BF4A4 /* ViewModel */ = {
495 496 isa = PBXGroup;
496 497 children = (
... ... @@ -503,7 +504,6 @@
503 504 7CD675212A26F844008354C1 /* HomePage */ = {
504 505 isa = PBXGroup;
505 506 children = (
506   - 7C7C62F42A4D72BA007A912E /* DB */,
507 507 7C83B43C2A52B899004BF4A4 /* ViewModel */,
508 508 7CD6754D2A2840B9008354C1 /* Controller */,
509 509 7CD675232A26F8F8008354C1 /* View */,
... ... @@ -855,12 +855,12 @@
855 855 7C83B4442A541F36004BF4A4 /* NSDate+CNLiveExtensions.swift in Sources */,
856 856 7CD675482A274167008354C1 /* PGIndexBannerSubiew.m in Sources */,
857 857 790D019F2A2DD66E00C5978D /* CNLiveLoginViewModel.swift in Sources */,
858   - 7C7C62F62A4D72E9007A912E /* CNIdentityDB.swift in Sources */,
  858 + 7C7C62F62A4D72E9007A912E /* CNLiveIdentityDB.swift in Sources */,
859 859 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */,
860 860 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */,
861 861 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */,
862 862 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */,
863   - 7C7C62F62A4D72E9007A912E /* CNMetaCodeDB.swift in Sources */,
  863 + 7C7C62F62A4D72E9007A912E /* CNLiveIdentityDB.swift in Sources */,
864 864 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */,
865 865 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */,
866 866 7C83B4422A541EBF004BF4A4 /* CALayer+CNLiveExtensions.swift in Sources */,
... ...
metaCode/Classes/Main/DB/CNIdentityDB.swift renamed to metaCode/Classes/Config/Database/CNLiveIdentityDB.swift
1 1 //
2   -// CNMetaCodeDB.swift
  2 +// CNLiveMetaCodeDB.swift
3 3 // metaCode
4 4 // 数据库
5 5 // Created by daojian on 2023/6/29.
... ... @@ -9,10 +9,10 @@ import Foundation
9 9 import WCDBSwift
10 10  
11 11 ///身份认证表名
12   -let CNIdentityTableName = "CNIdentityTable"
  12 +let CNLiveIdentityTableName = "CNLiveIdentityTable"
13 13  
14 14 ///身份model
15   -class CNIdentityModel: BaseModel,TableCodable {
  15 +class CNLiveIdentityModel: BaseModel,TableCodable {
16 16 var id: String = ""
17 17 var name: String?
18 18 var icon: String?
... ... @@ -20,7 +20,7 @@ class CNIdentityModel: BaseModel,TableCodable {
20 20 var enable: Bool?
21 21  
22 22 enum CodingKeys: String, CodingTableKey {
23   - typealias Root = CNIdentityModel
  23 + typealias Root = CNLiveIdentityModel
24 24 static let objectRelationalMapping = TableBinding(CodingKeys.self){
25 25 //设置表的主键key为id,用来区分数据唯一性, 如果id为int类型,可以按实现按顺序递增
26 26 BindColumnConstraint(id, isPrimary: true)
... ... @@ -35,7 +35,7 @@ class CNIdentityModel: BaseModel,TableCodable {
35 35 }
36 36  
37 37 ///身份列表数据库
38   -class CNIdentityDB :NSObject{
  38 +class CNLiveIdentityDB :NSObject{
39 39  
40 40 ///数据库
41 41 var database:Database
... ... @@ -44,11 +44,11 @@ class CNIdentityDB :NSObject{
44 44 override init() {
45 45  
46 46 //数据库地址
47   - let filePath = NSHomeDirectory() + "/Documents/DB/CNIdentity.db"
  47 + let filePath = NSHomeDirectory() + "/Documents/DB/CNLiveIdentity.db"
48 48 database = Database(at: filePath)
49 49  
50 50 super.init()
51   - self.createTable(name: CNIdentityTableName, classType: CNIdentityModel.self)
  51 + self.createTable(name: CNLiveIdentityTableName, classType: CNLiveIdentityModel.self)
52 52 }
53 53  
54 54 /// 创建表
... ... @@ -58,8 +58,7 @@ class CNIdentityDB :NSObject{
58 58 private func createTable<Root:TableDecodable>(name:String, classType: Root.Type){
59 59 do{
60 60 try database.create(table: name, of: classType)
61   - }
62   - catch{
  61 + }catch{
63 62 print("创建失败")
64 63 }
65 64  
... ... @@ -67,27 +66,26 @@ class CNIdentityDB :NSObject{
67 66  
68 67 /// 新增一条数据
69 68 /// - Parameter object: 数据
70   - func insterObject(object: CNIdentityModel){
71   - let array: [CNIdentityModel] = [object]
  69 + func insterObject(object: CNLiveIdentityModel){
  70 + let array: [CNLiveIdentityModel] = [object]
72 71 self.insterObjects(objects: array)
73 72 }
74 73  
75 74 ///新增多条数据
76   - func insterObjects(objects: Array<CNIdentityModel>){
  75 + func insterObjects(objects: Array<CNLiveIdentityModel>){
77 76 do{
78   - try database.insert(objects, intoTable: CNIdentityTableName)
79   - }
80   - catch{
  77 + try database.insert(objects, intoTable: CNLiveIdentityTableName)
  78 + }catch{
81 79 print("增加一条数据失败")
82 80 }
83 81 }
84 82  
85 83 /// 删除一条数据
86 84 /// - Parameter delete: 被删除的数据
87   - func deleteObject(delete: CNIdentityModel){
  85 + func deleteObject(delete: CNLiveIdentityModel){
88 86  
89 87 do{
90   - try database.delete(fromTable: CNIdentityTableName, where: CNIdentityModel.Properties.id == delete.id)
  88 + try database.delete(fromTable: CNLiveIdentityTableName, where: CNLiveIdentityModel.Properties.id == delete.id)
91 89 }
92 90 catch{
93 91 print("删除一条数据失败")
... ... @@ -95,15 +93,15 @@ class CNIdentityDB :NSObject{
95 93 }
96 94  
97 95 ///更新一条数据
98   - func updateObject(newObject:CNIdentityModel){
  96 + func updateObject(newObject:CNLiveIdentityModel){
99 97 do{
100 98 //需要更新的字段
101   - let updateProperties = [CNIdentityModel.Properties.name,
102   - CNIdentityModel.Properties.icon,
103   - CNIdentityModel.Properties.createTime,
104   - CNIdentityModel.Properties.enable]
  99 + let updateProperties = [CNLiveIdentityModel.Properties.name,
  100 + CNLiveIdentityModel.Properties.icon,
  101 + CNLiveIdentityModel.Properties.createTime,
  102 + CNLiveIdentityModel.Properties.enable]
105 103  
106   - try database.update(table: CNIdentityTableName, on:updateProperties, with: newObject,where: CNIdentityModel.Properties.id == newObject.id)
  104 + try database.update(table: CNLiveIdentityTableName, on:updateProperties, with: newObject,where: CNLiveIdentityModel.Properties.id == newObject.id)
107 105 }
108 106 catch{
109 107 print("更新一条数据失败")
... ... @@ -111,9 +109,9 @@ class CNIdentityDB :NSObject{
111 109 }
112 110  
113 111 ///获取所有数据
114   - func searchAllObject()-> Array<CNIdentityModel>{
  112 + func searchAllObject()-> Array<CNLiveIdentityModel>{
115 113 do{
116   - let allData: [CNIdentityModel] = try database.getObjects(fromTable: CNIdentityTableName)
  114 + let allData: [CNLiveIdentityModel] = try database.getObjects(fromTable: CNLiveIdentityTableName)
117 115 return allData
118 116 }
119 117 catch{
... ...
metaCode/Classes/Global/CNGlobalEnum.swift
... ... @@ -7,7 +7,7 @@
7 7  
8 8 import Foundation
9 9 ///网络请求响应状态
10   -enum CNNetworkingResponseType {
  10 +enum CNLiveNetworkingResponseType {
11 11 ///成功
12 12 case success
13 13 ///失败
... ...
metaCode/Classes/Main/HomePage/Controller/CNMetaCodeHomePageController.swift
... ... @@ -386,7 +386,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel
386 386 }
387 387 //MARK: - 网络请求
388 388 func getUserIdentityApi(){
389   - CNHomePageViewModel.getUserIdentityApi { listArray, responseType, errorMsg in
  389 + CNLiveHomePageViewModel.getUserIdentityApi { listArray, responseType, errorMsg in
390 390 switch responseType{
391 391 case .success:
392 392 if(listArray.count>0){
... ...
metaCode/Classes/Main/HomePage/ViewModel/CNHomePageViewModel.swift
1 1 //
2   -// CNHomePageViewModel.swift
  2 +// CNLiveHomePageViewModel.swift
3 3 // metaCode
4 4 //
5 5 // Created by daojian on 2023/7/3.
... ... @@ -9,15 +9,15 @@ import Foundation
9 9 import CNLiveRequestBastKit
10 10  
11 11 ///请求响应回调
12   -typealias responseBlock = (_ listArray:Array<CNIdentityModel>, _ responseType:CNNetworkingResponseType, _ errorMsg:String) -> Void
  12 +typealias responseBlock = (_ listArray:Array<CNLiveIdentityModel>, _ responseType:CNLiveNetworkingResponseType, _ errorMsg:String) -> Void
13 13  
14   -class CNHomePageViewModel:NSObject {
  14 +class CNLiveHomePageViewModel:NSObject {
15 15  
16 16 /// 获取身份列表
17 17 class func getUserIdentityApi(resultBlock:@escaping responseBlock){
18 18  
19 19 //先从本地获取,本地有直接返回
20   - let db = CNIdentityDB()
  20 + let db = CNLiveIdentityDB()
21 21 let allDbArray = db.searchAllObject()
22 22 if(allDbArray.count > 0){
23 23 resultBlock(allDbArray,.success,"")
... ... @@ -46,14 +46,14 @@ class CNHomePageViewModel:NSObject {
46 46 let data:NSDictionary = resultDic["data"] as! NSDictionary
47 47 let list:NSArray = data["list"] as! NSArray
48 48  
49   - //list数据转CNIdentityModel, 并把model存入本地
  49 + //list数据转CNLiveIdentityModel, 并把model存入本地
50 50  
51   - var array:Array = Array<CNIdentityModel>()
  51 + var array:Array = Array<CNLiveIdentityModel>()
52 52 for index in 0..<list.count{
53   - let item = dictionaryToModel(list[index] as! [String : Any], CNIdentityModel.self, "")
54   - array.append(item as! CNIdentityModel)
  53 + let item = dictionaryToModel(list[index] as! [String : Any], CNLiveIdentityModel.self, "")
  54 + array.append(item as! CNLiveIdentityModel)
55 55 //存入数据库
56   - db.insterObject(object: item as! CNIdentityModel)
  56 + db.insterObject(object: item as! CNLiveIdentityModel)
57 57 }
58 58 resultBlock(array,.success,"")
59 59 }
... ...