jp.db.schemas 1.0.18 → 1.0.19
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/repositories/admin.repository.d.ts +9 -0
- package/dist/repositories/admin.repository.d.ts.map +1 -0
- package/dist/repositories/admin.repository.js +41 -0
- package/dist/repositories/admin.repository.js.map +1 -0
- package/dist/repositories/article.repository.d.ts +10 -0
- package/dist/repositories/article.repository.d.ts.map +1 -0
- package/dist/repositories/article.repository.js +50 -0
- package/dist/repositories/article.repository.js.map +1 -0
- package/dist/repositories/banners.repository.d.ts +15 -0
- package/dist/repositories/banners.repository.d.ts.map +1 -0
- package/dist/repositories/banners.repository.js +60 -0
- package/dist/repositories/banners.repository.js.map +1 -0
- package/dist/repositories/complains.repository.d.ts +11 -0
- package/dist/repositories/complains.repository.d.ts.map +1 -0
- package/dist/repositories/complains.repository.js +44 -0
- package/dist/repositories/complains.repository.js.map +1 -0
- package/dist/repositories/index.d.ts +11 -0
- package/dist/repositories/index.d.ts.map +1 -0
- package/dist/repositories/index.js +22 -0
- package/dist/repositories/index.js.map +1 -0
- package/dist/repositories/notification.repository.d.ts +15 -0
- package/dist/repositories/notification.repository.d.ts.map +1 -0
- package/dist/repositories/notification.repository.js +60 -0
- package/dist/repositories/notification.repository.js.map +1 -0
- package/dist/repositories/products.repository.d.ts +9 -0
- package/dist/repositories/products.repository.d.ts.map +1 -0
- package/dist/repositories/products.repository.js +46 -0
- package/dist/repositories/products.repository.js.map +1 -0
- package/dist/repositories/scheduled-tournaments.repository.d.ts +11 -0
- package/dist/repositories/scheduled-tournaments.repository.d.ts.map +1 -0
- package/dist/repositories/scheduled-tournaments.repository.js +44 -0
- package/dist/repositories/scheduled-tournaments.repository.js.map +1 -0
- package/dist/repositories/servers.repository.d.ts +8 -0
- package/dist/repositories/servers.repository.d.ts.map +1 -0
- package/dist/repositories/servers.repository.js +36 -0
- package/dist/repositories/servers.repository.js.map +1 -0
- package/dist/repositories/users.repository.d.ts +15 -0
- package/dist/repositories/users.repository.d.ts.map +1 -0
- package/dist/repositories/users.repository.js +70 -0
- package/dist/repositories/users.repository.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +7 -0
- package/dist/utils.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +24 -0
- package/src/repositories/admin.repository.ts +23 -0
- package/src/repositories/article.repository.ts +33 -0
- package/src/repositories/banners.repository.ts +54 -0
- package/src/repositories/complains.repository.ts +30 -0
- package/src/repositories/index.ts +21 -0
- package/src/repositories/notification.repository.ts +54 -0
- package/src/repositories/products.repository.ts +29 -0
- package/src/repositories/scheduled-tournaments.repository.ts +30 -0
- package/src/repositories/servers.repository.ts +18 -0
- package/src/repositories/users.repository.ts +69 -0
- package/src/utils.ts +3 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ScheduledTournamentsRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
18
|
+
const mongoose_2 = require("mongoose");
|
|
19
|
+
const __1 = require("../");
|
|
20
|
+
let ScheduledTournamentsRepository = class ScheduledTournamentsRepository {
|
|
21
|
+
constructor(scheduledTournamentModel) {
|
|
22
|
+
this.scheduledTournamentModel = scheduledTournamentModel;
|
|
23
|
+
}
|
|
24
|
+
async findAndCount(limit, skip) {
|
|
25
|
+
const items = await this.scheduledTournamentModel
|
|
26
|
+
.find({ category: 'global' })
|
|
27
|
+
.sort({ date: -1 })
|
|
28
|
+
.limit(limit)
|
|
29
|
+
.skip(skip)
|
|
30
|
+
.exec();
|
|
31
|
+
const total = await this.scheduledTournamentModel
|
|
32
|
+
.find({ category: 'global' })
|
|
33
|
+
.countDocuments()
|
|
34
|
+
.exec();
|
|
35
|
+
return { items, total };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.ScheduledTournamentsRepository = ScheduledTournamentsRepository;
|
|
39
|
+
exports.ScheduledTournamentsRepository = ScheduledTournamentsRepository = __decorate([
|
|
40
|
+
(0, common_1.Injectable)(),
|
|
41
|
+
__param(0, (0, mongoose_1.InjectModel)(__1.ScheduledTournament.name)),
|
|
42
|
+
__metadata("design:paramtypes", [mongoose_2.Model])
|
|
43
|
+
], ScheduledTournamentsRepository);
|
|
44
|
+
//# sourceMappingURL=scheduled-tournaments.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduled-tournaments.repository.js","sourceRoot":"","sources":["../../src/repositories/scheduled-tournaments.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA+C;AAC/C,uCAAiC;AAEjC,2BAAuE;AAGhE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACzC,YAA4D,wBAA4D;QAA5D,6BAAwB,GAAxB,wBAAwB,CAAoC;IACxH,CAAC;IAED,KAAK,CAAC,YAAY,CAAE,KAAa,EAAE,IAAY;QAI7C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,wBAAwB;aAC9C,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAC,CAAC;aAC3B,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aAClB,KAAK,CAAC,KAAK,CAAC;aACZ,IAAI,CAAC,IAAI,CAAC;aACV,IAAI,EAAE,CAAC;QAEV,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,wBAAwB;aAC9C,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAC,CAAC;aAC3B,cAAc,EAAE;aAChB,IAAI,EAAE,CAAC;QAEV,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC;CACF,CAAA;AAtBY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,GAAE;IAEG,WAAA,IAAA,sBAAW,EAAC,uBAAmB,CAAC,IAAI,CAAC,CAAA;qCAAmC,gBAAK;GADhF,8BAA8B,CAsB1C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { Server, ServerDocument } from '../';
|
|
3
|
+
export declare class ServersRepository {
|
|
4
|
+
private serverModel;
|
|
5
|
+
constructor(serverModel: Model<ServerDocument>);
|
|
6
|
+
findServerByName(name: string): Promise<Server | null>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=servers.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servers.repository.d.ts","sourceRoot":"","sources":["../../src/repositories/servers.repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAE7C,qBACa,iBAAiB;IACa,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC;IAG3E,gBAAgB,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAKhE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ServersRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
18
|
+
const mongoose_2 = require("mongoose");
|
|
19
|
+
const __1 = require("../");
|
|
20
|
+
let ServersRepository = class ServersRepository {
|
|
21
|
+
constructor(serverModel) {
|
|
22
|
+
this.serverModel = serverModel;
|
|
23
|
+
}
|
|
24
|
+
async findServerByName(name) {
|
|
25
|
+
return this.serverModel
|
|
26
|
+
.findOne({ name })
|
|
27
|
+
.exec();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.ServersRepository = ServersRepository;
|
|
31
|
+
exports.ServersRepository = ServersRepository = __decorate([
|
|
32
|
+
(0, common_1.Injectable)(),
|
|
33
|
+
__param(0, (0, mongoose_1.InjectModel)(__1.Server.name)),
|
|
34
|
+
__metadata("design:paramtypes", [mongoose_2.Model])
|
|
35
|
+
], ServersRepository);
|
|
36
|
+
//# sourceMappingURL=servers.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servers.repository.js","sourceRoot":"","sources":["../../src/repositories/servers.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA+C;AAC/C,uCAAiC;AAEjC,2BAA6C;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,YAA+C,WAAkC;QAAlC,gBAAW,GAAX,WAAW,CAAuB;IACjF,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAE,IAAY;QAChC,OAAO,IAAI,CAAC,WAAW;aAClB,OAAO,CAAC,EAAC,IAAI,EAAC,CAAC;aACf,IAAI,EAAE,CAAC;IAChB,CAAC;CACJ,CAAA;AATY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAEK,WAAA,IAAA,sBAAW,EAAC,UAAM,CAAC,IAAI,CAAC,CAAA;qCAAsB,gBAAK;GADxD,iBAAiB,CAS7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Model } from 'mongoose';
|
|
2
|
+
import { User, UserDocument } from '../';
|
|
3
|
+
export declare class UsersRepository {
|
|
4
|
+
private userModel;
|
|
5
|
+
constructor(userModel: Model<UserDocument>);
|
|
6
|
+
findById(id: string): Promise<User | null>;
|
|
7
|
+
findByVKId(vkId: number): Promise<User | null>;
|
|
8
|
+
findAndCount(userName: string, limit: number, skip: number): Promise<{
|
|
9
|
+
items: Array<User>;
|
|
10
|
+
total: number;
|
|
11
|
+
}>;
|
|
12
|
+
createUser(user: User): Promise<User>;
|
|
13
|
+
updateUser(userId: string, user: Partial<User>, balanceAdding?: number): Promise<UserDocument | null>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=users.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.repository.d.ts","sourceRoot":"","sources":["../../src/repositories/users.repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAWzC,qBACa,eAAe;IACa,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC;IAGrE,QAAQ,CAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAM3C,UAAU,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAM/C,YAAY,CAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QACxE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACnB,KAAK,EAAE,MAAM,CAAA;KAChB,CAAC;IAeI,UAAU,CAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC,UAAU,CAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAc/G"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UsersRepository = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
18
|
+
const mongoose_2 = require("mongoose");
|
|
19
|
+
const __1 = require("../");
|
|
20
|
+
function getFullNameFilter(userName) {
|
|
21
|
+
const regexpName = {
|
|
22
|
+
'$regex': userName,
|
|
23
|
+
'$options': 'i',
|
|
24
|
+
};
|
|
25
|
+
return userName ? { $or: [{ fullName: regexpName }, { fullNameAlias: regexpName }] } : {};
|
|
26
|
+
}
|
|
27
|
+
let UsersRepository = class UsersRepository {
|
|
28
|
+
constructor(userModel) {
|
|
29
|
+
this.userModel = userModel;
|
|
30
|
+
}
|
|
31
|
+
async findById(id) {
|
|
32
|
+
return this.userModel
|
|
33
|
+
.findById(id)
|
|
34
|
+
.exec();
|
|
35
|
+
}
|
|
36
|
+
async findByVKId(vkId) {
|
|
37
|
+
return this.userModel
|
|
38
|
+
.findOne({ 'vkUser.id': vkId })
|
|
39
|
+
.exec();
|
|
40
|
+
}
|
|
41
|
+
async findAndCount(userName, limit, skip) {
|
|
42
|
+
const items = await this.userModel
|
|
43
|
+
.find(getFullNameFilter(userName))
|
|
44
|
+
.limit(limit)
|
|
45
|
+
.skip(skip)
|
|
46
|
+
.exec();
|
|
47
|
+
const total = await this.userModel
|
|
48
|
+
.find(getFullNameFilter(userName))
|
|
49
|
+
.countDocuments()
|
|
50
|
+
.exec();
|
|
51
|
+
return { items, total };
|
|
52
|
+
}
|
|
53
|
+
async createUser(user) {
|
|
54
|
+
return this.userModel.create(user);
|
|
55
|
+
}
|
|
56
|
+
async updateUser(userId, user, balanceAdding) {
|
|
57
|
+
delete user.balance;
|
|
58
|
+
return this.userModel.findByIdAndUpdate(userId, {
|
|
59
|
+
$set: Object.assign({}, user),
|
|
60
|
+
$inc: { balance: balanceAdding !== null && balanceAdding !== void 0 ? balanceAdding : 0 }
|
|
61
|
+
}, { new: true }).exec();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.UsersRepository = UsersRepository;
|
|
65
|
+
exports.UsersRepository = UsersRepository = __decorate([
|
|
66
|
+
(0, common_1.Injectable)(),
|
|
67
|
+
__param(0, (0, mongoose_1.InjectModel)(__1.User.name)),
|
|
68
|
+
__metadata("design:paramtypes", [mongoose_2.Model])
|
|
69
|
+
], UsersRepository);
|
|
70
|
+
//# sourceMappingURL=users.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.repository.js","sourceRoot":"","sources":["../../src/repositories/users.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAA+C;AAC/C,uCAAiC;AAEjC,2BAAyC;AAEzC,SAAS,iBAAiB,CAAE,QAAgB;IACxC,MAAM,UAAU,GAAG;QACf,QAAQ,EAAE,QAAQ;QAClB,UAAU,EAAE,GAAG;KAClB,CAAC;IAEF,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9F,CAAC;AAGM,IAAM,eAAe,GAArB,MAAM,eAAe;IACxB,YAA6C,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAC3E,CAAC;IAED,KAAK,CAAC,QAAQ,CAAE,EAAU;QACtB,OAAO,IAAI,CAAC,SAAS;aAChB,QAAQ,CAAC,EAAE,CAAC;aACZ,IAAI,EAAE,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,UAAU,CAAE,IAAY;QAC1B,OAAO,IAAI,CAAC,SAAS;aAChB,OAAO,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;aAC9B,IAAI,EAAE,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,YAAY,CAAE,QAAgB,EAAE,KAAa,EAAE,IAAY;QAI7D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS;aAC7B,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;aACjC,KAAK,CAAC,KAAK,CAAC;aACZ,IAAI,CAAC,IAAI,CAAC;aACV,IAAI,EAAE,CAAC;QAEZ,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS;aAC7B,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;aACjC,cAAc,EAAE;aAChB,IAAI,EAAE,CAAC;QAEZ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,UAAU,CAAE,IAAU;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,UAAU,CAAE,MAAc,EAAE,IAAmB,EAAE,aAAsB;QACzE,OAAO,IAAI,CAAC,OAAO,CAAC;QAEpB,OAAO,IAAI,CAAC,SAAS,CAAC,iBAAiB,CACnC,MAAM,EACN;YACI,IAAI,oBACG,IAAI,CACV;YACD,IAAI,EAAE,EAAE,OAAO,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,CAAC,EAAE;SACxC,EACD,EAAE,GAAG,EAAE,IAAI,EAAE,CAChB,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;CACJ,CAAA;AApDY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAEK,WAAA,IAAA,sBAAW,EAAC,QAAI,CAAC,IAAI,CAAC,CAAA;qCAAoB,gBAAK;GADpD,eAAe,CAoD3B"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,UAErD"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAAA,wDAEC;AAFD,SAAgB,sBAAsB,CAAC,OAAe;IAClD,OAAO,IAAI,MAAM,CAAC,OAAO,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -45,6 +45,18 @@ import type { RatingDocument } from './schemas/rating.schema';
|
|
|
45
45
|
import { Setting, SettingSchema } from './schemas/setting.schema';
|
|
46
46
|
import type { SettingDocument } from './schemas/setting.schema';
|
|
47
47
|
|
|
48
|
+
import {
|
|
49
|
+
AdminRepository,
|
|
50
|
+
ArticleRepository,
|
|
51
|
+
BannersRepository,
|
|
52
|
+
ComplainsRepository,
|
|
53
|
+
NotificationRepository,
|
|
54
|
+
ProductsRepository,
|
|
55
|
+
ScheduledTournamentsRepository,
|
|
56
|
+
ServersRepository,
|
|
57
|
+
UsersRepository,
|
|
58
|
+
} from './repositories'
|
|
59
|
+
|
|
48
60
|
export type {
|
|
49
61
|
UserDocument,
|
|
50
62
|
FBUserDocument,
|
|
@@ -119,3 +131,15 @@ export {
|
|
|
119
131
|
Setting,
|
|
120
132
|
SettingSchema,
|
|
121
133
|
}
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
AdminRepository,
|
|
137
|
+
ArticleRepository,
|
|
138
|
+
BannersRepository,
|
|
139
|
+
ComplainsRepository,
|
|
140
|
+
NotificationRepository,
|
|
141
|
+
ProductsRepository,
|
|
142
|
+
ScheduledTournamentsRepository,
|
|
143
|
+
ServersRepository,
|
|
144
|
+
UsersRepository,
|
|
145
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AdminRepository } from './admin.repository';
|
|
2
|
+
import { ArticleRepository } from './article.repository';
|
|
3
|
+
import { BannersRepository } from './banners.repository';
|
|
4
|
+
import { ComplainsRepository } from './complains.repository';
|
|
5
|
+
import { NotificationRepository } from './notification.repository';
|
|
6
|
+
import { ProductsRepository } from './products.repository';
|
|
7
|
+
import { ScheduledTournamentsRepository } from './scheduled-tournaments.repository';
|
|
8
|
+
import { ServersRepository } from './servers.repository';
|
|
9
|
+
import { UsersRepository } from './users.repository';
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
AdminRepository,
|
|
13
|
+
ArticleRepository,
|
|
14
|
+
BannersRepository,
|
|
15
|
+
ComplainsRepository,
|
|
16
|
+
NotificationRepository,
|
|
17
|
+
ProductsRepository,
|
|
18
|
+
ScheduledTournamentsRepository,
|
|
19
|
+
ServersRepository,
|
|
20
|
+
UsersRepository,
|
|
21
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Notification, NotificationDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class NotificationRepository {
|
|
9
|
+
constructor (@InjectModel(Notification.name) private notificationModel: Model<NotificationDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findById (id: string): Promise<Notification | null> {
|
|
13
|
+
return this.notificationModel
|
|
14
|
+
.findById(id)
|
|
15
|
+
.exec();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async findAndCount (limit: number, skip: number): Promise<{
|
|
19
|
+
items: Array<Notification>,
|
|
20
|
+
total: number
|
|
21
|
+
}> {
|
|
22
|
+
const items = await this.notificationModel
|
|
23
|
+
.find()
|
|
24
|
+
.sort({ createDate: -1 })
|
|
25
|
+
.limit(limit)
|
|
26
|
+
.skip(skip)
|
|
27
|
+
.exec();
|
|
28
|
+
|
|
29
|
+
const total = await this.notificationModel
|
|
30
|
+
.find()
|
|
31
|
+
.countDocuments()
|
|
32
|
+
.exec();
|
|
33
|
+
|
|
34
|
+
return { items, total };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public async crateNotification (notification: Notification): Promise<Notification> {
|
|
38
|
+
return this.notificationModel.create(notification);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async updateNotification (notificationId: string, notification: Partial<Notification>): Promise<void> {
|
|
42
|
+
await this.notificationModel.findByIdAndUpdate(
|
|
43
|
+
notificationId,
|
|
44
|
+
{
|
|
45
|
+
$set: {
|
|
46
|
+
...notification,
|
|
47
|
+
},
|
|
48
|
+
}).exec();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public async removeNotification (notificationId: string): Promise<void> {
|
|
52
|
+
await this.notificationModel.findByIdAndDelete(notificationId);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { Product, ProductDocument } from '../';
|
|
6
|
+
import { getChannelRegExpFilter } from '../utils';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class ProductsRepository {
|
|
10
|
+
constructor (@InjectModel(Product.name) private productModel: Model<ProductDocument>) {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async findByProductId (productId: string): Promise<Product | null> {
|
|
14
|
+
return this.productModel
|
|
15
|
+
.findOne({ productId })
|
|
16
|
+
.exec();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async findProducts (parentId: string | null, channel: string): Promise<Array<Product> | null> {
|
|
20
|
+
return this.productModel
|
|
21
|
+
.find({
|
|
22
|
+
parentId,
|
|
23
|
+
active: true,
|
|
24
|
+
channels: getChannelRegExpFilter(channel),
|
|
25
|
+
})
|
|
26
|
+
.exec();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { ScheduledTournament, ScheduledTournamentDocument } from '../';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class ScheduledTournamentsRepository {
|
|
9
|
+
constructor (@InjectModel(ScheduledTournament.name) private scheduledTournamentModel: Model<ScheduledTournamentDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findAndCount (limit: number, skip: number): Promise<{
|
|
13
|
+
items: Array<ScheduledTournament>,
|
|
14
|
+
total: number
|
|
15
|
+
}> {
|
|
16
|
+
const items = await this.scheduledTournamentModel
|
|
17
|
+
.find({ category: 'global'})
|
|
18
|
+
.sort({ date: -1 })
|
|
19
|
+
.limit(limit)
|
|
20
|
+
.skip(skip)
|
|
21
|
+
.exec();
|
|
22
|
+
|
|
23
|
+
const total = await this.scheduledTournamentModel
|
|
24
|
+
.find({ category: 'global'})
|
|
25
|
+
.countDocuments()
|
|
26
|
+
.exec();
|
|
27
|
+
|
|
28
|
+
return { items, total };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 (@InjectModel(Server.name) private serverModel: Model<ServerDocument>) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async findServerByName (name: string): Promise<Server | null> {
|
|
13
|
+
return this.serverModel
|
|
14
|
+
.findOne({name})
|
|
15
|
+
.exec();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { InjectModel } from '@nestjs/mongoose';
|
|
3
|
+
import { Model } from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { User, UserDocument } from '../';
|
|
6
|
+
|
|
7
|
+
function getFullNameFilter (userName: string) {
|
|
8
|
+
const regexpName = {
|
|
9
|
+
'$regex': userName,
|
|
10
|
+
'$options': 'i',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return userName ? { $or: [{ fullName: regexpName }, { fullNameAlias: regexpName }] } : {};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Injectable()
|
|
17
|
+
export class UsersRepository {
|
|
18
|
+
constructor (@InjectModel(User.name) private userModel: Model<UserDocument>) {
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async findById (id: string): Promise<User | null> {
|
|
22
|
+
return this.userModel
|
|
23
|
+
.findById(id)
|
|
24
|
+
.exec();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async findByVKId (vkId: number): Promise<User | null> {
|
|
28
|
+
return this.userModel
|
|
29
|
+
.findOne({ 'vkUser.id': vkId })
|
|
30
|
+
.exec();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async findAndCount (userName: string, limit: number, skip: number): Promise<{
|
|
34
|
+
items: Array<User>,
|
|
35
|
+
total: number
|
|
36
|
+
}> {
|
|
37
|
+
const items = await this.userModel
|
|
38
|
+
.find(getFullNameFilter(userName))
|
|
39
|
+
.limit(limit)
|
|
40
|
+
.skip(skip)
|
|
41
|
+
.exec();
|
|
42
|
+
|
|
43
|
+
const total = await this.userModel
|
|
44
|
+
.find(getFullNameFilter(userName))
|
|
45
|
+
.countDocuments()
|
|
46
|
+
.exec();
|
|
47
|
+
|
|
48
|
+
return { items, total };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async createUser (user: User): Promise<User> {
|
|
52
|
+
return this.userModel.create(user);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async updateUser (userId: string, user: Partial<User>, balanceAdding?: number): Promise<UserDocument | null> {
|
|
56
|
+
delete user.balance;
|
|
57
|
+
|
|
58
|
+
return this.userModel.findByIdAndUpdate(
|
|
59
|
+
userId,
|
|
60
|
+
{
|
|
61
|
+
$set: {
|
|
62
|
+
...user,
|
|
63
|
+
},
|
|
64
|
+
$inc: { balance: balanceAdding ?? 0 }
|
|
65
|
+
},
|
|
66
|
+
{ new: true },
|
|
67
|
+
).exec();
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/utils.ts
ADDED