jp.db.schemas 2.1.13 → 2.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/models/activity-log-user-login.interface copy.d.ts +11 -0
- package/dist/models/activity-log-user-login.interface copy.d.ts.map +1 -0
- package/dist/models/activity-log-user-login.interface copy.js +3 -0
- package/dist/models/activity-log-user-login.interface copy.js.map +1 -0
- package/dist/repositories/premium.repository.d.ts +1 -1
- package/dist/repositories/premium.repository.d.ts.map +1 -1
- package/dist/repositories/premium.repository.js +2 -5
- package/dist/repositories/premium.repository.js.map +1 -1
- package/dist/repositories/purchase.repository.d.ts +1 -1
- package/dist/repositories/purchase.repository.js +1 -1
- package/dist/repositories/rule.repository.d.ts +1 -1
- package/dist/repositories/rule.repository.d.ts.map +1 -1
- package/dist/repositories/rule.repository.js +2 -5
- package/dist/repositories/rule.repository.js.map +1 -1
- package/dist/repositories/welcome.repository.d.ts +1 -1
- package/dist/repositories/welcome.repository.d.ts.map +1 -1
- package/dist/repositories/welcome.repository.js +2 -5
- package/dist/repositories/welcome.repository.js.map +1 -1
- package/package.json +31 -31
- package/readme.md +3 -3
- package/src/index.ts +251 -251
- package/src/models/activity-log-user-login.interface copy.ts +10 -0
- package/src/models/activity-log-user-login.interface.ts +9 -9
- package/src/models/activity-log.enum.ts +7 -7
- package/src/models/currency.enum.ts +4 -4
- package/src/models/rating-add-bulk-item.interface.ts +6 -6
- package/src/models/rating-monthly-result.interface.ts +10 -10
- package/src/models/tournament-participant.interface.ts +5 -5
- package/src/models/tournament-status.enum.ts +6 -6
- package/src/models/tournament-template.enum.ts +3 -3
- package/src/models/tournament-winner.interface.ts +7 -7
- package/src/repositories/achievement.repository.ts +18 -18
- package/src/repositories/activity-log.repository.ts +110 -110
- package/src/repositories/admin.repository.ts +23 -23
- package/src/repositories/article.repository.ts +33 -33
- package/src/repositories/balance-history.repository.ts +15 -15
- package/src/repositories/banners.repository.ts +54 -54
- package/src/repositories/complains.repository.ts +30 -30
- package/src/repositories/daily-bonus.repository.ts +25 -25
- package/src/repositories/friend.repository.ts +19 -19
- package/src/repositories/game-result.repository.ts +15 -15
- package/src/repositories/game-statistic.repository.ts +21 -21
- package/src/repositories/index.ts +57 -57
- package/src/repositories/menu.repository.ts +21 -21
- package/src/repositories/notification.repository.ts +54 -54
- package/src/repositories/premium.repository.ts +17 -19
- package/src/repositories/products.repository.ts +29 -29
- package/src/repositories/purchase.repository.ts +95 -95
- package/src/repositories/rating.repository.ts +83 -83
- package/src/repositories/rooms.repository.ts +17 -17
- package/src/repositories/rule.repository.ts +17 -19
- package/src/repositories/scheduled-tournaments.repository.ts +30 -30
- package/src/repositories/servers.repository.ts +18 -18
- package/src/repositories/setting.repository.ts +19 -19
- package/src/repositories/simple-rooms.repository.ts +17 -17
- package/src/repositories/tournament-many-tables-rooms.repository.ts +132 -132
- package/src/repositories/tournament-one-table-rooms.repository.ts +106 -106
- package/src/repositories/users.repository.ts +151 -151
- package/src/repositories/welcome.repository.ts +17 -19
- package/src/schemas/achievement.schema.ts +40 -40
- package/src/schemas/activity_log.schema.ts +37 -37
- package/src/schemas/admin.schema.ts +22 -22
- package/src/schemas/article.schema.ts +37 -37
- package/src/schemas/balance_history.schema.ts +37 -37
- package/src/schemas/banner.schema.ts +40 -40
- package/src/schemas/channel_message.schema.ts +31 -31
- package/src/schemas/complain.schema.ts +46 -46
- package/src/schemas/daily_bonus.schema.ts +56 -56
- package/src/schemas/feature.schema.ts +28 -28
- package/src/schemas/friend.schema.ts +50 -50
- package/src/schemas/game_result.schema.ts +68 -68
- package/src/schemas/game_statistic.schema.ts +40 -40
- package/src/schemas/menu.schema.ts +40 -40
- package/src/schemas/notification.schema.ts +61 -61
- package/src/schemas/premium.schema.ts +45 -45
- package/src/schemas/product.schema.ts +123 -123
- package/src/schemas/purchase.schema.ts +58 -58
- package/src/schemas/purchase_channel.schema.ts +31 -31
- package/src/schemas/rating.schema.ts +37 -37
- package/src/schemas/rooms.schema.ts +63 -63
- package/src/schemas/rule.schema.ts +45 -45
- package/src/schemas/scheduled_tournament.schema.ts +93 -93
- package/src/schemas/server.schema.ts +22 -22
- package/src/schemas/setting.schema.ts +55 -55
- package/src/schemas/simple_rooms.schema.ts +46 -46
- package/src/schemas/tournament_many_tables_rooms.schema.ts +84 -84
- package/src/schemas/tournament_one_table_rooms.schema.ts +81 -81
- package/src/schemas/user.fb.schema.ts +33 -33
- package/src/schemas/user.google.schema.ts +24 -24
- package/src/schemas/user.ok.schema.ts +52 -52
- package/src/schemas/user.schema.ts +182 -182
- package/src/schemas/user.tg.schema.ts +30 -30
- package/src/schemas/user.vk.schema.ts +70 -70
- package/src/schemas/user.ya.schema.ts +24 -24
- package/src/schemas/welcome.schema.ts +45 -45
- package/src/utils.ts +3 -3
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Achievement, AchievementDocument } from '..';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class AchievementRepository {
|
|
9
|
-
constructor (@InjectModel(Achievement.name) private menuModel: Model<AchievementDocument>) {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async findAchievements (): Promise<Array<Achievement>> {
|
|
13
|
-
return this.menuModel
|
|
14
|
-
.find()
|
|
15
|
-
.exec();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Achievement, AchievementDocument } from '..';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class AchievementRepository {
|
|
9
|
+
constructor (@InjectModel(Achievement.name) private menuModel: Model<AchievementDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findAchievements (): Promise<Array<Achievement>> {
|
|
13
|
+
return this.menuModel
|
|
14
|
+
.find()
|
|
15
|
+
.exec();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
import dayjs from 'dayjs';
|
|
5
|
-
|
|
6
|
-
import { ActivityLog, ActivityLogDocument } from '..';
|
|
7
|
-
import { ActivityLogEnum } from '../models/activity-log.enum';
|
|
8
|
-
import { IActivityLogUserLogin } from '../models/activity-log-user-login.interface';
|
|
9
|
-
|
|
10
|
-
@Injectable()
|
|
11
|
-
export class ActivityLogRepository {
|
|
12
|
-
constructor(
|
|
13
|
-
@InjectModel(ActivityLog.name) private activityLogModel: Model<ActivityLogDocument>
|
|
14
|
-
) {
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async findLast7DaysLogins(
|
|
18
|
-
game: string,
|
|
19
|
-
userId: string,
|
|
20
|
-
): Promise<Array<IActivityLogUserLogin>> {
|
|
21
|
-
const weekAgo = dayjs().startOf('day').add(-1, 'week');
|
|
22
|
-
|
|
23
|
-
return this.activityLogModel.aggregate([
|
|
24
|
-
{
|
|
25
|
-
$match: {
|
|
26
|
-
game,
|
|
27
|
-
userId,
|
|
28
|
-
date: { $gte: weekAgo.toDate() },
|
|
29
|
-
event: ActivityLogEnum.USER_LOGIN,
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
$group: {
|
|
34
|
-
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date" } },
|
|
35
|
-
userId: { $first: "$userId" },
|
|
36
|
-
userName: { $first: "$userName" },
|
|
37
|
-
event: { $first: "$event" },
|
|
38
|
-
game: { $first: "$game" },
|
|
39
|
-
channels: { $first: "$channels" },
|
|
40
|
-
count: { $sum: 1 },
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
$project: {
|
|
45
|
-
_id: 0,
|
|
46
|
-
id: "$_id",
|
|
47
|
-
userId: 1,
|
|
48
|
-
userName: 1,
|
|
49
|
-
event: 1,
|
|
50
|
-
game: 1,
|
|
51
|
-
channel: 1,
|
|
52
|
-
count: 1,
|
|
53
|
-
date: "$_id"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
$sort: { "date": -1 }
|
|
58
|
-
}
|
|
59
|
-
])
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async userIsNewbie(userId: string): Promise<boolean> {
|
|
63
|
-
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_LOGIN }).exec() === 1;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async getUserPlayedGamesCount(userId: string): Promise<number> {
|
|
67
|
-
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_PLAYED_GAME }).exec()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async getUserWonGamesCount(userId: string): Promise<number> {
|
|
71
|
-
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_GAME }).exec()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
async getUserWonProfiCount(userId: string): Promise<number> {
|
|
75
|
-
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_PROFI }).exec()
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async getUserWonOneTableTournamentCount(userId: string): Promise<number> {
|
|
79
|
-
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT }).exec()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async addUserLoginEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
83
|
-
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_LOGIN, userId, userName, game, channels });
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async addUserGotBonuseEvent(userId: string, userName: string, game: string, channels: string, amount: number): Promise<ActivityLog> {
|
|
87
|
-
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_GOT_BONUS, userId, userName, game, channels, amount, });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async addUserPlayedGameEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
91
|
-
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_PLAYED_GAME, userId, userName, game, channels, });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async addUserWonGameEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
95
|
-
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_GAME, userId, userName, game, channels });
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
async addUserWonProfieEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
99
|
-
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_PROFI, userId, userName, game, channels });
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async addUserWonOneTableTournamentEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
103
|
-
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT, userId, userName, game, channels });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async addActivityLog(activityLog: Partial<ActivityLog>): Promise<ActivityLog> {
|
|
107
|
-
return this.activityLogModel.create(activityLog);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
|
|
6
|
+
import { ActivityLog, ActivityLogDocument } from '..';
|
|
7
|
+
import { ActivityLogEnum } from '../models/activity-log.enum';
|
|
8
|
+
import { IActivityLogUserLogin } from '../models/activity-log-user-login.interface';
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class ActivityLogRepository {
|
|
12
|
+
constructor(
|
|
13
|
+
@InjectModel(ActivityLog.name) private activityLogModel: Model<ActivityLogDocument>
|
|
14
|
+
) {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async findLast7DaysLogins(
|
|
18
|
+
game: string,
|
|
19
|
+
userId: string,
|
|
20
|
+
): Promise<Array<IActivityLogUserLogin>> {
|
|
21
|
+
const weekAgo = dayjs().startOf('day').add(-1, 'week');
|
|
22
|
+
|
|
23
|
+
return this.activityLogModel.aggregate([
|
|
24
|
+
{
|
|
25
|
+
$match: {
|
|
26
|
+
game,
|
|
27
|
+
userId,
|
|
28
|
+
date: { $gte: weekAgo.toDate() },
|
|
29
|
+
event: ActivityLogEnum.USER_LOGIN,
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
$group: {
|
|
34
|
+
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date" } },
|
|
35
|
+
userId: { $first: "$userId" },
|
|
36
|
+
userName: { $first: "$userName" },
|
|
37
|
+
event: { $first: "$event" },
|
|
38
|
+
game: { $first: "$game" },
|
|
39
|
+
channels: { $first: "$channels" },
|
|
40
|
+
count: { $sum: 1 },
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
$project: {
|
|
45
|
+
_id: 0,
|
|
46
|
+
id: "$_id",
|
|
47
|
+
userId: 1,
|
|
48
|
+
userName: 1,
|
|
49
|
+
event: 1,
|
|
50
|
+
game: 1,
|
|
51
|
+
channel: 1,
|
|
52
|
+
count: 1,
|
|
53
|
+
date: "$_id"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
$sort: { "date": -1 }
|
|
58
|
+
}
|
|
59
|
+
])
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async userIsNewbie(userId: string): Promise<boolean> {
|
|
63
|
+
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_LOGIN }).exec() === 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async getUserPlayedGamesCount(userId: string): Promise<number> {
|
|
67
|
+
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_PLAYED_GAME }).exec()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async getUserWonGamesCount(userId: string): Promise<number> {
|
|
71
|
+
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_GAME }).exec()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async getUserWonProfiCount(userId: string): Promise<number> {
|
|
75
|
+
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_PROFI }).exec()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async getUserWonOneTableTournamentCount(userId: string): Promise<number> {
|
|
79
|
+
return await this.activityLogModel.countDocuments({ userId, event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT }).exec()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async addUserLoginEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
83
|
+
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_LOGIN, userId, userName, game, channels });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async addUserGotBonuseEvent(userId: string, userName: string, game: string, channels: string, amount: number): Promise<ActivityLog> {
|
|
87
|
+
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_GOT_BONUS, userId, userName, game, channels, amount, });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async addUserPlayedGameEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
91
|
+
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_PLAYED_GAME, userId, userName, game, channels, });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async addUserWonGameEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
95
|
+
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_GAME, userId, userName, game, channels });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async addUserWonProfieEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
99
|
+
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_PROFI, userId, userName, game, channels });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async addUserWonOneTableTournamentEvent(userId: string, userName: string, game: string, channels: string): Promise<ActivityLog> {
|
|
103
|
+
return this.addActivityLog({ date: new Date(), event: ActivityLogEnum.USER_WON_ONE_TABLE_TOURNAMENT, userId, userName, game, channels });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async addActivityLog(activityLog: Partial<ActivityLog>): Promise<ActivityLog> {
|
|
107
|
+
return this.activityLogModel.create(activityLog);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Admin, AdminDocument } from '../';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class AdminRepository {
|
|
9
|
-
constructor (@InjectModel(Admin.name) private adminModel: Model<AdminDocument>) {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async findById (id: string): Promise<Admin | null> {
|
|
13
|
-
return this.adminModel
|
|
14
|
-
.findOne({ _id: id })
|
|
15
|
-
.exec();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async findByLogin (login: string): Promise<Admin | null> {
|
|
19
|
-
return this.adminModel
|
|
20
|
-
.findOne({ login })
|
|
21
|
-
.exec();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Admin, AdminDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class AdminRepository {
|
|
9
|
+
constructor (@InjectModel(Admin.name) private adminModel: Model<AdminDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findById (id: string): Promise<Admin | null> {
|
|
13
|
+
return this.adminModel
|
|
14
|
+
.findOne({ _id: id })
|
|
15
|
+
.exec();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async findByLogin (login: string): Promise<Admin | null> {
|
|
19
|
+
return this.adminModel
|
|
20
|
+
.findOne({ login })
|
|
21
|
+
.exec();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Article, ArticleDocument } from '../';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class ArticleRepository {
|
|
9
|
-
constructor (@InjectModel(Article.name) private articleModel: Model<ArticleDocument>) {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async findAllArticles (): Promise<Array<Article>> {
|
|
13
|
-
return this.articleModel
|
|
14
|
-
.find()
|
|
15
|
-
.sort({ createDate: -1 })
|
|
16
|
-
.exec();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async findLastArticle (): Promise<Article | null> {
|
|
20
|
-
return await this.articleModel
|
|
21
|
-
.findOne()
|
|
22
|
-
.sort({ createDate: -1 })
|
|
23
|
-
.exec();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async findTop3Articles (): Promise<Array<Article>> {
|
|
27
|
-
return this.articleModel
|
|
28
|
-
.find()
|
|
29
|
-
.sort({ createDate: -1 })
|
|
30
|
-
.limit(3)
|
|
31
|
-
.exec();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Article, ArticleDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ArticleRepository {
|
|
9
|
+
constructor (@InjectModel(Article.name) private articleModel: Model<ArticleDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findAllArticles (): Promise<Array<Article>> {
|
|
13
|
+
return this.articleModel
|
|
14
|
+
.find()
|
|
15
|
+
.sort({ createDate: -1 })
|
|
16
|
+
.exec();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async findLastArticle (): Promise<Article | null> {
|
|
20
|
+
return await this.articleModel
|
|
21
|
+
.findOne()
|
|
22
|
+
.sort({ createDate: -1 })
|
|
23
|
+
.exec();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async findTop3Articles (): Promise<Array<Article>> {
|
|
27
|
+
return this.articleModel
|
|
28
|
+
.find()
|
|
29
|
+
.sort({ createDate: -1 })
|
|
30
|
+
.limit(3)
|
|
31
|
+
.exec();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { BalanceHistory, BalanceHistoryDocument } from '../';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class BalanceHistoryRepository {
|
|
9
|
-
constructor (@InjectModel(BalanceHistory.name) private balanceHistoryModel: Model<BalanceHistoryDocument>) {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public async createBalanceHistory (gameResult: Partial<BalanceHistory>): Promise<BalanceHistory> {
|
|
13
|
-
return this.balanceHistoryModel.create(gameResult);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { BalanceHistory, BalanceHistoryDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class BalanceHistoryRepository {
|
|
9
|
+
constructor (@InjectModel(BalanceHistory.name) private balanceHistoryModel: Model<BalanceHistoryDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async createBalanceHistory (gameResult: Partial<BalanceHistory>): Promise<BalanceHistory> {
|
|
13
|
+
return this.balanceHistoryModel.create(gameResult);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Banner, BannerDocument } from '../';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class BannersRepository {
|
|
9
|
-
constructor (@InjectModel(Banner.name) private bannerModel: Model<BannerDocument>) {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async findById (id: string): Promise<Banner | null> {
|
|
13
|
-
return this.bannerModel
|
|
14
|
-
.findById(id)
|
|
15
|
-
.exec();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async findAndCount (limit: number, skip: number): Promise<{
|
|
19
|
-
items: Array<Banner>,
|
|
20
|
-
total: number
|
|
21
|
-
}> {
|
|
22
|
-
const items = await this.bannerModel
|
|
23
|
-
.find()
|
|
24
|
-
.sort({ createDate: -1 })
|
|
25
|
-
.limit(limit)
|
|
26
|
-
.skip(skip)
|
|
27
|
-
.exec();
|
|
28
|
-
|
|
29
|
-
const total = await this.bannerModel
|
|
30
|
-
.find()
|
|
31
|
-
.countDocuments()
|
|
32
|
-
.exec();
|
|
33
|
-
|
|
34
|
-
return { items, total };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public async createBanner (banner: Banner): Promise<Banner> {
|
|
38
|
-
return this.bannerModel.create(banner);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async updateBanner (bannerId: string, banner: Partial<Banner>): Promise<void> {
|
|
42
|
-
await this.bannerModel.findByIdAndUpdate(
|
|
43
|
-
bannerId,
|
|
44
|
-
{
|
|
45
|
-
$set: {
|
|
46
|
-
...banner,
|
|
47
|
-
},
|
|
48
|
-
}).exec();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public async removeBanner (bannerId: string): Promise<void> {
|
|
52
|
-
await this.bannerModel.findByIdAndDelete(bannerId);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Banner, BannerDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class BannersRepository {
|
|
9
|
+
constructor (@InjectModel(Banner.name) private bannerModel: Model<BannerDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findById (id: string): Promise<Banner | null> {
|
|
13
|
+
return this.bannerModel
|
|
14
|
+
.findById(id)
|
|
15
|
+
.exec();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async findAndCount (limit: number, skip: number): Promise<{
|
|
19
|
+
items: Array<Banner>,
|
|
20
|
+
total: number
|
|
21
|
+
}> {
|
|
22
|
+
const items = await this.bannerModel
|
|
23
|
+
.find()
|
|
24
|
+
.sort({ createDate: -1 })
|
|
25
|
+
.limit(limit)
|
|
26
|
+
.skip(skip)
|
|
27
|
+
.exec();
|
|
28
|
+
|
|
29
|
+
const total = await this.bannerModel
|
|
30
|
+
.find()
|
|
31
|
+
.countDocuments()
|
|
32
|
+
.exec();
|
|
33
|
+
|
|
34
|
+
return { items, total };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async createBanner (banner: Banner): Promise<Banner> {
|
|
38
|
+
return this.bannerModel.create(banner);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async updateBanner (bannerId: string, banner: Partial<Banner>): Promise<void> {
|
|
42
|
+
await this.bannerModel.findByIdAndUpdate(
|
|
43
|
+
bannerId,
|
|
44
|
+
{
|
|
45
|
+
$set: {
|
|
46
|
+
...banner,
|
|
47
|
+
},
|
|
48
|
+
}).exec();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public async removeBanner (bannerId: string): Promise<void> {
|
|
52
|
+
await this.bannerModel.findByIdAndDelete(bannerId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Complain, ComplainDocument } from '../';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class ComplainsRepository {
|
|
9
|
-
constructor (@InjectModel(Complain.name) private complainModel: Model<ComplainDocument>) {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async findAndCount (limit: number, skip: number): Promise<{
|
|
13
|
-
items: Array<Complain>,
|
|
14
|
-
total: number
|
|
15
|
-
}> {
|
|
16
|
-
const items = await this.complainModel
|
|
17
|
-
.find()
|
|
18
|
-
.sort({ createDate: -1 })
|
|
19
|
-
.limit(limit)
|
|
20
|
-
.skip(skip)
|
|
21
|
-
.exec();
|
|
22
|
-
|
|
23
|
-
const total = await this.complainModel
|
|
24
|
-
.find()
|
|
25
|
-
.countDocuments()
|
|
26
|
-
.exec();
|
|
27
|
-
|
|
28
|
-
return { items, total };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Complain, ComplainDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ComplainsRepository {
|
|
9
|
+
constructor (@InjectModel(Complain.name) private complainModel: Model<ComplainDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findAndCount (limit: number, skip: number): Promise<{
|
|
13
|
+
items: Array<Complain>,
|
|
14
|
+
total: number
|
|
15
|
+
}> {
|
|
16
|
+
const items = await this.complainModel
|
|
17
|
+
.find()
|
|
18
|
+
.sort({ createDate: -1 })
|
|
19
|
+
.limit(limit)
|
|
20
|
+
.skip(skip)
|
|
21
|
+
.exec();
|
|
22
|
+
|
|
23
|
+
const total = await this.complainModel
|
|
24
|
+
.find()
|
|
25
|
+
.countDocuments()
|
|
26
|
+
.exec();
|
|
27
|
+
|
|
28
|
+
return { items, total };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { DailyBonus, DailyBonusDocument } from '../';
|
|
6
|
-
import { getChannelRegExpFilter } from '../utils';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class DailyBonusRepository {
|
|
10
|
-
constructor(@InjectModel(DailyBonus.name) private dailyBonusModel: Model<DailyBonusDocument>) {
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async findDailyBonuses(channel: string, game: string): Promise<Array<DailyBonus> | null> {
|
|
14
|
-
return this.dailyBonusModel
|
|
15
|
-
.find({
|
|
16
|
-
channels: getChannelRegExpFilter(channel),
|
|
17
|
-
})
|
|
18
|
-
.exec();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async findDailyBonusByDay(day: number, game: string): Promise<DailyBonus | null> {
|
|
22
|
-
return this.dailyBonusModel
|
|
23
|
-
.findOne({ game, position: day })
|
|
24
|
-
.exec();
|
|
25
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { DailyBonus, DailyBonusDocument } from '../';
|
|
6
|
+
import { getChannelRegExpFilter } from '../utils';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class DailyBonusRepository {
|
|
10
|
+
constructor(@InjectModel(DailyBonus.name) private dailyBonusModel: Model<DailyBonusDocument>) {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async findDailyBonuses(channel: string, game: string): Promise<Array<DailyBonus> | null> {
|
|
14
|
+
return this.dailyBonusModel
|
|
15
|
+
.find({
|
|
16
|
+
channels: getChannelRegExpFilter(channel),
|
|
17
|
+
})
|
|
18
|
+
.exec();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async findDailyBonusByDay(day: number, game: string): Promise<DailyBonus | null> {
|
|
22
|
+
return this.dailyBonusModel
|
|
23
|
+
.findOne({ game, position: day })
|
|
24
|
+
.exec();
|
|
25
|
+
}
|
|
26
26
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Friend, FriendDocument } from '..';
|
|
6
|
-
import { getChannelRegExpFilter } from '../utils';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class FriendRepository {
|
|
10
|
-
constructor (@InjectModel(Friend.name) private friendModel: Model<FriendDocument>) {
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async findFriend (channel: string, game: string): Promise<Array<Friend> | null> {
|
|
14
|
-
return this.friendModel
|
|
15
|
-
.find({
|
|
16
|
-
channels: getChannelRegExpFilter(channel),
|
|
17
|
-
})
|
|
18
|
-
.exec();
|
|
19
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Friend, FriendDocument } from '..';
|
|
6
|
+
import { getChannelRegExpFilter } from '../utils';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class FriendRepository {
|
|
10
|
+
constructor (@InjectModel(Friend.name) private friendModel: Model<FriendDocument>) {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async findFriend (channel: string, game: string): Promise<Array<Friend> | null> {
|
|
14
|
+
return this.friendModel
|
|
15
|
+
.find({
|
|
16
|
+
channels: getChannelRegExpFilter(channel),
|
|
17
|
+
})
|
|
18
|
+
.exec();
|
|
19
|
+
}
|
|
20
20
|
}
|