@chevre/domain 23.2.0-alpha.15 → 23.2.0-alpha.16
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/example/src/chevre/place/findEntranceGates.ts +27 -0
- package/example/src/chevre/roles/{addAdminSeatReadPermissionIfNotExists.ts → addAdminMovieTheaterReadPermissionIfNotExists.ts} +1 -1
- package/example/src/chevre/roles/{addAdminSeatWritePermissionIfNotExists.ts → addAdminMovieTheaterWritePermissionIfNotExists.ts} +1 -1
- package/lib/chevre/repo/place/entranceGate.d.ts +30 -0
- package/lib/chevre/repo/place/entranceGate.js +62 -0
- package/lib/chevre/repository.d.ts +8 -0
- package/lib/chevre/repository.js +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const entranceGateRepo = await chevre.repository.place.EntranceGate.createInstance(
|
|
12
|
+
mongoose.connection,
|
|
13
|
+
{ id: '5bfb841d5a78d7948369979a' }
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const entranceGates = await entranceGateRepo.findEntranceGates({
|
|
17
|
+
limit: 20,
|
|
18
|
+
page: 1,
|
|
19
|
+
project: { id: { $eq: project.id } }
|
|
20
|
+
});
|
|
21
|
+
console.log(entranceGates);
|
|
22
|
+
console.log(entranceGates.length);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
main()
|
|
26
|
+
.then(console.log)
|
|
27
|
+
.catch(console.error);
|
|
@@ -15,7 +15,7 @@ async function main() {
|
|
|
15
15
|
chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
16
16
|
];
|
|
17
17
|
const permissions = [
|
|
18
|
-
'admin.sellers.
|
|
18
|
+
'admin.sellers.movieTheaters.read'
|
|
19
19
|
];
|
|
20
20
|
for (const roleName of roleNames) {
|
|
21
21
|
for (const permission of permissions) {
|
|
@@ -15,7 +15,7 @@ async function main() {
|
|
|
15
15
|
// chevre.factory.role.organizationRole.RoleName.TicketClerk
|
|
16
16
|
];
|
|
17
17
|
const permissions = [
|
|
18
|
-
'admin.sellers.
|
|
18
|
+
'admin.sellers.movieTheaters.*'
|
|
19
19
|
];
|
|
20
20
|
for (const roleName of roleNames) {
|
|
21
21
|
for (const permission of permissions) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
import * as factory from '../../factory';
|
|
3
|
+
/**
|
|
4
|
+
* ゲートを操作する組織
|
|
5
|
+
*/
|
|
6
|
+
interface IOperator {
|
|
7
|
+
/**
|
|
8
|
+
* 施設ID
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
12
|
+
type IEntranceGate = Pick<factory.place.movieTheater.IEntranceGate, 'identifier' | 'name'>;
|
|
13
|
+
/**
|
|
14
|
+
* 施設の入場ゲートリポジトリ
|
|
15
|
+
*/
|
|
16
|
+
export declare class EntranceGateRepo {
|
|
17
|
+
private readonly operator;
|
|
18
|
+
private readonly civicStructureModel;
|
|
19
|
+
constructor(connection: Connection, operater: IOperator);
|
|
20
|
+
findEntranceGates(params: {
|
|
21
|
+
limit: number;
|
|
22
|
+
page: number;
|
|
23
|
+
project?: {
|
|
24
|
+
id?: {
|
|
25
|
+
$eq?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}): Promise<IEntranceGate[]>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EntranceGateRepo = void 0;
|
|
13
|
+
const mongoose_1 = require("mongoose");
|
|
14
|
+
const factory = require("../../factory");
|
|
15
|
+
const settings_1 = require("../../settings");
|
|
16
|
+
const civicStructure_1 = require("../mongoose/schemas/civicStructure");
|
|
17
|
+
/**
|
|
18
|
+
* 施設の入場ゲートリポジトリ
|
|
19
|
+
*/
|
|
20
|
+
class EntranceGateRepo {
|
|
21
|
+
constructor(connection, operater) {
|
|
22
|
+
this.civicStructureModel = connection.model(civicStructure_1.modelName, (0, civicStructure_1.createSchema)());
|
|
23
|
+
this.operator = operater;
|
|
24
|
+
}
|
|
25
|
+
findEntranceGates(params) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const matchStages = [
|
|
29
|
+
{ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(this.operator.id) } } }
|
|
30
|
+
];
|
|
31
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
32
|
+
if (typeof projectIdEq === 'string') {
|
|
33
|
+
matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
|
|
34
|
+
}
|
|
35
|
+
const aggregate = this.civicStructureModel.aggregate([
|
|
36
|
+
{
|
|
37
|
+
$unwind: {
|
|
38
|
+
path: '$hasEntranceGate'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
...matchStages,
|
|
42
|
+
{ $sort: { 'hasEntranceGate.identifier': factory.sortType.Ascending } },
|
|
43
|
+
{
|
|
44
|
+
$project: {
|
|
45
|
+
_id: 0,
|
|
46
|
+
identifier: '$hasEntranceGate.identifier',
|
|
47
|
+
name: '$hasEntranceGate.name'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]);
|
|
51
|
+
const { limit, page } = params;
|
|
52
|
+
if (typeof limit === 'number' && limit > 0) {
|
|
53
|
+
const pageMustBePositive = (typeof page === 'number' && page > 0) ? page : 1;
|
|
54
|
+
aggregate.skip(limit * (pageMustBePositive - 1))
|
|
55
|
+
.limit(limit);
|
|
56
|
+
}
|
|
57
|
+
return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
58
|
+
.exec();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.EntranceGateRepo = EntranceGateRepo;
|
|
@@ -51,6 +51,7 @@ import type { PaymentServiceProviderRepo } from './repo/paymentServiceProvider';
|
|
|
51
51
|
import type { PendingReservationRepo } from './repo/pendingReservation';
|
|
52
52
|
import type { PermitRepo } from './repo/permit';
|
|
53
53
|
import type { BusStopRepo } from './repo/place/busStop';
|
|
54
|
+
import type { EntranceGateRepo } from './repo/place/entranceGate';
|
|
54
55
|
import type { HasPOSRepo } from './repo/place/hasPOS';
|
|
55
56
|
import type { MovieTheaterRepo } from './repo/place/movieTheater';
|
|
56
57
|
import type { ScreeningRoomRepo } from './repo/place/screeningRoom';
|
|
@@ -316,6 +317,13 @@ export declare namespace place {
|
|
|
316
317
|
namespace BusStop {
|
|
317
318
|
function createInstance(...params: ConstructorParameters<typeof BusStopRepo>): Promise<BusStopRepo>;
|
|
318
319
|
}
|
|
320
|
+
type EntranceGate = EntranceGateRepo;
|
|
321
|
+
/**
|
|
322
|
+
* 施設の入場ゲートリポジトリ
|
|
323
|
+
*/
|
|
324
|
+
namespace EntranceGate {
|
|
325
|
+
function createInstance(...params: ConstructorParameters<typeof EntranceGateRepo>): Promise<EntranceGateRepo>;
|
|
326
|
+
}
|
|
319
327
|
type HasPOS = HasPOSRepo;
|
|
320
328
|
/**
|
|
321
329
|
* 施設PointOfSalesリポジトリ
|
package/lib/chevre/repository.js
CHANGED
|
@@ -721,6 +721,22 @@ var place;
|
|
|
721
721
|
}
|
|
722
722
|
BusStop.createInstance = createInstance;
|
|
723
723
|
})(BusStop = place.BusStop || (place.BusStop = {}));
|
|
724
|
+
/**
|
|
725
|
+
* 施設の入場ゲートリポジトリ
|
|
726
|
+
*/
|
|
727
|
+
let EntranceGate;
|
|
728
|
+
(function (EntranceGate) {
|
|
729
|
+
let repo;
|
|
730
|
+
function createInstance(...params) {
|
|
731
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
732
|
+
if (repo === undefined) {
|
|
733
|
+
repo = (yield Promise.resolve().then(() => require('./repo/place/entranceGate'))).EntranceGateRepo;
|
|
734
|
+
}
|
|
735
|
+
return new repo(...params);
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
EntranceGate.createInstance = createInstance;
|
|
739
|
+
})(EntranceGate = place.EntranceGate || (place.EntranceGate = {}));
|
|
724
740
|
/**
|
|
725
741
|
* 施設PointOfSalesリポジトリ
|
|
726
742
|
*/
|
package/package.json
CHANGED