Commit df7add882c77392b3013987020195e9528d18295

Authored by Cao yang
2 parents fe840a49 85f14aee
Exists in parentassistant

Merge branch 'parentassistant' of http://git.shunzhi.net/iosgroup/parentassistan…

…t into parentassistant
ParentAssistant/ParentAssistant.xcodeproj/project.pbxproj
... ... @@ -81,7 +81,6 @@
81 81 BF38847C205CDE1B00A240EF /* JS.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF38847B205CDE1B00A240EF /* JS.storyboard */; };
82 82 BF38847E205CDE2D00A240EF /* JSViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF38847D205CDE2D00A240EF /* JSViewController.swift */; };
83 83 BF388480205CDFBE00A240EF /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF38847F205CDFBE00A240EF /* WebKit.framework */; };
84   - BF388482205F5BC800A240EF /* MessageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF388481205F5BC800A240EF /* MessageManager.swift */; };
85 84 BF3B8298204FC80D002078EA /* UMCommon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF3B8297204FC80D002078EA /* UMCommon.framework */; };
86 85 BF406CD62057B03A000A6681 /* MessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD52057B03A000A6681 /* MessageViewController.swift */; };
87 86 BF406CD82057B529000A6681 /* MessageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF406CD72057B529000A6681 /* MessageTableViewCell.swift */; };
... ... @@ -120,6 +119,7 @@
120 119 BF7A4C86204E338500460463 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF7A4C81204E338400460463 /* Main.storyboard */; };
121 120 BF7A4C87204E338500460463 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = BF7A4C83204E338400460463 /* Info.plist */; };
122 121 BFA7443A207DB6EE00845D30 /* ActivationSchoolCardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA74439207DB6EE00845D30 /* ActivationSchoolCardViewController.swift */; };
  122 + BFA7446C208193D300845D30 /* MessageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA7446B208193D300845D30 /* MessageManager.swift */; };
123 123 BFBC06C52063AE8900CCFAFF /* ZLaunchAd.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBC06BB2063AE8800CCFAFF /* ZLaunchAd.swift */; };
124 124 BFBC06C62063AE8900CCFAFF /* ZLaunchAdAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBC06BC2063AE8800CCFAFF /* ZLaunchAdAnimation.swift */; };
125 125 BFBC06C72063AE8900CCFAFF /* ZLaunchAdButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBC06BD2063AE8800CCFAFF /* ZLaunchAdButton.swift */; };
... ... @@ -249,7 +249,6 @@
249 249 BF38847B205CDE1B00A240EF /* JS.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = JS.storyboard; sourceTree = "<group>"; };
250 250 BF38847D205CDE2D00A240EF /* JSViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSViewController.swift; sourceTree = "<group>"; };
251 251 BF38847F205CDFBE00A240EF /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
252   - BF388481205F5BC800A240EF /* MessageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageManager.swift; sourceTree = "<group>"; };
253 252 BF3B8297204FC80D002078EA /* UMCommon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UMCommon.framework; path = Pods/UMCCommon/UMCommon.framework; sourceTree = "<group>"; };
254 253 BF406CD52057B03A000A6681 /* MessageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageViewController.swift; sourceTree = "<group>"; };
255 254 BF406CD72057B529000A6681 /* MessageTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTableViewCell.swift; sourceTree = "<group>"; };
... ... @@ -294,6 +293,7 @@
294 293 BF7A4C83204E338400460463 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
295 294 BFA74439207DB6EE00845D30 /* ActivationSchoolCardViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivationSchoolCardViewController.swift; sourceTree = "<group>"; };
296 295 BFA7443B2080869D00845D30 /* ParentAssistant 2.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "ParentAssistant 2.xcdatamodel"; sourceTree = "<group>"; };
  296 + BFA7446B208193D300845D30 /* MessageManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageManager.swift; sourceTree = "<group>"; };
297 297 BFBC06BB2063AE8800CCFAFF /* ZLaunchAd.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAd.swift; sourceTree = "<group>"; };
298 298 BFBC06BC2063AE8800CCFAFF /* ZLaunchAdAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAdAnimation.swift; sourceTree = "<group>"; };
299 299 BFBC06BD2063AE8800CCFAFF /* ZLaunchAdButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLaunchAdButton.swift; sourceTree = "<group>"; };
... ... @@ -490,6 +490,7 @@
490 490 ADE33B302062202300BEA6E6 /* Macro.swift */,
491 491 BF5D1669204E675C00274489 /* account.swift */,
492 492 BF5D166B204E6A0300274489 /* network.swift */,
  493 + BFA7446B208193D300845D30 /* MessageManager.swift */,
493 494 599365282052553900C8B371 /* pinyin.c */,
494 495 599365292052553900C8B371 /* pinyin.h */,
495 496 );
... ... @@ -751,7 +752,6 @@
751 752 BFCED88A20528DE700055373 /* MyViewControllerModel.swift */,
752 753 BF406CD92057BEB8000A6681 /* OrderDetailModel.swift */,
753 754 BF388468205A4DE900A240EF /* StudentClassInfo.swift */,
754   - BF388481205F5BC800A240EF /* MessageManager.swift */,
755 755 );
756 756 path = Model;
757 757 sourceTree = "<group>";
... ... @@ -1058,7 +1058,6 @@
1058 1058 599364ED204E62E700C8B371 /* InformationViewController.swift in Sources */,
1059 1059 ADC9AB72207C55CE00348EF1 /* GrowViewController.swift in Sources */,
1060 1060 5980BF692061048A00F4A35E /* LZCityPickerView.m in Sources */,
1061   - BF388482205F5BC800A240EF /* MessageManager.swift in Sources */,
1062 1061 5980BF682061048A00F4A35E /* LZCityPickerController.m in Sources */,
1063 1062 AD198173207D9FB4009AB8B5 /* ProgramCheckViewController.swift in Sources */,
1064 1063 BFCED88B20528DE700055373 /* MyViewControllerModel.swift in Sources */,
... ... @@ -1099,6 +1098,7 @@
1099 1098 AD64A2C0207F289400B25E80 /* ProgramVacateTableViewCell.swift in Sources */,
1100 1099 AD64A2C3207F28CF00B25E80 /* ProgramVacateBodyTableViewCell.swift in Sources */,
1101 1100 599364EA204E62E700C8B371 /* ChannelViewController.swift in Sources */,
  1101 + BFA7446C208193D300845D30 /* MessageManager.swift in Sources */,
1102 1102 BF406CDE2057C537000A6681 /* OrderDetailTableViewCell.swift in Sources */,
1103 1103 BFEAAAC7205257460072FAAF /* LXCalenderCell.m in Sources */,
1104 1104 BFBC06CC2063AE8900CCFAFF /* ZLaunchAdWindow.swift in Sources */,
... ...
ParentAssistant/ParentAssistant/Classes/controllers/my/Model/MessageManager.swift
... ... @@ -1,118 +0,0 @@
1   -//
2   -// MessageManager.swift
3   -// ParentAssistant
4   -//
5   -// Created by 葛建军 on 2018/3/19.
6   -// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
7   -//
8   -
9   -import UIKit
10   -import CoreData
11   -extension NSManagedObject {
12   -
13   - static func creatWith(identifier:String)->NSManagedObject {
14   - //获取管理的数据上下文 对象
15   - var context:NSManagedObjectContext!
16   - if #available(iOS 10.0, *) {
17   - context = appDelegate.persistentContainer.viewContext
18   - } else {
19   - // Fallback on earlier versions
20   - context = appDelegate.managedObjectContext
21   - }
22   - //创建对象
23   - let obj = NSEntityDescription.insertNewObject(forEntityName: identifier,into: context)
24   - return obj
25   - }
26   - //查询数据操作
27   - static func fetchModel(identifier:String,ownid:String)->[Any]{
28   - //获取管理的数据上下文 对象
29   - var context:NSManagedObjectContext!
30   - if #available(iOS 10.0, *) {
31   - context = appDelegate.persistentContainer.viewContext
32   - } else {
33   - // Fallback on earlier versions
34   - context = appDelegate.managedObjectContext
35   - }
36   - //声明数据的请求
37   - let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier)
38   - fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)]
39   -// fetchRequest.fetchLimit = 10 //限定查询结果的数量
40   - fetchRequest.fetchOffset = 0 //查询的偏移量
41   -
42   - //设置查询条件
43   - let predicate = NSPredicate(format: "ownId = %@", ownid)
44   - fetchRequest.predicate = predicate
45   -
46   - //查询操作
47   - do {
48   - let fetchedObjects = try context.fetch(fetchRequest)
49   - return fetchedObjects
50   - }
51   - catch {
52   - fatalError("不能查询:\(error)")
53   - }
54   - }
55   - //查询数据操作
56   - static func fetchAllUnReadModel(identifier:String,ownid:String)->[Any]{
57   - //获取管理的数据上下文 对象
58   - var context:NSManagedObjectContext!
59   - if #available(iOS 10.0, *) {
60   - context = appDelegate.persistentContainer.viewContext
61   - } else {
62   - // Fallback on earlier versions
63   - context = appDelegate.managedObjectContext
64   - }
65   - //声明数据的请求
66   - let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier)
67   - fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)]
68   - // fetchRequest.fetchLimit = 10 //限定查询结果的数量
69   - fetchRequest.fetchOffset = 0 //查询的偏移量
70   -
71   - //设置查询条件
72   - let predicate = NSPredicate(format: "ownId = %@ and isReaded == %@", ownid,false as CVarArg)
73   - fetchRequest.predicate = predicate
74   -
75   - //查询操作
76   - do {
77   - let fetchedObjects = try context.fetch(fetchRequest)
78   - return fetchedObjects
79   - }
80   - catch {
81   - fatalError("不能查询:\(error)")
82   - }
83   - }
84   -
85   - func save(){
86   - //获取管理的数据上下文 对象
87   - var context:NSManagedObjectContext!
88   - if #available(iOS 10.0, *) {
89   - context = appDelegate.persistentContainer.viewContext
90   - } else {
91   - // Fallback on earlier versions
92   - context = appDelegate.managedObjectContext
93   - }
94   - //保存
95   - do {
96   - try context.save()
97   - print("保存成功!")
98   - } catch {
99   - fatalError("不能保存:\(error)")
100   - }
101   - }
102   - func delete(){
103   - //获取管理的数据上下文 对象
104   - var context:NSManagedObjectContext!
105   - if #available(iOS 10.0, *) {
106   - context = appDelegate.persistentContainer.viewContext
107   - } else {
108   - // Fallback on earlier versions
109   - context = appDelegate.managedObjectContext
110   - }
111   - context.delete(self)
112   - //重新保存-更新到数据库
113   - save()
114   - }
115   -}
116   -class MessageNotification: NSObject {
117   - static let receiveMessage = "YXReceiveMessage"
118   -}
ParentAssistant/ParentAssistant/Classes/util/MessageManager.swift 0 → 100644
... ... @@ -0,0 +1,118 @@
  1 +//
  2 +// MessageManager.swift
  3 +// ParentAssistant
  4 +//
  5 +// Created by 葛建军 on 2018/3/19.
  6 +// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
  7 +//
  8 +
  9 +import UIKit
  10 +import CoreData
  11 +extension NSManagedObject {
  12 +
  13 + static func creatWith(identifier:String)->NSManagedObject {
  14 + //获取管理的数据上下文 对象
  15 + var context:NSManagedObjectContext!
  16 + if #available(iOS 10.0, *) {
  17 + context = appDelegate.persistentContainer.viewContext
  18 + } else {
  19 + // Fallback on earlier versions
  20 + context = appDelegate.managedObjectContext
  21 + }
  22 + //创建对象
  23 + let obj = NSEntityDescription.insertNewObject(forEntityName: identifier,into: context)
  24 + return obj
  25 + }
  26 + //查询数据操作
  27 + static func fetchModel(identifier:String,ownid:String)->[Any]{
  28 + //获取管理的数据上下文 对象
  29 + var context:NSManagedObjectContext!
  30 + if #available(iOS 10.0, *) {
  31 + context = appDelegate.persistentContainer.viewContext
  32 + } else {
  33 + // Fallback on earlier versions
  34 + context = appDelegate.managedObjectContext
  35 + }
  36 + //声明数据的请求
  37 + let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier)
  38 + fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)]
  39 +// fetchRequest.fetchLimit = 10 //限定查询结果的数量
  40 + fetchRequest.fetchOffset = 0 //查询的偏移量
  41 +
  42 + //设置查询条件
  43 + let predicate = NSPredicate(format: "ownId = %@", ownid)
  44 + fetchRequest.predicate = predicate
  45 +
  46 + //查询操作
  47 + do {
  48 + let fetchedObjects = try context.fetch(fetchRequest)
  49 + return fetchedObjects
  50 + }
  51 + catch {
  52 + fatalError("不能查询:\(error)")
  53 + }
  54 + }
  55 + //查询数据操作
  56 + static func fetchAllUnReadModel(identifier:String,ownid:String)->[Any]{
  57 + //获取管理的数据上下文 对象
  58 + var context:NSManagedObjectContext!
  59 + if #available(iOS 10.0, *) {
  60 + context = appDelegate.persistentContainer.viewContext
  61 + } else {
  62 + // Fallback on earlier versions
  63 + context = appDelegate.managedObjectContext
  64 + }
  65 + //声明数据的请求
  66 + let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName:identifier)
  67 + fetchRequest.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)]
  68 + // fetchRequest.fetchLimit = 10 //限定查询结果的数量
  69 + fetchRequest.fetchOffset = 0 //查询的偏移量
  70 +
  71 + //设置查询条件
  72 + let predicate = NSPredicate(format: "ownId = %@ and isReaded == %@", ownid,false as CVarArg)
  73 + fetchRequest.predicate = predicate
  74 +
  75 + //查询操作
  76 + do {
  77 + let fetchedObjects = try context.fetch(fetchRequest)
  78 + return fetchedObjects
  79 + }
  80 + catch {
  81 + fatalError("不能查询:\(error)")
  82 + }
  83 + }
  84 +
  85 + func save(){
  86 + //获取管理的数据上下文 对象
  87 + var context:NSManagedObjectContext!
  88 + if #available(iOS 10.0, *) {
  89 + context = appDelegate.persistentContainer.viewContext
  90 + } else {
  91 + // Fallback on earlier versions
  92 + context = appDelegate.managedObjectContext
  93 + }
  94 + //保存
  95 + do {
  96 + try context.save()
  97 + print("保存成功!")
  98 + } catch {
  99 + fatalError("不能保存:\(error)")
  100 + }
  101 + }
  102 + func delete(){
  103 + //获取管理的数据上下文 对象
  104 + var context:NSManagedObjectContext!
  105 + if #available(iOS 10.0, *) {
  106 + context = appDelegate.persistentContainer.viewContext
  107 + } else {
  108 + // Fallback on earlier versions
  109 + context = appDelegate.managedObjectContext
  110 + }
  111 + context.delete(self)
  112 + //重新保存-更新到数据库
  113 + save()
  114 + }
  115 +}
  116 +class MessageNotification: NSObject {
  117 + static let receiveMessage = "YXReceiveMessage"
  118 +}
... ...