-
Notifications
You must be signed in to change notification settings - Fork 43
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
Showing
30 changed files
with
9,234 additions
and
8,212 deletions.
There are no files selected for viewing
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 was deleted.
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
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,12 @@ | ||
import type { DB } from '../data-source' | ||
|
||
export class BaseController { | ||
private _db: DB | ||
constructor(db: DB) { | ||
this._db = db | ||
} | ||
|
||
get db() { | ||
return this._db | ||
} | ||
} |
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,11 @@ | ||
import { BaseController } from './BaseController' | ||
|
||
export class ChapterHistory extends BaseController { | ||
save(data: any) { | ||
return this.db.getChapterHistory().save(data) | ||
} | ||
|
||
list(data: any) { | ||
return this.db.getChapterHistory().list(data) | ||
} | ||
} |
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,18 @@ | ||
import { BaseController } from './BaseController' | ||
|
||
export class ResourceFavorites extends BaseController { | ||
// 获取列表 | ||
list() { | ||
return this.db.getResourceFavorites().list() | ||
} | ||
|
||
// 删除 | ||
unstar(data: any) { | ||
return this.db.getResourceFavorites().remove(data) | ||
} | ||
|
||
// 添加 | ||
star(data: any) { | ||
return this.db.getResourceFavorites().create(data) | ||
} | ||
} |
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,18 @@ | ||
import { BaseController } from './BaseController' | ||
|
||
export class ResourceHistory extends BaseController { | ||
// 获取列表 | ||
list() { | ||
return this.db.getResourceHistory().list() | ||
} | ||
|
||
// 删除一个记录 | ||
remove(data: any) { | ||
return this.db.getResourceHistory().remove(data) | ||
} | ||
|
||
// 添加一个记录 | ||
create(data: any) { | ||
return this.db.getResourceHistory().create(data) | ||
} | ||
} |
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,44 @@ | ||
import { DataSource } from 'typeorm' | ||
import { DB_PATH } from './constants' | ||
import { ChapterHistory } from './entity/ChapterHistory' | ||
import { ResourceHistory } from './entity/ResourceHistory' | ||
import { ResourceFavorites } from './entity/ResourceFavorites' | ||
import { ChapterHistoryService } from './service/ChapterHistory' | ||
import { ResourceHistoryService } from './service/ResourceHistory' | ||
import { ResourceFavoritesService } from './service/ResourceFavorites' | ||
|
||
export const AppDataSource = new DataSource({ | ||
entityPrefix: 'ar_', | ||
type: 'sqlite', | ||
database: DB_PATH, | ||
synchronize: true, | ||
logging: true, | ||
entities: [ChapterHistory, ResourceHistory, ResourceFavorites], | ||
subscribers: [], | ||
migrations: [], | ||
}) | ||
|
||
export class DB { | ||
private _initialize = false | ||
|
||
async initialize() { | ||
if (this._initialize) | ||
return | ||
this._initialize = true | ||
return AppDataSource.initialize() | ||
} | ||
|
||
getChapterHistory() { | ||
return new ChapterHistoryService(AppDataSource.getRepository(ChapterHistory)) | ||
} | ||
|
||
getResourceHistory() { | ||
return new ResourceHistoryService(AppDataSource.getRepository(ResourceHistory)) | ||
} | ||
|
||
getResourceFavorites() { | ||
return new ResourceFavoritesService(AppDataSource.getRepository(ResourceFavorites)) | ||
} | ||
} | ||
|
||
export const db = new DB() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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.