This repository has been archived by the owner on Dec 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
198d3f6
commit 6752fd9
Showing
65 changed files
with
1,655 additions
and
1,972 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Gallery+CoreDataClass.h | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <CoreData/CoreData.h> | ||
|
||
@class GalleryPage; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface Gallery : NSManagedObject | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#import "Gallery+CoreDataProperties.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Gallery+CoreDataClass.m | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
// | ||
|
||
#import "Gallery+CoreDataClass.h" | ||
|
||
@implementation Gallery | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Gallery+CoreDataProperties.h | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
// | ||
|
||
#import "Gallery+CoreDataClass.h" | ||
|
||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface Gallery (CoreDataProperties) | ||
|
||
+ (NSFetchRequest<Gallery *> *)fetchRequest; | ||
|
||
@property (nullable, nonatomic, copy) NSString *galleryid; | ||
@property (nullable, nonatomic, retain) NSSet<GalleryPage *> *galleryPage; | ||
|
||
@end | ||
|
||
@interface Gallery (CoreDataGeneratedAccessors) | ||
|
||
- (void)addGalleryPageObject:(GalleryPage *)value; | ||
- (void)removeGalleryPageObject:(GalleryPage *)value; | ||
- (void)addGalleryPage:(NSSet<GalleryPage *> *)values; | ||
- (void)removeGalleryPage:(NSSet<GalleryPage *> *)values; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Gallery+CoreDataProperties.m | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
// | ||
|
||
#import "Gallery+CoreDataProperties.h" | ||
|
||
@implementation Gallery (CoreDataProperties) | ||
|
||
+ (NSFetchRequest<Gallery *> *)fetchRequest { | ||
return [NSFetchRequest fetchRequestWithEntityName:@"Gallery"]; | ||
} | ||
|
||
@dynamic galleryid; | ||
@dynamic galleryPage; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// GalleryPage+CoreDataClass.h | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <CoreData/CoreData.h> | ||
|
||
@class Gallery; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface GalleryPage : NSManagedObject | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#import "GalleryPage+CoreDataProperties.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// GalleryPage+CoreDataClass.m | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
// | ||
|
||
#import "GalleryPage+CoreDataClass.h" | ||
|
||
@implementation GalleryPage | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// GalleryPage+CoreDataProperties.h | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
// | ||
|
||
#import "GalleryPage+CoreDataClass.h" | ||
|
||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface GalleryPage (CoreDataProperties) | ||
|
||
+ (NSFetchRequest<GalleryPage *> *)fetchRequest; | ||
|
||
@property (nonatomic) int64_t page; | ||
@property (nullable, nonatomic, copy) NSString *smallImageUrl; | ||
@property (nullable, nonatomic, retain) Gallery *gallery; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// GalleryPage+CoreDataProperties.m | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
// | ||
|
||
#import "GalleryPage+CoreDataProperties.h" | ||
|
||
@implementation GalleryPage (CoreDataProperties) | ||
|
||
+ (NSFetchRequest<GalleryPage *> *)fetchRequest { | ||
return [NSFetchRequest fetchRequestWithEntityName:@"GalleryPage"]; | ||
} | ||
|
||
@dynamic page; | ||
@dynamic smallImageUrl; | ||
@dynamic gallery; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// QJBrowerCollectManager.h | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
|
||
// 管理书签相关 | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@class GalleryPage; | ||
|
||
@interface QJBrowerCollectManager : NSObject | ||
|
||
/** 获取全部书签 | ||
@param gid 画廊的唯一标识符 | ||
*/ | ||
+ (NSArray<GalleryPage *> *)getAllCollectPagesWithGid:(NSString *)gid; | ||
|
||
/** 添加一个书签 | ||
@param gid 画廊的唯一标识符 | ||
@param pageIndex 书签信息,页码 | ||
@param smallImageUrl 书签信息,缩略图url | ||
*/ | ||
+ (void)saveOnePageWithGid:(NSString *)gid pageIndex:(NSInteger)pageIndex smallImageUrl:(NSString *)smallImageUrl; | ||
|
||
/** 删除一个书签 | ||
@param gid 画廊的唯一标识符 | ||
@param pageIndex 书签信息,页码 | ||
@param smallImageUrl 书签信息,缩略图url | ||
*/ | ||
+ (void)deleteOnePageWithGid:(NSString *)gid pageIndex:(NSInteger)pageIndex smallImageUrl:(NSString *)smallImageUrl; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// | ||
// QJBrowerCollectManager.m | ||
// EHenTaiViewer | ||
// | ||
// Created by QinJ on 2018/8/13. | ||
// Copyright © 2018 kayanouriko. All rights reserved. | ||
// | ||
|
||
#import "QJBrowerCollectManager.h" | ||
// coredata | ||
#import "Gallery+CoreDataClass.h" | ||
#import "Gallery+CoreDataProperties.h" | ||
#import "GalleryPage+CoreDataClass.h" | ||
#import "GalleryPage+CoreDataProperties.h" | ||
|
||
@implementation QJBrowerCollectManager | ||
|
||
+ (NSArray<GalleryPage *> *)getAllCollectPagesWithGid:(NSString *)gid { | ||
Gallery *gallery = [Gallery MR_findByAttribute:@"galleryid" withValue:gid].firstObject; | ||
if (nil == gallery) { | ||
return @[]; | ||
} | ||
NSSet *galleryPage = gallery.galleryPage; | ||
NSSortDescriptor *pageDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"page" ascending:YES]; | ||
return [galleryPage sortedArrayUsingDescriptors:@[pageDescriptor]]; | ||
} | ||
|
||
+ (void)saveOnePageWithGid:(NSString *)gid pageIndex:(NSInteger)pageIndex smallImageUrl:(NSString *)smallImageUrl { | ||
// 添加 | ||
Gallery *gallery = [Gallery MR_findByAttribute:@"galleryid" withValue:gid].firstObject; | ||
// 如果不存在,则创建一个 | ||
if (nil == gallery) { | ||
gallery = [Gallery MR_createEntityInContext:[NSManagedObjectContext MR_defaultContext]]; | ||
gallery.galleryid = gid; | ||
} | ||
// 获取当前页的对象 | ||
NSArray *array = [GalleryPage MR_findByAttribute:@"gallery" withValue:gallery]; | ||
if (array.count) { | ||
// 查找是否存在 | ||
NSPredicate *pagePredicate = [NSPredicate predicateWithFormat:@"page = %ld", pageIndex]; | ||
NSArray *selectArray = [array filteredArrayUsingPredicate:pagePredicate]; | ||
if (selectArray.count) { | ||
GalleryPage *galleryPage = selectArray.firstObject; | ||
galleryPage.page = pageIndex; | ||
galleryPage.smallImageUrl = smallImageUrl; | ||
} | ||
else { | ||
GalleryPage *galleryPage = [GalleryPage MR_createEntity]; | ||
galleryPage.page = pageIndex; | ||
galleryPage.smallImageUrl = smallImageUrl; | ||
[gallery addGalleryPageObject:galleryPage]; | ||
} | ||
} | ||
else { | ||
GalleryPage *galleryPage = [GalleryPage MR_createEntity]; | ||
galleryPage.page = pageIndex; | ||
galleryPage.smallImageUrl = smallImageUrl; | ||
[gallery addGalleryPageObject:galleryPage]; | ||
} | ||
[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait]; | ||
} | ||
|
||
+ (void)deleteOnePageWithGid:(NSString *)gid pageIndex:(NSInteger)pageIndex smallImageUrl:(NSString *)smallImageUrl { | ||
Gallery *gallery = [Gallery MR_findByAttribute:@"galleryid" withValue:gid].firstObject; | ||
if (gallery) { | ||
NSArray *array = [GalleryPage MR_findByAttribute:@"gallery" withValue:gallery]; | ||
if (array.count) { | ||
NSPredicate *pagePredicate = [NSPredicate predicateWithFormat:@"page = %ld", pageIndex]; | ||
NSArray *selectArray = [array filteredArrayUsingPredicate:pagePredicate]; | ||
for (GalleryPage *page in selectArray) { | ||
[page MR_deleteEntity]; | ||
} | ||
if (array.count <= 1) { | ||
// 如果没有书签了删除本身 | ||
[gallery MR_deleteEntity]; | ||
} | ||
} | ||
else { | ||
// 如果没有书签了删除本身 | ||
[gallery MR_deleteEntity]; | ||
} | ||
[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.