jp.db.schemas 2.2.13 → 2.2.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/repositories/products.repository.js +1 -1
- package/dist/repositories/products.repository.js.map +1 -1
- package/dist/repositories/settings-options.repository.js +1 -1
- package/dist/repositories/settings-options.repository.js.map +1 -1
- package/dist/schemas/user.schema.d.ts.map +1 -1
- package/dist/schemas/user.schema.js +1 -1
- package/dist/schemas/user.schema.js.map +1 -1
- package/package.json +37 -37
- package/readme.md +3 -3
- package/src/index.ts +277 -277
- package/src/models/account-type.enum.ts +8 -8
- package/src/models/activity-log-user-login.interface.ts +10 -10
- package/src/models/activity-log.enum.ts +8 -8
- package/src/models/currency.enum.ts +6 -6
- package/src/models/experiences-level-edge.enum.ts +4 -4
- package/src/models/experiences-level-rank.enum.ts +5 -5
- package/src/models/rating-add-bulk-item.interface.ts +7 -7
- package/src/models/rating-monthly-result.interface.ts +12 -12
- 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/models/users-balance-reason.enum.ts +8 -8
- package/src/repositories/achievement.repository.ts +22 -22
- package/src/repositories/activity-log.repository.ts +209 -209
- package/src/repositories/admin.repository.ts +20 -20
- package/src/repositories/article.repository.ts +24 -24
- package/src/repositories/banners.repository.ts +67 -67
- package/src/repositories/complains.repository.ts +31 -31
- package/src/repositories/daily-bonus.repository.ts +33 -33
- package/src/repositories/friend.repository.ts +16 -16
- package/src/repositories/game-result.repository.ts +19 -19
- package/src/repositories/game-statistic.repository.ts +22 -22
- package/src/repositories/index.ts +57 -57
- package/src/repositories/many-tables-tournament-rooms.repository.ts +167 -167
- package/src/repositories/menu.repository.ts +20 -20
- package/src/repositories/notification.repository.ts +59 -59
- package/src/repositories/one-table-tournament-rooms.repository.ts +142 -142
- package/src/repositories/premium.repository.ts +22 -22
- package/src/repositories/products.repository.ts +32 -32
- package/src/repositories/purchase.repository.ts +111 -111
- package/src/repositories/rating.repository.ts +79 -79
- package/src/repositories/rule.repository.ts +20 -20
- package/src/repositories/servers.repository.ts +16 -16
- package/src/repositories/setting.repository.ts +25 -25
- package/src/repositories/settings-options.repository.ts +17 -17
- package/src/repositories/simple-rooms.repository.ts +16 -16
- package/src/repositories/users-achievements.repository.ts +46 -46
- package/src/repositories/users-balances.repository.ts +65 -65
- package/src/repositories/users.repository.ts +153 -153
- package/src/repositories/welcome.repository.ts +22 -22
- package/src/schemas/achievement.schema.ts +34 -34
- 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/banner.schema.ts +37 -37
- package/src/schemas/channel_message.schema.ts +32 -32
- package/src/schemas/complain.schema.ts +46 -46
- package/src/schemas/daily_bonus.schema.ts +46 -46
- package/src/schemas/feature.schema.ts +28 -28
- package/src/schemas/friend.schema.ts +46 -46
- package/src/schemas/game_result.schema.ts +68 -68
- package/src/schemas/game_statistic.schema.ts +34 -34
- package/src/schemas/many_tables_tournament_rooms.schema.ts +87 -87
- package/src/schemas/menu.schema.ts +37 -37
- package/src/schemas/notification.schema.ts +61 -61
- package/src/schemas/one_table_tournament_rooms.schema.ts +84 -84
- package/src/schemas/premium.schema.ts +34 -34
- package/src/schemas/product.schema.ts +111 -111
- package/src/schemas/purchase.schema.ts +61 -61
- package/src/schemas/purchase_channel.schema.ts +32 -32
- package/src/schemas/rating.schema.ts +37 -37
- package/src/schemas/rule.schema.ts +34 -34
- package/src/schemas/server.schema.ts +22 -22
- package/src/schemas/setting.schema.ts +49 -49
- package/src/schemas/settings_option.schema.ts +41 -41
- package/src/schemas/simple_rooms.schema.ts +49 -49
- 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 +53 -53
- package/src/schemas/user.schema.ts +185 -187
- 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/users_achievement.schema.ts +41 -41
- package/src/schemas/users_balance.schema.ts +34 -34
- package/src/schemas/welcome.schema.ts +37 -37
- package/src/utils.ts +7 -7
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Rating, RatingDocument } from '..';
|
|
6
|
-
import { IRatingMonthlyResult } from '../models/rating-monthly-result.interface';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class RatingRepository {
|
|
10
|
-
constructor(
|
|
11
|
-
@InjectModel(Rating.name) private ratingModel: Model<RatingDocument>,
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
async addBulkPlayerRating(items: Array<Rating>): Promise<void> {
|
|
15
|
-
await this.ratingModel.insertMany(items);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async getMonthlyRatingList(
|
|
19
|
-
game: string,
|
|
20
|
-
startDate: Date,
|
|
21
|
-
endDate: Date,
|
|
22
|
-
): Promise<Array<IRatingMonthlyResult>> {
|
|
23
|
-
return this.ratingModel.aggregate([
|
|
24
|
-
{
|
|
25
|
-
$match: {
|
|
26
|
-
game,
|
|
27
|
-
date: {
|
|
28
|
-
$gte: startDate,
|
|
29
|
-
$lte: endDate,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
$group: {
|
|
35
|
-
_id: {
|
|
36
|
-
userId: '$userId',
|
|
37
|
-
date: {
|
|
38
|
-
$dateToString: {
|
|
39
|
-
format: '%Y-%m',
|
|
40
|
-
date: '$date',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
userId: { $first: '$userId' },
|
|
45
|
-
userName: { $first: '$userName' },
|
|
46
|
-
userAvatarUrl: { $first: '$userAvatarUrl' },
|
|
47
|
-
game: { $first: '$game' },
|
|
48
|
-
channel: { $first: '$channel' },
|
|
49
|
-
count: { $sum: 1 },
|
|
50
|
-
profit: { $sum: '$profit' },
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
$sort: { profit: -1 },
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
$setWindowFields: {
|
|
58
|
-
sortBy: { profit: -1 },
|
|
59
|
-
output: { rank: { $rank: {} } },
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
$project: {
|
|
64
|
-
_id: 0,
|
|
65
|
-
id: { $concat: ['$_id.userId', '_', '$_id.date'] },
|
|
66
|
-
userId: 1,
|
|
67
|
-
userName: 1,
|
|
68
|
-
userAvatarUrl: 1,
|
|
69
|
-
game: 1,
|
|
70
|
-
channel: 1,
|
|
71
|
-
count: 1,
|
|
72
|
-
date: '$_id.date',
|
|
73
|
-
rank: 1,
|
|
74
|
-
profit: 1,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
]);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Rating, RatingDocument } from '..';
|
|
6
|
+
import { IRatingMonthlyResult } from '../models/rating-monthly-result.interface';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class RatingRepository {
|
|
10
|
+
constructor(
|
|
11
|
+
@InjectModel(Rating.name) private ratingModel: Model<RatingDocument>,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
async addBulkPlayerRating(items: Array<Rating>): Promise<void> {
|
|
15
|
+
await this.ratingModel.insertMany(items);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async getMonthlyRatingList(
|
|
19
|
+
game: string,
|
|
20
|
+
startDate: Date,
|
|
21
|
+
endDate: Date,
|
|
22
|
+
): Promise<Array<IRatingMonthlyResult>> {
|
|
23
|
+
return this.ratingModel.aggregate([
|
|
24
|
+
{
|
|
25
|
+
$match: {
|
|
26
|
+
game,
|
|
27
|
+
date: {
|
|
28
|
+
$gte: startDate,
|
|
29
|
+
$lte: endDate,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
$group: {
|
|
35
|
+
_id: {
|
|
36
|
+
userId: '$userId',
|
|
37
|
+
date: {
|
|
38
|
+
$dateToString: {
|
|
39
|
+
format: '%Y-%m',
|
|
40
|
+
date: '$date',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
userId: { $first: '$userId' },
|
|
45
|
+
userName: { $first: '$userName' },
|
|
46
|
+
userAvatarUrl: { $first: '$userAvatarUrl' },
|
|
47
|
+
game: { $first: '$game' },
|
|
48
|
+
channel: { $first: '$channel' },
|
|
49
|
+
count: { $sum: 1 },
|
|
50
|
+
profit: { $sum: '$profit' },
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
$sort: { profit: -1 },
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
$setWindowFields: {
|
|
58
|
+
sortBy: { profit: -1 },
|
|
59
|
+
output: { rank: { $rank: {} } },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
$project: {
|
|
64
|
+
_id: 0,
|
|
65
|
+
id: { $concat: ['$_id.userId', '_', '$_id.date'] },
|
|
66
|
+
userId: 1,
|
|
67
|
+
userName: 1,
|
|
68
|
+
userAvatarUrl: 1,
|
|
69
|
+
game: 1,
|
|
70
|
+
channel: 1,
|
|
71
|
+
count: 1,
|
|
72
|
+
date: '$_id.date',
|
|
73
|
+
rank: 1,
|
|
74
|
+
profit: 1,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
]);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Rule, RuleDocument } from '..';
|
|
6
|
-
import { getGameRegExpFilter, getChannelRegExpFilter } from '../utils';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class RuleRepository {
|
|
10
|
-
constructor(@InjectModel(Rule.name) private ruleModel: Model<RuleDocument>) {}
|
|
11
|
-
|
|
12
|
-
async findRule(game: string, channel: string): Promise<Rule | null> {
|
|
13
|
-
return this.ruleModel
|
|
14
|
-
.findOne({
|
|
15
|
-
game: getGameRegExpFilter(game),
|
|
16
|
-
channel: getChannelRegExpFilter(channel),
|
|
17
|
-
})
|
|
18
|
-
.exec();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Rule, RuleDocument } from '..';
|
|
6
|
+
import { getGameRegExpFilter, getChannelRegExpFilter } from '../utils';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class RuleRepository {
|
|
10
|
+
constructor(@InjectModel(Rule.name) private ruleModel: Model<RuleDocument>) {}
|
|
11
|
+
|
|
12
|
+
async findRule(game: string, channel: string): Promise<Rule | null> {
|
|
13
|
+
return this.ruleModel
|
|
14
|
+
.findOne({
|
|
15
|
+
game: getGameRegExpFilter(game),
|
|
16
|
+
channel: getChannelRegExpFilter(channel),
|
|
17
|
+
})
|
|
18
|
+
.exec();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Server, ServerDocument } from '../';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class ServersRepository {
|
|
9
|
-
constructor(
|
|
10
|
-
@InjectModel(Server.name) private serverModel: Model<ServerDocument>,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async findServerByName(name: string): Promise<Server | null> {
|
|
14
|
-
return this.serverModel.findOne({ name }).exec();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Server, ServerDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ServersRepository {
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(Server.name) private serverModel: Model<ServerDocument>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findServerByName(name: string): Promise<Server | null> {
|
|
14
|
+
return this.serverModel.findOne({ name }).exec();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { Setting, SettingDocument } from '..';
|
|
6
|
-
import { getChannelRegExpFilter, getGameRegExpFilter } from '../utils';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class SettingRepository {
|
|
10
|
-
constructor(
|
|
11
|
-
@InjectModel(Setting.name) private settingModel: Model<SettingDocument>,
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
async findSettings(
|
|
15
|
-
game: string,
|
|
16
|
-
channel: string,
|
|
17
|
-
): Promise<Array<Setting> | null> {
|
|
18
|
-
return this.settingModel
|
|
19
|
-
.find({
|
|
20
|
-
game: getGameRegExpFilter(game),
|
|
21
|
-
channel: getChannelRegExpFilter(channel),
|
|
22
|
-
})
|
|
23
|
-
.exec();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Setting, SettingDocument } from '..';
|
|
6
|
+
import { getChannelRegExpFilter, getGameRegExpFilter } from '../utils';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class SettingRepository {
|
|
10
|
+
constructor(
|
|
11
|
+
@InjectModel(Setting.name) private settingModel: Model<SettingDocument>,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
async findSettings(
|
|
15
|
+
game: string,
|
|
16
|
+
channel: string,
|
|
17
|
+
): Promise<Array<Setting> | null> {
|
|
18
|
+
return this.settingModel
|
|
19
|
+
.find({
|
|
20
|
+
game: getGameRegExpFilter(game),
|
|
21
|
+
channel: getChannelRegExpFilter(channel),
|
|
22
|
+
})
|
|
23
|
+
.exec();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { SettingsOption, SettingsOptionDocument } from '..';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class SettingsOptionsRepository {
|
|
9
|
-
constructor(
|
|
10
|
-
@InjectModel(SettingsOption.name)
|
|
11
|
-
private settingOptionsModel: Model<SettingsOptionDocument>,
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
async findSettingsOptions(): Promise<Array<SettingsOption> | null> {
|
|
15
|
-
return this.settingOptionsModel.find().exec();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { SettingsOption, SettingsOptionDocument } from '..';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class SettingsOptionsRepository {
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(SettingsOption.name)
|
|
11
|
+
private settingOptionsModel: Model<SettingsOptionDocument>,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
async findSettingsOptions(): Promise<Array<SettingsOption> | null> {
|
|
15
|
+
return this.settingOptionsModel.find().sort({ position: 1 }).exec();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { SimpleRoom, SimpleRoomDocument } from '../';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class SimpleRoomsRepository {
|
|
9
|
-
constructor(
|
|
10
|
-
@InjectModel(SimpleRoom.name) private roomModel: Model<SimpleRoomDocument>,
|
|
11
|
-
) {}
|
|
12
|
-
|
|
13
|
-
async findRooms(gameType: string): Promise<Array<SimpleRoomDocument>> {
|
|
14
|
-
return this.roomModel.find({ gameType }).exec();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { SimpleRoom, SimpleRoomDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class SimpleRoomsRepository {
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(SimpleRoom.name) private roomModel: Model<SimpleRoomDocument>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
async findRooms(gameType: string): Promise<Array<SimpleRoomDocument>> {
|
|
14
|
+
return this.roomModel.find({ gameType }).exec();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { UsersAchievement, UsersAchievementDocument } from '..';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class UsersAchievementsRepository {
|
|
9
|
-
constructor(
|
|
10
|
-
@InjectModel(UsersAchievement.name)
|
|
11
|
-
private usersAchievementModel: Model<UsersAchievementDocument>,
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
async findAchivementsByUserId(
|
|
15
|
-
userId: string,
|
|
16
|
-
): Promise<Array<UsersAchievement>> {
|
|
17
|
-
return this.usersAchievementModel.find({ userId }).exec();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async findAchivementsByUserIdAndAchievementCode(
|
|
21
|
-
userId: string,
|
|
22
|
-
achievementCode: string,
|
|
23
|
-
): Promise<Array<UsersAchievement>> {
|
|
24
|
-
return this.usersAchievementModel.find({ userId, achievementCode }).exec();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async addUsersAchievement(
|
|
28
|
-
userId: string,
|
|
29
|
-
userName: string,
|
|
30
|
-
achievementId: string,
|
|
31
|
-
achievementTitle: string,
|
|
32
|
-
achievementCode: string,
|
|
33
|
-
achievementPrize: number,
|
|
34
|
-
game: string,
|
|
35
|
-
): Promise<UsersAchievement> {
|
|
36
|
-
return this.usersAchievementModel.create({
|
|
37
|
-
userId,
|
|
38
|
-
userName,
|
|
39
|
-
achievementId,
|
|
40
|
-
achievementTitle,
|
|
41
|
-
achievementCode,
|
|
42
|
-
achievementPrize,
|
|
43
|
-
game,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { UsersAchievement, UsersAchievementDocument } from '..';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class UsersAchievementsRepository {
|
|
9
|
+
constructor(
|
|
10
|
+
@InjectModel(UsersAchievement.name)
|
|
11
|
+
private usersAchievementModel: Model<UsersAchievementDocument>,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
async findAchivementsByUserId(
|
|
15
|
+
userId: string,
|
|
16
|
+
): Promise<Array<UsersAchievement>> {
|
|
17
|
+
return this.usersAchievementModel.find({ userId }).exec();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async findAchivementsByUserIdAndAchievementCode(
|
|
21
|
+
userId: string,
|
|
22
|
+
achievementCode: string,
|
|
23
|
+
): Promise<Array<UsersAchievement>> {
|
|
24
|
+
return this.usersAchievementModel.find({ userId, achievementCode }).exec();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async addUsersAchievement(
|
|
28
|
+
userId: string,
|
|
29
|
+
userName: string,
|
|
30
|
+
achievementId: string,
|
|
31
|
+
achievementTitle: string,
|
|
32
|
+
achievementCode: string,
|
|
33
|
+
achievementPrize: number,
|
|
34
|
+
game: string,
|
|
35
|
+
): Promise<UsersAchievement> {
|
|
36
|
+
return this.usersAchievementModel.create({
|
|
37
|
+
userId,
|
|
38
|
+
userName,
|
|
39
|
+
achievementId,
|
|
40
|
+
achievementTitle,
|
|
41
|
+
achievementCode,
|
|
42
|
+
achievementPrize,
|
|
43
|
+
game,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
-
import { Model } from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { UsersBalance, UsersBalanceDocument } from '..';
|
|
6
|
-
import { UsersBalanceReasonEnum } from '../models/users-balance-reason.enum';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class UsersBalancesRepository {
|
|
10
|
-
constructor(
|
|
11
|
-
@InjectModel(UsersBalance.name)
|
|
12
|
-
private usersBalanceModel: Model<UsersBalanceDocument>,
|
|
13
|
-
) {}
|
|
14
|
-
|
|
15
|
-
async addUsersBalanceByRegister(
|
|
16
|
-
userId: string,
|
|
17
|
-
userName: string,
|
|
18
|
-
amount: number,
|
|
19
|
-
game: string,
|
|
20
|
-
): Promise<UsersBalance> {
|
|
21
|
-
return this.createUsersBalance({
|
|
22
|
-
userId,
|
|
23
|
-
userName,
|
|
24
|
-
amount,
|
|
25
|
-
reason: UsersBalanceReasonEnum.REGISTER,
|
|
26
|
-
game,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async addUsersBalanceByDailyBonus(
|
|
31
|
-
userId: string,
|
|
32
|
-
userName: string,
|
|
33
|
-
amount: number,
|
|
34
|
-
game: string,
|
|
35
|
-
): Promise<UsersBalance> {
|
|
36
|
-
return this.createUsersBalance({
|
|
37
|
-
userId,
|
|
38
|
-
userName,
|
|
39
|
-
amount,
|
|
40
|
-
reason: UsersBalanceReasonEnum.DAILY_BONUS,
|
|
41
|
-
game,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async addUsersBalanceByShopPurchase(
|
|
46
|
-
userId: string,
|
|
47
|
-
userName: string,
|
|
48
|
-
amount: number,
|
|
49
|
-
game: string,
|
|
50
|
-
): Promise<UsersBalance> {
|
|
51
|
-
return this.createUsersBalance({
|
|
52
|
-
userId,
|
|
53
|
-
userName,
|
|
54
|
-
amount,
|
|
55
|
-
reason: UsersBalanceReasonEnum.SHOP_PURCHASE,
|
|
56
|
-
game,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async createUsersBalance(
|
|
61
|
-
usersBalance: Partial<UsersBalance>,
|
|
62
|
-
): Promise<UsersBalance> {
|
|
63
|
-
return this.usersBalanceModel.create(usersBalance);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { UsersBalance, UsersBalanceDocument } from '..';
|
|
6
|
+
import { UsersBalanceReasonEnum } from '../models/users-balance-reason.enum';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class UsersBalancesRepository {
|
|
10
|
+
constructor(
|
|
11
|
+
@InjectModel(UsersBalance.name)
|
|
12
|
+
private usersBalanceModel: Model<UsersBalanceDocument>,
|
|
13
|
+
) {}
|
|
14
|
+
|
|
15
|
+
async addUsersBalanceByRegister(
|
|
16
|
+
userId: string,
|
|
17
|
+
userName: string,
|
|
18
|
+
amount: number,
|
|
19
|
+
game: string,
|
|
20
|
+
): Promise<UsersBalance> {
|
|
21
|
+
return this.createUsersBalance({
|
|
22
|
+
userId,
|
|
23
|
+
userName,
|
|
24
|
+
amount,
|
|
25
|
+
reason: UsersBalanceReasonEnum.REGISTER,
|
|
26
|
+
game,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async addUsersBalanceByDailyBonus(
|
|
31
|
+
userId: string,
|
|
32
|
+
userName: string,
|
|
33
|
+
amount: number,
|
|
34
|
+
game: string,
|
|
35
|
+
): Promise<UsersBalance> {
|
|
36
|
+
return this.createUsersBalance({
|
|
37
|
+
userId,
|
|
38
|
+
userName,
|
|
39
|
+
amount,
|
|
40
|
+
reason: UsersBalanceReasonEnum.DAILY_BONUS,
|
|
41
|
+
game,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async addUsersBalanceByShopPurchase(
|
|
46
|
+
userId: string,
|
|
47
|
+
userName: string,
|
|
48
|
+
amount: number,
|
|
49
|
+
game: string,
|
|
50
|
+
): Promise<UsersBalance> {
|
|
51
|
+
return this.createUsersBalance({
|
|
52
|
+
userId,
|
|
53
|
+
userName,
|
|
54
|
+
amount,
|
|
55
|
+
reason: UsersBalanceReasonEnum.SHOP_PURCHASE,
|
|
56
|
+
game,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async createUsersBalance(
|
|
61
|
+
usersBalance: Partial<UsersBalance>,
|
|
62
|
+
): Promise<UsersBalance> {
|
|
63
|
+
return this.usersBalanceModel.create(usersBalance);
|
|
64
|
+
}
|
|
65
|
+
}
|