Compare commits
No commits in common. "development" and "feat/fix-couch-transaction" have entirely different histories.
developmen
...
feat/fix-c
89
.drone.yml
89
.drone.yml
|
@ -2,37 +2,29 @@ kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: server
|
name: server
|
||||||
steps:
|
steps:
|
||||||
# - name: build
|
- name: build
|
||||||
# image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
# settings:
|
|
||||||
# host:
|
|
||||||
# - 172.10.10.10
|
|
||||||
# username: eigen
|
|
||||||
# key:
|
|
||||||
# from_secret: DEVOPS_SSH_PRIVATE_OPEN
|
|
||||||
# port: 22
|
|
||||||
# script:
|
|
||||||
# - cd /home/eigen/PROJECT/POS/POS.DEV/BE
|
|
||||||
# - sh build.sh
|
|
||||||
# when:
|
|
||||||
# ref:
|
|
||||||
# - refs/tags/devel_*
|
|
||||||
# - refs/tags/*-alpha.*
|
|
||||||
- name: build-testing
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
settings:
|
||||||
registry: registry.eigen.co.id
|
host:
|
||||||
repo: registry.eigen.co.id/eigen/${DRONE_REPO_NAME}
|
- 172.10.10.10
|
||||||
tags: ${DRONE_TAG}
|
username: eigen
|
||||||
custom_dns: 172.10.10.16
|
key:
|
||||||
|
from_secret: DEVOPS_SSH_PRIVATE_OPEN
|
||||||
|
port: 22
|
||||||
|
script:
|
||||||
|
- cd /home/eigen/PROJECT/POS/POS.DEV/BE
|
||||||
|
- sh build.sh
|
||||||
when:
|
when:
|
||||||
ref:
|
ref:
|
||||||
|
- refs/tags/devel_*
|
||||||
- refs/tags/*-alpha.*
|
- refs/tags/*-alpha.*
|
||||||
- name: build-production
|
- name: build-production
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
registry: registry.eigen.co.id
|
registry: registry.eigen.co.id
|
||||||
repo: registry.eigen.co.id/eigen/${DRONE_REPO_NAME}
|
repo: registry.eigen.co.id/eigen/${DRONE_REPO_NAME}
|
||||||
|
build_args:
|
||||||
|
- env_target=env.production
|
||||||
tags: ${DRONE_TAG}
|
tags: ${DRONE_TAG}
|
||||||
custom_dns: 172.10.10.16
|
custom_dns: 172.10.10.16
|
||||||
when:
|
when:
|
||||||
|
@ -54,56 +46,3 @@ trigger:
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- promote
|
- promote
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: kustomize
|
|
||||||
|
|
||||||
clone:
|
|
||||||
disable: true
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: kustomize-testing
|
|
||||||
image: registry.k8s.io/kustomize/kustomize:v5.0.0
|
|
||||||
environment:
|
|
||||||
DEVOPS_SSH_PRIVATE:
|
|
||||||
from_secret: DEVOPS_SSH_PRIVATE
|
|
||||||
DEVOPS_SSH_PUBLIC:
|
|
||||||
from_secret: DEVOPS_SSH_PUBLIC
|
|
||||||
INFRASTRUCTURE_REPO: "k8s-kustomize-external"
|
|
||||||
DIRECTORY_NAME: "weplay-pos-testing"
|
|
||||||
commands:
|
|
||||||
- mkdir -p ~/.ssh &&
|
|
||||||
- echo $DEVOPS_SSH_PRIVATE | base64 -d > ~/.ssh/id_rsa &&
|
|
||||||
- echo $DEVOPS_SSH_PUBLIC | base64 -d > ~/.ssh/id_rsa.pub &&
|
|
||||||
- ssh-keyscan -H -p 2222 git.eigen.co.id >> ~/.ssh/known_hosts &&
|
|
||||||
- chmod 700 ~/.ssh/ &&
|
|
||||||
- chmod 600 ~/.ssh/id_rsa &&
|
|
||||||
- git clone ssh://git@git.eigen.co.id:2222/eigen/$INFRASTRUCTURE_REPO.git &&
|
|
||||||
- cd $INFRASTRUCTURE_REPO/$DIRECTORY_NAME
|
|
||||||
- kustomize edit set image registry.eigen.co.id/eigen/$DRONE_REPO_NAME=registry.eigen.co.id/eigen/$DRONE_REPO_NAME:$DRONE_TAG &&
|
|
||||||
- git add . &&
|
|
||||||
- |-
|
|
||||||
git commit -m "feat: update $DRONE_REPO_NAME testing to $DRONE_TAG" &&
|
|
||||||
- git push origin master
|
|
||||||
- name: send-message
|
|
||||||
image: harbor.eigen.co.id/docker.com/plugins/webhook
|
|
||||||
settings:
|
|
||||||
urls: https://mattermost.eigen.co.id/api/v4/posts
|
|
||||||
content_type: application/json
|
|
||||||
headers:
|
|
||||||
- Authorization=Bearer 5zubexudb38uuradfa36qy98ca
|
|
||||||
template: |
|
|
||||||
{
|
|
||||||
"channel_id": "s1ekqde1c3du5p35g6budnuotc",
|
|
||||||
"message": "ALERT: {{ repo.name }} gagal update dengan tag ${DRONE_TAG}"
|
|
||||||
}
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- failure
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
include:
|
|
||||||
- refs/tags/*-alpha.*
|
|
||||||
depends_on:
|
|
||||||
- server
|
|
|
@ -1602,7 +1602,7 @@
|
||||||
mso-line-height-rule: exactly;
|
mso-line-height-rule: exactly;
|
||||||
mso-text-raise: 2px;
|
mso-text-raise: 2px;
|
||||||
"
|
"
|
||||||
>Click Here to Pay</a
|
>Pay Here</a
|
||||||
>
|
>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -44,6 +44,3 @@ GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec1
|
||||||
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
|
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
|
||||||
SUPERSET_ADMIN_USERNAME=admin
|
SUPERSET_ADMIN_USERNAME=admin
|
||||||
SUPERSET_ADMIN_PASSWORD=admin
|
SUPERSET_ADMIN_PASSWORD=admin
|
||||||
|
|
||||||
WHATSAPP_BUSINESS_ACCOUNT_NUMBER_ID=604883366037548
|
|
||||||
WHATSAPP_BUSINESS_ACCESS_TOKEN=EAAINOvRRiEEBO9yQsYDnYtjHZB7q1nZCwbBpRcxIGMDWajKZBtmWxNRKvPYkS95KQZBsZBOvSFyjiEg5CcCZBZBtaSZApxyV8fiA3cEyVwf7iVZBQP2YCTPRQZArMFeeXbO0uq5TGygmjsIz3M4YxcUHxPzKO4pKxIyxnzcoUZCqCSo1NqQSLVf3a0JyZAwgDXGL55dV
|
|
|
@ -41,6 +41,3 @@ GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec1
|
||||||
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
|
SUPERSET_URL=https://dashboard.weplayground.eigen.co.id
|
||||||
SUPERSET_ADMIN_USERNAME=admin
|
SUPERSET_ADMIN_USERNAME=admin
|
||||||
SUPERSET_ADMIN_PASSWORD=admin
|
SUPERSET_ADMIN_PASSWORD=admin
|
||||||
|
|
||||||
WHATSAPP_BUSINESS_ACCOUNT_NUMBER_ID=604883366037548
|
|
||||||
WHATSAPP_BUSINESS_ACCESS_TOKEN=EAAINOvRRiEEBO9yQsYDnYtjHZB7q1nZCwbBpRcxIGMDWajKZBtmWxNRKvPYkS95KQZBsZBOvSFyjiEg5CcCZBZBtaSZApxyV8fiA3cEyVwf7iVZBQP2YCTPRQZArMFeeXbO0uq5TGygmjsIz3M4YxcUHxPzKO4pKxIyxnzcoUZCqCSo1NqQSLVf3a0JyZAwgDXGL55dV
|
|
|
@ -49,7 +49,6 @@
|
||||||
"exceljs": "^4.4.0",
|
"exceljs": "^4.4.0",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.2.0",
|
||||||
"googleapis": "^140.0.0",
|
"googleapis": "^140.0.0",
|
||||||
"gtts": "^0.2.1",
|
|
||||||
"handlebars": "^4.7.8",
|
"handlebars": "^4.7.8",
|
||||||
"mathjs": "^13.0.2",
|
"mathjs": "^13.0.2",
|
||||||
"midtrans-client": "^1.3.1",
|
"midtrans-client": "^1.3.1",
|
||||||
|
|
|
@ -45,10 +45,8 @@ import { GoogleCalendarModule } from './modules/configuration/google-calendar/go
|
||||||
import { TransactionModule } from './modules/transaction/transaction/transaction.module';
|
import { TransactionModule } from './modules/transaction/transaction/transaction.module';
|
||||||
import { TransactionModel } from './modules/transaction/transaction/data/models/transaction.model';
|
import { TransactionModel } from './modules/transaction/transaction/data/models/transaction.model';
|
||||||
import {
|
import {
|
||||||
TransactionBreakdownTaxModel,
|
|
||||||
TransactionItemBreakdownModel,
|
TransactionItemBreakdownModel,
|
||||||
TransactionItemModel,
|
TransactionItemModel,
|
||||||
TransactionItemTaxModel,
|
|
||||||
} from './modules/transaction/transaction/data/models/transaction-item.model';
|
} from './modules/transaction/transaction/data/models/transaction-item.model';
|
||||||
import { TransactionTaxModel } from './modules/transaction/transaction/data/models/transaction-tax.model';
|
import { TransactionTaxModel } from './modules/transaction/transaction/data/models/transaction-tax.model';
|
||||||
import { ReconciliationModule } from './modules/transaction/reconciliation/reconciliation.module';
|
import { ReconciliationModule } from './modules/transaction/reconciliation/reconciliation.module';
|
||||||
|
@ -79,20 +77,6 @@ import { ExportModule } from './modules/configuration/export/export.module';
|
||||||
import { TransactionDemographyModel } from './modules/transaction/transaction/data/models/transaction-demography.model';
|
import { TransactionDemographyModel } from './modules/transaction/transaction/data/models/transaction-demography.model';
|
||||||
import { SupersetModule } from './modules/configuration/superset/superset.module';
|
import { SupersetModule } from './modules/configuration/superset/superset.module';
|
||||||
import { GateScanModule } from './modules/gates/gate.module';
|
import { GateScanModule } from './modules/gates/gate.module';
|
||||||
import { UserLoginModel } from './modules/user-related/user/data/models/user-login.model';
|
|
||||||
import { LogUserLoginModel } from './modules/configuration/log/data/models/log-user-login.model';
|
|
||||||
import { AuthService } from './core/guards/domain/services/auth.service';
|
|
||||||
import { ReportSummaryModule } from './modules/reports/report-summary/report-summary.module';
|
|
||||||
import { QueueModule } from './modules/queue/queue.module';
|
|
||||||
import {
|
|
||||||
QueueOrderModel,
|
|
||||||
QueueTicketModel,
|
|
||||||
QueueItemModel,
|
|
||||||
QueueModel,
|
|
||||||
} from './modules/queue/data/models/queue.model';
|
|
||||||
import { ItemQueueModule } from './modules/item-related/item-queue/item-queue.module';
|
|
||||||
import { ItemQueueModel } from './modules/item-related/item-queue/data/models/item-queue.model';
|
|
||||||
import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -117,9 +101,7 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
ItemModel,
|
ItemModel,
|
||||||
ItemCategoryModel,
|
ItemCategoryModel,
|
||||||
ItemRateModel,
|
ItemRateModel,
|
||||||
ItemQueueModel,
|
|
||||||
LogModel,
|
LogModel,
|
||||||
LogUserLoginModel,
|
|
||||||
NewsModel,
|
NewsModel,
|
||||||
PaymentMethodModel,
|
PaymentMethodModel,
|
||||||
PosLogModel,
|
PosLogModel,
|
||||||
|
@ -135,24 +117,13 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
TransactionTaxModel,
|
TransactionTaxModel,
|
||||||
TransactionDemographyModel,
|
TransactionDemographyModel,
|
||||||
TransactionItemBreakdownModel,
|
TransactionItemBreakdownModel,
|
||||||
TransactionItemTaxModel,
|
|
||||||
TransactionBreakdownTaxModel,
|
|
||||||
UserModel,
|
UserModel,
|
||||||
UserLoginModel,
|
|
||||||
|
|
||||||
VipCategoryModel,
|
VipCategoryModel,
|
||||||
VipCodeModel,
|
VipCodeModel,
|
||||||
|
|
||||||
// report
|
// report
|
||||||
ReportBookmarkModel,
|
ReportBookmarkModel,
|
||||||
ExportReportHistoryModel,
|
ExportReportHistoryModel,
|
||||||
|
|
||||||
// Queue
|
|
||||||
QueueOrderModel,
|
|
||||||
QueueTicketModel,
|
|
||||||
QueueItemModel,
|
|
||||||
QueueModel,
|
|
||||||
QueueBucketModel,
|
|
||||||
],
|
],
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
}),
|
}),
|
||||||
|
@ -178,7 +149,6 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
ItemCategoryModule,
|
ItemCategoryModule,
|
||||||
ItemModule,
|
ItemModule,
|
||||||
ItemRateModule,
|
ItemRateModule,
|
||||||
ItemQueueModule,
|
|
||||||
|
|
||||||
// transaction
|
// transaction
|
||||||
PaymentMethodModule,
|
PaymentMethodModule,
|
||||||
|
@ -206,18 +176,14 @@ import { QueueBucketModel } from './modules/queue/data/models/queue-bucket.model
|
||||||
ReportModule,
|
ReportModule,
|
||||||
ReportBookmarkModule,
|
ReportBookmarkModule,
|
||||||
ReportExportModule,
|
ReportExportModule,
|
||||||
ReportSummaryModule,
|
|
||||||
|
|
||||||
// superset
|
// superset
|
||||||
SupersetModule,
|
SupersetModule,
|
||||||
|
|
||||||
GateScanModule,
|
GateScanModule,
|
||||||
|
|
||||||
QueueModule,
|
|
||||||
],
|
],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [
|
providers: [
|
||||||
AuthService,
|
|
||||||
PrivilegeService,
|
PrivilegeService,
|
||||||
/**
|
/**
|
||||||
* By default all request from client will protect by JWT
|
* By default all request from client will protect by JWT
|
||||||
|
|
|
@ -7,10 +7,10 @@ import {
|
||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Reflector } from '@nestjs/core';
|
import { Reflector } from '@nestjs/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
import { SessionService, UsersSession } from 'src/core/sessions';
|
import { SessionService, UsersSession } from 'src/core/sessions';
|
||||||
import { UNPROTECTED_URL } from '../constants';
|
import { UNPROTECTED_URL } from '../constants';
|
||||||
import { PrivilegeService } from './services/privilege.service';
|
import { PrivilegeService } from './services/privilege.service';
|
||||||
import { AuthService } from './services/auth.service';
|
|
||||||
|
|
||||||
@Injectable({ scope: Scope.REQUEST })
|
@Injectable({ scope: Scope.REQUEST })
|
||||||
export class JWTGuard implements CanActivate {
|
export class JWTGuard implements CanActivate {
|
||||||
|
@ -18,13 +18,14 @@ export class JWTGuard implements CanActivate {
|
||||||
protected readonly session: SessionService,
|
protected readonly session: SessionService,
|
||||||
protected readonly reflector: Reflector,
|
protected readonly reflector: Reflector,
|
||||||
protected readonly privilege: PrivilegeService,
|
protected readonly privilege: PrivilegeService,
|
||||||
protected readonly authService: AuthService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
protected isPublic = false;
|
protected isPublic = false;
|
||||||
protected userSession: UsersSession;
|
protected userSession: UsersSession;
|
||||||
|
|
||||||
async canActivate(context: ExecutionContext) {
|
canActivate(
|
||||||
|
context: ExecutionContext,
|
||||||
|
): boolean | Promise<boolean> | Observable<boolean> {
|
||||||
/**
|
/**
|
||||||
* Check if access url is protected or not
|
* Check if access url is protected or not
|
||||||
* By default `isUnprotected` equals `false`
|
* By default `isUnprotected` equals `false`
|
||||||
|
@ -60,29 +61,9 @@ export class JWTGuard implements CanActivate {
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
this.userSession = this.session.verifyToken(token);
|
this.userSession = this.session.verifyToken(token);
|
||||||
await this.authService.verifyRegisteredLoginToken(token);
|
|
||||||
|
|
||||||
Logger.log(`Access from ${this.userSession.name}`, 'AuthGuard');
|
Logger.log(`Access from ${this.userSession.name}`, 'AuthGuard');
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const expiredError = error.message;
|
|
||||||
if (expiredError === 'jwt expired') {
|
|
||||||
const [, body] = token.split('.');
|
|
||||||
const bodyToken = JSON.parse(atob(body));
|
|
||||||
|
|
||||||
const user = {
|
|
||||||
role: bodyToken.role,
|
|
||||||
user_id: bodyToken.id,
|
|
||||||
username: bodyToken.username,
|
|
||||||
user_privilege_id: bodyToken.user_privilege_id,
|
|
||||||
item_id: bodyToken.item_id,
|
|
||||||
item_name: bodyToken.item_name,
|
|
||||||
source: bodyToken.source,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.authService.logoutUser(user, token);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new UnauthorizedException({
|
throw new UnauthorizedException({
|
||||||
code: 10001,
|
code: 10001,
|
||||||
message:
|
message:
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { MAIN_MENU } from '../constants';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RolesGuard extends JWTGuard {
|
export class RolesGuard extends JWTGuard {
|
||||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||||
await super.canActivate(context);
|
super.canActivate(context);
|
||||||
|
|
||||||
// jika endpoint tersebut bukan public, maka lakukan check lanjutan
|
// jika endpoint tersebut bukan public, maka lakukan check lanjutan
|
||||||
if (!this.isPublic) {
|
if (!this.isPublic) {
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
import {
|
|
||||||
HttpStatus,
|
|
||||||
Injectable,
|
|
||||||
Scope,
|
|
||||||
UnauthorizedException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { InjectDataSource } from '@nestjs/typeorm';
|
|
||||||
import {
|
|
||||||
CONNECTION_NAME,
|
|
||||||
OPERATION,
|
|
||||||
} from 'src/core/strings/constants/base.constants';
|
|
||||||
import { DataSource } from 'typeorm';
|
|
||||||
import { UserRole } from 'src/modules/user-related/user/constants';
|
|
||||||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
|
||||||
import { AppSource, LogUserType } from 'src/core/helpers/constant';
|
|
||||||
import { EventBus } from '@nestjs/cqrs';
|
|
||||||
import { LogUserLoginEvent } from 'src/modules/configuration/log/domain/entities/log-user-login.event';
|
|
||||||
import { UserLoginModel } from 'src/modules/user-related/user/data/models/user-login.model';
|
|
||||||
|
|
||||||
interface UserEntity {
|
|
||||||
user_id: string;
|
|
||||||
username: string;
|
|
||||||
role: UserRole;
|
|
||||||
user_privilege_id: string;
|
|
||||||
item_id: string;
|
|
||||||
item_name: string;
|
|
||||||
source: AppSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Injectable({ scope: Scope.REQUEST })
|
|
||||||
export class AuthService {
|
|
||||||
constructor(
|
|
||||||
@InjectDataSource(CONNECTION_NAME.DEFAULT)
|
|
||||||
protected readonly dataSource: DataSource,
|
|
||||||
|
|
||||||
private eventBus: EventBus,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
get repository() {
|
|
||||||
return this.dataSource.getRepository(UserLoginModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
async logoutUser(user: UserEntity, token: string) {
|
|
||||||
await this.repository.delete({ login_token: token });
|
|
||||||
|
|
||||||
const userLogout = {
|
|
||||||
type: LogUserType.logout,
|
|
||||||
created_at: new Date().getTime(),
|
|
||||||
name: user.username,
|
|
||||||
user_privilege_id: user.user_privilege_id,
|
|
||||||
...user,
|
|
||||||
};
|
|
||||||
|
|
||||||
this.eventBus.publish(
|
|
||||||
new LogUserLoginEvent({
|
|
||||||
id: user.user_id,
|
|
||||||
old: null,
|
|
||||||
data: userLogout,
|
|
||||||
user: userLogout as any,
|
|
||||||
description: 'Logout',
|
|
||||||
module: UserModel.name,
|
|
||||||
op: OPERATION.UPDATE,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async verifyRegisteredLoginToken(token: string) {
|
|
||||||
const data = await this.repository.findOneBy({ login_token: token });
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
throw new UnauthorizedException({
|
|
||||||
statusCode: HttpStatus.UNAUTHORIZED,
|
|
||||||
message: `Invalid token`,
|
|
||||||
error: 'Unauthorized',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
export enum LogUserType {
|
|
||||||
login = 'login',
|
|
||||||
logout = 'logout',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum AppSource {
|
|
||||||
POS_ADMIN = 'POS_ADMIN',
|
|
||||||
POS_COUNTER = 'POS_COUNTER',
|
|
||||||
QUEUE_ADMIN = 'QUEUE_ADMIN',
|
|
||||||
QUEUE_CUSTOMER = 'QUEUE_CUSTOMER',
|
|
||||||
}
|
|
|
@ -8,9 +8,7 @@ import { diskStorage } from 'multer';
|
||||||
const MB = 1024 * 1024;
|
const MB = 1024 * 1024;
|
||||||
|
|
||||||
const fileFilter = (req, file, callback) => {
|
const fileFilter = (req, file, callback) => {
|
||||||
if (
|
if (file.mimetype.match(/\/(jpg|jpeg|png)$/)) {
|
||||||
file.mimetype.match(/\/(jpg|jpeg|png|flv|mp4|m3u8|ts|3gp|mov|avi|wmv)$/)
|
|
||||||
) {
|
|
||||||
callback(null, true);
|
callback(null, true);
|
||||||
} else {
|
} else {
|
||||||
callback(
|
callback(
|
||||||
|
|
|
@ -32,7 +32,7 @@ export abstract class BaseManager {
|
||||||
|
|
||||||
setUser() {
|
setUser() {
|
||||||
try {
|
try {
|
||||||
this.user = this.userProvider?.user ?? BLANK_USER;
|
this.user = this.userProvider?.user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.user = BLANK_USER;
|
this.user = BLANK_USER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ export abstract class BaseCreateManager<Entity> extends BaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
async publishEvents() {
|
async publishEvents() {
|
||||||
this.eventBus?.publish(
|
this.eventBus.publish(
|
||||||
new RecordLog({
|
new RecordLog({
|
||||||
id: this.result['id'],
|
id: this.result['id'],
|
||||||
old: null,
|
old: null,
|
||||||
|
|
|
@ -50,7 +50,7 @@ export abstract class BaseIndexManager<Entity> extends BaseReadManager {
|
||||||
|
|
||||||
// jika searching status terdapat dalam enum, maka dia mencari specific data
|
// jika searching status terdapat dalam enum, maka dia mencari specific data
|
||||||
// ? karena jika tidak, ketika dia search "active" maka "inactive" juga ikut
|
// ? karena jika tidak, ketika dia search "active" maka "inactive" juga ikut
|
||||||
return `'${STATUS[statusData.toUpperCase()]}'`;
|
return `'${STATUS[statusData.toUpperCase()]}'` ?? `'%${statusData}%'`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const exist = specificFilter.find((item) => item.isStatus);
|
const exist = specificFilter.find((item) => item.isStatus);
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import { ValidateRelationHelper } from 'src/core/helpers/validation/validate-relation.helper';
|
import { ValidateRelationHelper } from 'src/core/helpers/validation/validate-relation.helper';
|
||||||
import { BaseManager } from '../base.manager';
|
import { BaseManager } from '../base.manager';
|
||||||
import {
|
import { OPERATION, STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
OPERATION,
|
|
||||||
QUEUE_STATUS,
|
|
||||||
STATUS,
|
|
||||||
} from 'src/core/strings/constants/base.constants';
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { RecordLog } from 'src/modules/configuration/log/domain/entities/log.event';
|
import { RecordLog } from 'src/modules/configuration/log/domain/entities/log.event';
|
||||||
|
|
||||||
|
@ -12,12 +8,12 @@ export abstract class BaseUpdateStatusManager<Entity> extends BaseManager {
|
||||||
protected dataId: string;
|
protected dataId: string;
|
||||||
protected result: Entity;
|
protected result: Entity;
|
||||||
protected oldData: Entity;
|
protected oldData: Entity;
|
||||||
protected dataStatus: STATUS | QUEUE_STATUS;
|
protected dataStatus: STATUS;
|
||||||
protected relations = [];
|
protected relations = [];
|
||||||
protected duplicateColumn: string[];
|
protected duplicateColumn: string[];
|
||||||
abstract get entityTarget(): any;
|
abstract get entityTarget(): any;
|
||||||
|
|
||||||
setData(id: string, status: STATUS | QUEUE_STATUS): void {
|
setData(id: string, status: STATUS): void {
|
||||||
/**
|
/**
|
||||||
* // TODO: Handle case confirm multiple tabs;
|
* // TODO: Handle case confirm multiple tabs;
|
||||||
* Pola id yang dikirim dirubah menjadi data_id___updated_at
|
* Pola id yang dikirim dirubah menjadi data_id___updated_at
|
||||||
|
|
|
@ -23,7 +23,6 @@ export class BaseFilterDto implements BaseFilterEntity {
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
limit = 10;
|
limit = 10;
|
||||||
|
|
||||||
@ApiProperty({ type: String, required: false })
|
|
||||||
q: string;
|
q: string;
|
||||||
|
|
||||||
@ApiProperty({ type: ['string'], required: false })
|
@ApiProperty({ type: ['string'], required: false })
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import { AppSource } from 'src/core/helpers/constant';
|
|
||||||
import { UserRole } from 'src/modules/user-related/user/constants';
|
import { UserRole } from 'src/modules/user-related/user/constants';
|
||||||
|
|
||||||
export interface UsersSession {
|
export interface UsersSession {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
role: UserRole;
|
role: UserRole;
|
||||||
source?: AppSource;
|
|
||||||
item_id?: string;
|
|
||||||
user_privilege_id: string;
|
user_privilege_id: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,4 @@ export class UserProvider {
|
||||||
const [, token] = this.request.headers['authorization'].split(' ');
|
const [, token] = this.request.headers['authorization'].split(' ');
|
||||||
return this.session.verifyToken(token);
|
return this.session.verifyToken(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
get token(): string {
|
|
||||||
const [, token] = this.request.headers['authorization'].split(' ');
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,6 @@ export enum STATUS {
|
||||||
WAITING = 'waiting',
|
WAITING = 'waiting',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum QUEUE_STATUS {
|
|
||||||
DONE = 'done',
|
|
||||||
CALLED = 'called',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ORDER_TYPE {
|
export enum ORDER_TYPE {
|
||||||
ASC = 'ASC',
|
ASC = 'ASC',
|
||||||
DESC = 'DESC',
|
DESC = 'DESC',
|
||||||
|
|
|
@ -4,7 +4,6 @@ export enum MODULE_NAME {
|
||||||
GATE = 'gates',
|
GATE = 'gates',
|
||||||
ITEM = 'items',
|
ITEM = 'items',
|
||||||
ITEM_CATEGORY = 'item-categories',
|
ITEM_CATEGORY = 'item-categories',
|
||||||
ITEM_QUEUE = 'item-queues',
|
|
||||||
ITEM_RATE = 'item-rates',
|
ITEM_RATE = 'item-rates',
|
||||||
NEWS = 'news',
|
NEWS = 'news',
|
||||||
PAYMENT_METHOD = 'payment-methods',
|
PAYMENT_METHOD = 'payment-methods',
|
||||||
|
@ -25,7 +24,4 @@ export enum MODULE_NAME {
|
||||||
REPORT = 'report',
|
REPORT = 'report',
|
||||||
REPORT_BOOKMARK = 'report-bookmark',
|
REPORT_BOOKMARK = 'report-bookmark',
|
||||||
REPORT_EXPORT = 'report-export',
|
REPORT_EXPORT = 'report-export',
|
||||||
REPORT_SUMMARY = 'report-summary',
|
|
||||||
|
|
||||||
QUEUE = 'queue',
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ export enum TABLE_NAME {
|
||||||
FAQ = 'faqs',
|
FAQ = 'faqs',
|
||||||
ITEM = 'items',
|
ITEM = 'items',
|
||||||
ITEM_CATEGORY = 'item_categories',
|
ITEM_CATEGORY = 'item_categories',
|
||||||
ITEM_QUEUE = 'item_queues',
|
|
||||||
ITEM_RATE = 'item_rates',
|
ITEM_RATE = 'item_rates',
|
||||||
GATE = 'gates',
|
GATE = 'gates',
|
||||||
LOG = 'logs',
|
LOG = 'logs',
|
||||||
|
@ -23,12 +22,8 @@ export enum TABLE_NAME {
|
||||||
TRANSACTION_ITEM = 'transaction_items',
|
TRANSACTION_ITEM = 'transaction_items',
|
||||||
TRANSACTION_ITEM_BREAKDOWN = 'transaction_item_breakdowns',
|
TRANSACTION_ITEM_BREAKDOWN = 'transaction_item_breakdowns',
|
||||||
TRANSACTION_TAX = 'transaction_taxes',
|
TRANSACTION_TAX = 'transaction_taxes',
|
||||||
TRANSACTION_ITEM_TAX = 'transaction_item_taxes',
|
|
||||||
TRANSACTION_ITEM_BREAKDOWN_TAX = 't_breakdown_item_taxes',
|
|
||||||
TRANSACTION_DEMOGRAPHY = 'transaction_demographies',
|
TRANSACTION_DEMOGRAPHY = 'transaction_demographies',
|
||||||
USER = 'users',
|
USER = 'users',
|
||||||
USER_LOGIN = 'users_login',
|
|
||||||
LOG_USER_LOGIN = 'log_users_login',
|
|
||||||
USER_PRIVILEGE = 'user_privileges',
|
USER_PRIVILEGE = 'user_privileges',
|
||||||
USER_PRIVILEGE_CONFIGURATION = 'user_privilege_configurations',
|
USER_PRIVILEGE_CONFIGURATION = 'user_privilege_configurations',
|
||||||
VIP_CATEGORY = 'vip_categories',
|
VIP_CATEGORY = 'vip_categories',
|
||||||
|
@ -36,10 +31,4 @@ export enum TABLE_NAME {
|
||||||
|
|
||||||
REPORT_BOOKMARK = 'report_bookmark',
|
REPORT_BOOKMARK = 'report_bookmark',
|
||||||
EXPORT_REPORT_HISTORY = 'export_report_history',
|
EXPORT_REPORT_HISTORY = 'export_report_history',
|
||||||
|
|
||||||
QUEUE = 'queues',
|
|
||||||
QUEUE_ORDER = 'queue_orders',
|
|
||||||
QUEUE_TICKET = 'queue_tickets',
|
|
||||||
QUEUE_ITEM = 'queue_items',
|
|
||||||
QUEUE_BUCKET = 'queue_bucket',
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ export class AddEstimationToItem1723801180604 implements MigrationInterface {
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`ALTER TABLE "items" ADD "play_estimation" numeric`,
|
`ALTER TABLE "items" ADD "play_estimation" integer`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddPaymentDateBankColumnAtTransaction1725962197762
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddPaymentDateBankColumnAtTransaction1725962197762';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" ADD "payment_date_bank" date`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" DROP COLUMN "payment_date_bank"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddPosNameColumn1726033041774 implements MigrationInterface {
|
|
||||||
name = 'AddPosNameColumn1726033041774';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" ADD "creator_counter_name" character varying`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "logs_pos" ADD "pos_name" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "logs_pos" DROP COLUMN "pos_name"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" DROP COLUMN "creator_counter_name"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddFlagRoleQueue1726041175749 implements MigrationInterface {
|
|
||||||
name = 'AddFlagRoleQueue1726041175749';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TYPE "public"."users_role_enum" RENAME TO "users_role_enum_old"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."users_role_enum" AS ENUM('superadmin', 'staff', 'tenant', 'queue_admin')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users" ALTER COLUMN "role" DROP DEFAULT`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users" ALTER COLUMN "role" TYPE "public"."users_role_enum" USING "role"::"text"::"public"."users_role_enum"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users" ALTER COLUMN "role" SET DEFAULT 'staff'`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."users_role_enum_old"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."users_role_enum_old" AS ENUM('superadmin', 'staff', 'tenant')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users" ALTER COLUMN "role" DROP DEFAULT`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users" ALTER COLUMN "role" TYPE "public"."users_role_enum_old" USING "role"::"text"::"public"."users_role_enum_old"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users" ALTER COLUMN "role" SET DEFAULT 'staff'`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."users_role_enum"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TYPE "public"."users_role_enum_old" RENAME TO "users_role_enum"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddTaxItemTransaction1726045820711 implements MigrationInterface {
|
|
||||||
name = 'AddTaxItemTransaction1726045820711';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "transaction_item_taxes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "tax_id" character varying, "tax_name" character varying, "taxt_value" numeric, "tax_total_value" numeric, "transaction_id" uuid, CONSTRAINT "PK_fc5f6da61b24eb5bfdd503b0a0d" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "t_breakdown_item_taxes" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "tax_id" character varying, "tax_name" character varying, "taxt_value" numeric, "tax_total_value" numeric, "transaction_id" uuid, CONSTRAINT "PK_a1ef08d2c68169a50102aa70eca" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "total_profit_share" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "total_profit_share" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_taxes" ADD CONSTRAINT "FK_f5c4966a381d903899cafb4b5ba" FOREIGN KEY ("transaction_id") REFERENCES "transaction_items"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "t_breakdown_item_taxes" ADD CONSTRAINT "FK_74bedce7e94f6707ddf26ef0c0f" FOREIGN KEY ("transaction_id") REFERENCES "transaction_item_breakdowns"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "payment_total_dpp" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "payment_total_dpp" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "payment_total_tax" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "payment_total_tax" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "total_share_tenant" numeric`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "t_breakdown_item_taxes" DROP CONSTRAINT "FK_74bedce7e94f6707ddf26ef0c0f"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_taxes" DROP CONSTRAINT "FK_f5c4966a381d903899cafb4b5ba"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "total_profit_share"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "total_profit_share"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TABLE "t_breakdown_item_taxes"`);
|
|
||||||
await queryRunner.query(`DROP TABLE "transaction_item_taxes"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "payment_total_dpp"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "payment_total_dpp"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "payment_total_tax"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "payment_total_tax"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "total_share_tenant"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddTableUserLogin1726115025759 implements MigrationInterface {
|
|
||||||
name = 'AddTableUserLogin1726115025759';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "users_login" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "login_date" bigint NOT NULL, "login_token" character varying, "user_id" uuid, CONSTRAINT "REL_2a80a213b51423ce5b8211f058" UNIQUE ("user_id"), CONSTRAINT "PK_e564194a9a22f8c623354284f75" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD CONSTRAINT "FK_2a80a213b51423ce5b8211f0584" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" DROP CONSTRAINT "FK_2a80a213b51423ce5b8211f0584"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TABLE "users_login"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class UpdateTableUserLogin1726122619596 implements MigrationInterface {
|
|
||||||
name = 'UpdateTableUserLogin1726122619596';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" DROP CONSTRAINT "FK_2a80a213b51423ce5b8211f0584"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD CONSTRAINT "FK_2a80a213b51423ce5b8211f0584" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" DROP CONSTRAINT "FK_2a80a213b51423ce5b8211f0584"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD CONSTRAINT "FK_2a80a213b51423ce5b8211f0584" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddTableLogUserLogin1726123955427 implements MigrationInterface {
|
|
||||||
name = 'AddTableLogUserLogin1726123955427';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."log_users_login_type_enum" AS ENUM('login', 'logout')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."log_users_login_role_enum" AS ENUM('superadmin', 'staff', 'tenant', 'queue_admin')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "log_users_login" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."log_users_login_type_enum", "role" "public"."log_users_login_role_enum", "user_id" uuid, "username" character varying, "created_at" bigint, CONSTRAINT "PK_75141588aa6ee560504f7d3adce" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`DROP TABLE "log_users_login"`);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."log_users_login_role_enum"`);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."log_users_login_type_enum"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddColumnItemId1726139426994 implements MigrationInterface {
|
|
||||||
name = 'AddColumnItemId1726139426994';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "users_login" ADD "item_id" uuid`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "log_users_login" ADD "item_id" uuid`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "log_users_login" DROP COLUMN "item_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`ALTER TABLE "users_login" DROP COLUMN "item_id"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddColumnItemName1726141393404 implements MigrationInterface {
|
|
||||||
name = 'AddColumnItemName1726141393404';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD "item_name" character varying`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "log_users_login" ADD "item_name" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "log_users_login" DROP COLUMN "item_name"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" DROP COLUMN "item_name"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddFormulaToTax1726365023179 implements MigrationInterface {
|
|
||||||
name = 'AddFormulaToTax1726365023179';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "taxes" ADD "formula_render" json`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "taxes" ADD "formula_string" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "taxes" DROP COLUMN "formula_string"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "taxes" DROP COLUMN "formula_render"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ChangeUserLoginRelation1726642119207
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'ChangeUserLoginRelation1726642119207';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "users" DROP COLUMN "refresh_token"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" DROP CONSTRAINT "FK_2a80a213b51423ce5b8211f0584"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" DROP CONSTRAINT "REL_2a80a213b51423ce5b8211f058"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD CONSTRAINT "FK_2a80a213b51423ce5b8211f0584" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" DROP CONSTRAINT "FK_2a80a213b51423ce5b8211f0584"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD CONSTRAINT "REL_2a80a213b51423ce5b8211f058" UNIQUE ("user_id")`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD CONSTRAINT "FK_2a80a213b51423ce5b8211f0584" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users" ADD "refresh_token" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddColumnSourceAtUserLogin1726642499135
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddColumnSourceAtUserLogin1726642499135';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."users_login_role_enum" AS ENUM('superadmin', 'staff', 'tenant', 'queue_admin')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD "role" "public"."users_login_role_enum"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."users_login_source_enum" AS ENUM('POS_ADMIN', 'POS_COUNTER', 'QUEUE_ADMIN', 'QUEUE_CUSTOMER')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "users_login" ADD "source" "public"."users_login_source_enum"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "users_login" DROP COLUMN "source"`);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."users_login_source_enum"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "users_login" DROP COLUMN "role"`);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."users_login_role_enum"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddSourceOnLogLogin1726647442006 implements MigrationInterface {
|
|
||||||
name = 'AddSourceOnLogLogin1726647442006';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."log_users_login_source_enum" AS ENUM('POS_ADMIN', 'POS_COUNTER', 'QUEUE_ADMIN', 'QUEUE_CUSTOMER')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "log_users_login" ADD "source" "public"."log_users_login_source_enum"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "log_users_login" DROP COLUMN "source"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."log_users_login_source_enum"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddDiscountForItemTransaction1726824289989
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddDiscountForItemTransaction1726824289989';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "subtotal" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "discount_value" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "subtotal" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "discount_value" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" ADD "total_price" numeric`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "total_price"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "discount_value"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" DROP COLUMN "subtotal"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "discount_value"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "subtotal"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ChangeColumnName1726830293878 implements MigrationInterface {
|
|
||||||
name = 'ChangeColumnName1726830293878';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" RENAME COLUMN "subtotal" TO "total_net_price"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" RENAME COLUMN "subtotal" TO "total_net_price"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_item_breakdowns" RENAME COLUMN "total_net_price" TO "subtotal"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" RENAME COLUMN "total_net_price" TO "subtotal"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddDiscountValueToVoucher1728377112337
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddDiscountValueToVoucher1728377112337';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_codes" ADD "discount_value" numeric`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_codes" ALTER COLUMN "discount" DROP NOT NULL`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_codes" ALTER COLUMN "discount" SET NOT NULL`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_codes" DROP COLUMN "discount_value"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ItemVideoAndVipPass1729072422409 implements MigrationInterface {
|
|
||||||
name = 'ItemVideoAndVipPass1729072422409';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD "video_url" character varying`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_categories" ADD "has_vip_pass" boolean NOT NULL DEFAULT false`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "vip_categories" DROP COLUMN "has_vip_pass"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "video_url"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class QueueTable1729151429165 implements MigrationInterface {
|
|
||||||
name = 'QueueTable1729151429165';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queue_orders" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying NOT NULL, "customer" character varying, "phone" character varying, "date" bigint NOT NULL, CONSTRAINT "PK_b139e4cc9ca3e709c152f820d2e" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queue_tickets" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying NOT NULL, "customer" character varying, "phone" character varying, "date" bigint NOT NULL, "order_id" uuid, CONSTRAINT "PK_1b903aa90bcc04136caa6540c55" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queue_items" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "qty" integer NOT NULL, "ticket_id" uuid, "item_id" uuid, CONSTRAINT "PK_2245e11ac3517494bacfe932773" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_tickets" ADD CONSTRAINT "FK_0e9823b8b7ca9523b3be73878e5" FOREIGN KEY ("order_id") REFERENCES "queue_orders"("id") ON DELETE SET NULL ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_items" ADD CONSTRAINT "FK_25352739034765f6917757df74b" FOREIGN KEY ("ticket_id") REFERENCES "queue_tickets"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_items" ADD CONSTRAINT "FK_ab15c053aeb4f739ebf533b61cd" FOREIGN KEY ("item_id") REFERENCES "items"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_items" DROP CONSTRAINT "FK_ab15c053aeb4f739ebf533b61cd"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_items" DROP CONSTRAINT "FK_25352739034765f6917757df74b"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_tickets" DROP CONSTRAINT "FK_0e9823b8b7ca9523b3be73878e5"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(`DROP TABLE "queue_items"`);
|
|
||||||
await queryRunner.query(`DROP TABLE "queue_tickets"`);
|
|
||||||
await queryRunner.query(`DROP TABLE "queue_orders"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class VideoUrlToJson1729248576381 implements MigrationInterface {
|
|
||||||
name = 'VideoUrlToJson1729248576381';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "video_url"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" ADD "video_url" json`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "video_url"`);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD "video_url" character varying`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`DROP TABLE "item_queues"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ItemQueues1729570177597 implements MigrationInterface {
|
|
||||||
name = 'ItemQueues1729570177597';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."item_queues_status_enum" AS ENUM('active', 'cancel', 'confirmed', 'draft', 'expired', 'inactive', 'partial refund', 'pending', 'proses refund', 'refunded', 'rejected', 'settled', 'waiting')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TYPE "public"."item_queues_item_type_enum" AS ENUM('tiket masuk', 'wahana', 'bundling', 'free gift', 'other')`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "item_queues" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "creator_id" character varying(36), "creator_name" character varying(125), "editor_id" character varying(36), "editor_name" character varying(125), "created_at" bigint NOT NULL, "updated_at" bigint NOT NULL, "status" "public"."item_queues_status_enum" NOT NULL DEFAULT 'draft', "name" character varying NOT NULL, "item_type" "public"."item_queues_item_type_enum" NOT NULL DEFAULT 'tiket masuk', CONSTRAINT "PK_e19adb0b99d995e8f10c189985f" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" ADD "item_queue_id" uuid`);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c" FOREIGN KEY ("item_queue_id") REFERENCES "item_queues"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" DROP CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(`ALTER TABLE "items" DROP COLUMN "item_queue_id"`);
|
|
||||||
await queryRunner.query(`DROP TABLE "item_queues"`);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."item_queues_item_type_enum"`);
|
|
||||||
await queryRunner.query(`DROP TYPE "public"."item_queues_status_enum"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ItemQueueOnDelete1729582398827 implements MigrationInterface {
|
|
||||||
name = 'ItemQueueOnDelete1729582398827';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" DROP CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c" FOREIGN KEY ("item_queue_id") REFERENCES "item_queues"("id") ON DELETE SET NULL ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" DROP CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "items" ADD CONSTRAINT "FK_2cbbeb03e176addcf60d65f7c9c" FOREIGN KEY ("item_queue_id") REFERENCES "item_queues"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddTransactionIdToQueueOrder1729653046392
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddTransactionIdToQueueOrder1729653046392';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_orders" ADD "transaction_id" character varying NOT NULL`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queue_orders" DROP COLUMN "transaction_id"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddQueueTable1729756969674 implements MigrationInterface {
|
|
||||||
name = 'AddQueueTable1729756969674';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queues" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "code" character varying NOT NULL, "status" character varying NOT NULL, "time" bigint NOT NULL, "call_time" bigint NOT NULL, "vip" boolean NOT NULL, "item_id" uuid NOT NULL, "qty" integer NOT NULL, CONSTRAINT "PK_d966f9eb39a9396658387071bb3" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD CONSTRAINT "FK_435954e9a0d9967f17e043d54b4" FOREIGN KEY ("item_id") REFERENCES "queue_items"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" DROP CONSTRAINT "FK_435954e9a0d9967f17e043d54b4"`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(`DROP TABLE "queues"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddQueueBaseModel1729838994129 implements MigrationInterface {
|
|
||||||
name = 'AddQueueBaseModel1729838994129';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "creator_id" character varying(36)`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "creator_name" character varying(125)`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "editor_id" character varying(36)`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "editor_name" character varying(125)`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "created_at" bigint NOT NULL`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "updated_at" bigint NOT NULL`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ALTER COLUMN "call_time" DROP NOT NULL`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "updated_at"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "created_at"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "editor_name"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "editor_id"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "creator_name"`);
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "creator_id"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddQueueBucket1730859187883 implements MigrationInterface {
|
|
||||||
name = 'AddQueueBucket1730859187883';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`CREATE TABLE "queue_bucket" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "queue_item_id" character varying NOT NULL, "date" bigint NOT NULL, "regular" integer NOT NULL, "vip" integer NOT NULL, CONSTRAINT "PK_cdd58b0d9e93e4be922da9d8bd6" PRIMARY KEY ("id"))`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`DROP TABLE "queue_bucket"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddTransactionAndItemRelation1731383726542
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddTransactionAndItemRelation1731383726542';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "item_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "item_id" uuid`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" DROP COLUMN "customer_category_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" ADD "customer_category_id" uuid`,
|
|
||||||
);
|
|
||||||
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD CONSTRAINT "FK_edb934ab033f847e3f7ed4fc0fc" FOREIGN KEY ("item_id") REFERENCES "items"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" ADD CONSTRAINT "FK_08dc8138714894a66e94820766d" FOREIGN KEY ("customer_category_id") REFERENCES "vip_categories"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" DROP CONSTRAINT "FK_08dc8138714894a66e94820766d"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP CONSTRAINT "FK_edb934ab033f847e3f7ed4fc0fc"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" DROP COLUMN "customer_category_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transactions" ADD "customer_category_id" character varying`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" DROP COLUMN "item_id"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "transaction_items" ADD "item_id" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddItemQueueToQueue1731498661938 implements MigrationInterface {
|
|
||||||
name = 'AddItemQueueToQueue1731498661938';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "item_queue_id" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "queues" DROP COLUMN "item_queue_id"`);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddInformationToItemQueue1731570311609
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddInformationToItemQueue1731570311609';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "information" character varying`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "information"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class ItemQueueAddTimeAndPeakLevel1733199330134
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'ItemQueueAddTimeAndPeakLevel1733199330134';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "max_peak_level" integer NOT NULL DEFAULT '100'`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "call_preparation" integer NOT NULL DEFAULT '5'`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "call_preparation"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "max_peak_level"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddNotificationConfigToItemQueue1734717058658
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddNotificationConfigToItemQueue1734717058658';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "use_notification" boolean NOT NULL DEFAULT true`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" ADD "requiring_notification" boolean NOT NULL DEFAULT false`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "requiring_notification"`,
|
|
||||||
);
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "item_queues" DROP COLUMN "use_notification"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
||||||
|
|
||||||
export class AddLastNotificationToQueue1734718462106
|
|
||||||
implements MigrationInterface
|
|
||||||
{
|
|
||||||
name = 'AddLastNotificationToQueue1734718462106';
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" ADD "last_notification" bigint NULL`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "queues" DROP COLUMN "last_notification"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,32 +9,14 @@ import { CqrsModule } from '@nestjs/cqrs';
|
||||||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
||||||
import { UserDataService } from 'src/modules/user-related/user/data/services/user-data.service';
|
import { UserDataService } from 'src/modules/user-related/user/data/services/user-data.service';
|
||||||
import { AuthAdminQueueController } from './infrastructure/auth-admin-queue.controller';
|
|
||||||
import { AuthAdminQueueOrchestrator } from './domain/auth-admin-queue.orchestrator';
|
|
||||||
import { LoginAdminQueueManager } from './domain/managers/admin-queue/login-admin-queue.manager';
|
|
||||||
import { LogoutAdminQueueManager } from './domain/managers/admin-queue/logout-admin-queue.manager';
|
|
||||||
import { UserLoginModel } from 'src/modules/user-related/user/data/models/user-login.model';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
TypeOrmModule.forFeature(
|
TypeOrmModule.forFeature([UserModel], CONNECTION_NAME.DEFAULT),
|
||||||
[UserModel, UserLoginModel],
|
|
||||||
CONNECTION_NAME.DEFAULT,
|
|
||||||
),
|
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
],
|
],
|
||||||
controllers: [AuthController, AuthAdminQueueController],
|
controllers: [AuthController],
|
||||||
providers: [
|
providers: [LoginManager, LogoutManager, UserDataService, AuthOrchestrator],
|
||||||
LoginManager,
|
|
||||||
LogoutManager,
|
|
||||||
UserDataService,
|
|
||||||
AuthOrchestrator,
|
|
||||||
|
|
||||||
// ADMIN QUEUE
|
|
||||||
AuthAdminQueueOrchestrator,
|
|
||||||
LoginAdminQueueManager,
|
|
||||||
LogoutAdminQueueManager,
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
export class AuthModule {}
|
export class AuthModule {}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { LoginAdminQueueManager } from './managers/admin-queue/login-admin-queue.manager';
|
|
||||||
import { LogoutAdminQueueManager } from './managers/admin-queue/logout-admin-queue.manager';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
import { UserDataService } from 'src/modules/user-related/user/data/services/user-data.service';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AuthAdminQueueOrchestrator {
|
|
||||||
constructor(
|
|
||||||
private loginManager: LoginAdminQueueManager,
|
|
||||||
private logoutManager: LogoutAdminQueueManager,
|
|
||||||
private serviceData: UserDataService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async login(data): Promise<any> {
|
|
||||||
this.loginManager.setData(data);
|
|
||||||
this.loginManager.setService(this.serviceData, TABLE_NAME.USER);
|
|
||||||
await this.loginManager.execute();
|
|
||||||
return this.loginManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async logout(userId?: string): Promise<any> {
|
|
||||||
if (userId) this.logoutManager.setData({ user_id: userId });
|
|
||||||
this.logoutManager.setService(this.serviceData, TABLE_NAME.USER);
|
|
||||||
await this.logoutManager.execute();
|
|
||||||
return this.logoutManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async forceLogout(token): Promise<any> {
|
|
||||||
return this.serviceData.forceLogout(token);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,8 +24,4 @@ export class AuthOrchestrator {
|
||||||
await this.logoutManager.execute();
|
await this.logoutManager.execute();
|
||||||
return this.logoutManager.getResult();
|
return this.logoutManager.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
async forceLogout(token): Promise<any> {
|
|
||||||
return this.serviceData.forceLogout(token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,168 +0,0 @@
|
||||||
import {
|
|
||||||
HttpStatus,
|
|
||||||
Inject,
|
|
||||||
Injectable,
|
|
||||||
Logger,
|
|
||||||
UnauthorizedException,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { validatePassword } from 'src/core/helpers/password/bcrypt.helpers';
|
|
||||||
import { BaseCustomManager } from 'src/core/modules/domain/usecase/managers/base-custom.manager';
|
|
||||||
import { SessionService } from 'src/core/sessions';
|
|
||||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
|
||||||
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
|
|
||||||
import { In } from 'typeorm';
|
|
||||||
import { UserRole } from 'src/modules/user-related/user/constants';
|
|
||||||
import { AppSource, LogUserType } from 'src/core/helpers/constant';
|
|
||||||
import { LogUserLoginEvent } from 'src/modules/configuration/log/domain/entities/log-user-login.event';
|
|
||||||
import { UserLoginEntity } from 'src/modules/user-related/user/domain/entities/user-login.entity';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class LoginAdminQueueManager extends BaseCustomManager<UserEntity> {
|
|
||||||
@Inject()
|
|
||||||
protected session: SessionService;
|
|
||||||
protected token;
|
|
||||||
protected userLogin;
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async process(): Promise<void> {
|
|
||||||
const itemLogin = await this.dataService.getLoginUserByItem(
|
|
||||||
this.data.item_id,
|
|
||||||
);
|
|
||||||
|
|
||||||
// get user active by username
|
|
||||||
this.userLogin = await this.dataService.getOneByOptions({
|
|
||||||
where: {
|
|
||||||
username: this.data.username,
|
|
||||||
status: STATUS.ACTIVE,
|
|
||||||
role: In([UserRole.QUEUE_ADMIN, UserRole.SUPERADMIN]),
|
|
||||||
},
|
|
||||||
relations: ['user_login'],
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!this.userLogin) this.throwError();
|
|
||||||
|
|
||||||
// validasi password
|
|
||||||
const valid = await validatePassword(
|
|
||||||
this.data.password,
|
|
||||||
this.userLogin?.password,
|
|
||||||
);
|
|
||||||
if (!valid) this.throwError();
|
|
||||||
|
|
||||||
const userLoginItem = await this.dataService.getOneByOptions({
|
|
||||||
where: {
|
|
||||||
id: itemLogin?.user_id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const hasLoginAsQueue = this.userLogin?.user_login?.find(
|
|
||||||
(item) => item.source === AppSource.QUEUE_ADMIN,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (hasLoginAsQueue && hasLoginAsQueue?.item_id !== this.data.item_id) {
|
|
||||||
throw new UnauthorizedException({
|
|
||||||
statusCode: HttpStatus.UNAUTHORIZED,
|
|
||||||
message: `Akun anda sudah login di item "${hasLoginAsQueue?.item_name}"`,
|
|
||||||
error: 'Unauthorized',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// else if (itemLogin && itemLogin.user_id !== this.userLogin.id) {
|
|
||||||
// throw new UnauthorizedException({
|
|
||||||
// statusCode: HttpStatus.UNAUTHORIZED,
|
|
||||||
// message: `"${userLoginItem.name}" masih login sebagai admin antrian `,
|
|
||||||
// error: 'Unauthorized',
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// * Disini untuk isi token
|
|
||||||
const tokenData = {
|
|
||||||
id: this.userLogin.id,
|
|
||||||
name: this.userLogin.name,
|
|
||||||
username: this.userLogin.username,
|
|
||||||
role: this.userLogin.role,
|
|
||||||
user_privilege_id: this.userLogin.user_privilege_id,
|
|
||||||
item_id: this.data.item_id,
|
|
||||||
item_name: this.data.item_name,
|
|
||||||
source: AppSource.QUEUE_ADMIN,
|
|
||||||
};
|
|
||||||
|
|
||||||
Logger.debug('Sign Token Admin Queue', 'LoginAdminQueueManager');
|
|
||||||
this.token = this.session.createAccessToken(tokenData);
|
|
||||||
|
|
||||||
Logger.debug('Save Login Token', 'LoginManager');
|
|
||||||
const userLoginData: UserLoginEntity = {
|
|
||||||
user_id: this.userLogin.id,
|
|
||||||
login_token: this.token,
|
|
||||||
login_date: new Date().getTime(),
|
|
||||||
source: AppSource.QUEUE_ADMIN,
|
|
||||||
role: this.userLogin.role,
|
|
||||||
item_id: this.data.item_id,
|
|
||||||
item_name: this.data.item_name,
|
|
||||||
};
|
|
||||||
if (hasLoginAsQueue?.item_id === this.data.item_id) {
|
|
||||||
Object.assign(userLoginData, { id: hasLoginAsQueue.id });
|
|
||||||
}
|
|
||||||
// Update refresh token
|
|
||||||
await this.dataService.saveUserLogin(userLoginData);
|
|
||||||
|
|
||||||
await this.publishEvents();
|
|
||||||
|
|
||||||
Logger.debug('Process Login Admin Queue Done', 'LoginAdminQueueManager');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult() {
|
|
||||||
return {
|
|
||||||
id: this.userLogin.id,
|
|
||||||
name: this.userLogin.name,
|
|
||||||
username: this.userLogin.username,
|
|
||||||
role: this.userLogin.role,
|
|
||||||
token: this.token,
|
|
||||||
item_id: this.data.item_id,
|
|
||||||
item_name: this.data.item_name,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return UserModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
topic: LogUserLoginEvent,
|
|
||||||
data: {
|
|
||||||
type: LogUserType.login,
|
|
||||||
role: this.userLogin.role,
|
|
||||||
user_id: this.userLogin.id,
|
|
||||||
username: this.userLogin.username,
|
|
||||||
created_at: new Date().getTime(),
|
|
||||||
item_id: this.data.item_id,
|
|
||||||
item_name: this.data.item_name,
|
|
||||||
source: AppSource.QUEUE_ADMIN,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// !throw errornya akan sama, untuk security
|
|
||||||
throwError() {
|
|
||||||
throw new UnauthorizedException({
|
|
||||||
statusCode: HttpStatus.UNAUTHORIZED,
|
|
||||||
message: `Gagal! username atau password tidak sesuai`,
|
|
||||||
error: 'Unauthorized',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
import { AppSource, LogUserType } from 'src/core/helpers/constant';
|
|
||||||
import { BaseCustomManager } from 'src/core/modules/domain/usecase/managers/base-custom.manager';
|
|
||||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { LogUserLoginEvent } from 'src/modules/configuration/log/domain/entities/log-user-login.event';
|
|
||||||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
|
||||||
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
|
|
||||||
|
|
||||||
export class LogoutAdminQueueManager extends BaseCustomManager<UserEntity> {
|
|
||||||
protected userLogin;
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async process(): Promise<void> {
|
|
||||||
const id = this.data?.user_id ?? this.user.id;
|
|
||||||
|
|
||||||
this.userLogin = await this.dataService.getOneByOptions({
|
|
||||||
where: { id },
|
|
||||||
});
|
|
||||||
|
|
||||||
await this.dataService.removeUserLogin({
|
|
||||||
user_id: id,
|
|
||||||
source: AppSource.QUEUE_ADMIN,
|
|
||||||
});
|
|
||||||
|
|
||||||
await this.publishEvents();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult() {
|
|
||||||
return `Success Logout User`;
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return UserModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
topic: LogUserLoginEvent,
|
|
||||||
data: {
|
|
||||||
type: LogUserType.logout,
|
|
||||||
role: this.userLogin.role,
|
|
||||||
user_id: this.userLogin.id,
|
|
||||||
username: this.userLogin.name,
|
|
||||||
created_at: new Date().getTime(),
|
|
||||||
source: AppSource.QUEUE_ADMIN,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,11 +12,7 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
||||||
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
|
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
|
||||||
import { Not } from 'typeorm';
|
import { UserLoginEvent } from '../entities/login.event';
|
||||||
import { UserRole } from 'src/modules/user-related/user/constants';
|
|
||||||
import { AppSource, LogUserType } from 'src/core/helpers/constant';
|
|
||||||
import { LogUserLoginEvent } from 'src/modules/configuration/log/domain/entities/log-user-login.event';
|
|
||||||
import { UserLoginEntity } from 'src/modules/user-related/user/domain/entities/user-login.entity';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LoginManager extends BaseCustomManager<UserEntity> {
|
export class LoginManager extends BaseCustomManager<UserEntity> {
|
||||||
|
@ -40,7 +36,6 @@ export class LoginManager extends BaseCustomManager<UserEntity> {
|
||||||
where: {
|
where: {
|
||||||
username: this.data.username,
|
username: this.data.username,
|
||||||
status: STATUS.ACTIVE,
|
status: STATUS.ACTIVE,
|
||||||
role: Not(UserRole.QUEUE_ADMIN),
|
|
||||||
},
|
},
|
||||||
relations: [
|
relations: [
|
||||||
'user_privilege',
|
'user_privilege',
|
||||||
|
@ -63,27 +58,25 @@ export class LoginManager extends BaseCustomManager<UserEntity> {
|
||||||
username: this.userLogin.username,
|
username: this.userLogin.username,
|
||||||
role: this.userLogin.role,
|
role: this.userLogin.role,
|
||||||
user_privilege_id: this.userLogin.user_privilege_id,
|
user_privilege_id: this.userLogin.user_privilege_id,
|
||||||
source: AppSource.POS_ADMIN,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.debug('Sign Token', 'LoginManager');
|
Logger.debug('Sign Token', 'LoginManager');
|
||||||
this.token = this.session.createAccessToken(tokenData);
|
this.token = this.session.createAccessToken(tokenData);
|
||||||
|
|
||||||
Logger.debug('Save Login Token', 'LoginManager');
|
Logger.debug('refreshToken', 'LoginManager');
|
||||||
const userLoginData: UserLoginEntity = {
|
const refreshToken = this.session.createAccessToken(tokenData);
|
||||||
user_id: this.userLogin.id,
|
|
||||||
login_token: this.token,
|
|
||||||
login_date: new Date().getTime(),
|
|
||||||
source: AppSource.POS_ADMIN,
|
|
||||||
role: this.userLogin.role,
|
|
||||||
item_id: null,
|
|
||||||
item_name: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
Logger.debug('Update Refresh Token', 'LoginManager');
|
||||||
// Update refresh token
|
// Update refresh token
|
||||||
await this.dataService.saveUserLogin(userLoginData);
|
await this.dataService.update(
|
||||||
|
this.queryRunner,
|
||||||
|
this.entityTarget,
|
||||||
|
{ id: this.userLogin.id },
|
||||||
|
{
|
||||||
|
refresh_token: refreshToken,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
await this.publishEvents();
|
|
||||||
Logger.debug('Process Login Done', 'LoginManager');
|
Logger.debug('Process Login Done', 'LoginManager');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -126,14 +119,11 @@ export class LoginManager extends BaseCustomManager<UserEntity> {
|
||||||
get eventTopics(): EventTopics[] {
|
get eventTopics(): EventTopics[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
topic: LogUserLoginEvent,
|
topic: UserLoginEvent,
|
||||||
data: {
|
data: {
|
||||||
type: LogUserType.login,
|
id: this.userLogin.id,
|
||||||
role: this.userLogin.role,
|
type: 'login',
|
||||||
user_id: this.userLogin.id,
|
timestamp: new Date().getTime(),
|
||||||
username: this.userLogin.username,
|
|
||||||
created_at: new Date().getTime(),
|
|
||||||
source: AppSource.POS_ADMIN,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -2,8 +2,7 @@ import { BaseCustomManager } from 'src/core/modules/domain/usecase/managers/base
|
||||||
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
import { EventTopics } from 'src/core/strings/constants/interface.constants';
|
||||||
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
import { UserModel } from 'src/modules/user-related/user/data/models/user.model';
|
||||||
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
|
import { UserEntity } from 'src/modules/user-related/user/domain/entities/user.entity';
|
||||||
import { AppSource, LogUserType } from 'src/core/helpers/constant';
|
import { UserLogoutEvent } from '../entities/logout.event';
|
||||||
import { LogUserLoginEvent } from 'src/modules/configuration/log/domain/entities/log-user-login.event';
|
|
||||||
|
|
||||||
export class LogoutManager extends BaseCustomManager<UserEntity> {
|
export class LogoutManager extends BaseCustomManager<UserEntity> {
|
||||||
async validateProcess(): Promise<void> {
|
async validateProcess(): Promise<void> {
|
||||||
|
@ -15,12 +14,15 @@ export class LogoutManager extends BaseCustomManager<UserEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async process(): Promise<void> {
|
async process(): Promise<void> {
|
||||||
await this.dataService.removeUserLogin({
|
await this.dataService.update(
|
||||||
user_id: this.user.id,
|
this.queryRunner,
|
||||||
login_token: this.userProvider.token,
|
this.entityTarget,
|
||||||
source: AppSource.POS_ADMIN,
|
{ id: this.user.id },
|
||||||
});
|
{
|
||||||
await this.publishEvents();
|
refresh_token: null,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,14 +41,11 @@ export class LogoutManager extends BaseCustomManager<UserEntity> {
|
||||||
get eventTopics(): EventTopics[] {
|
get eventTopics(): EventTopics[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
topic: LogUserLoginEvent,
|
topic: UserLogoutEvent,
|
||||||
data: {
|
data: {
|
||||||
type: LogUserType.logout,
|
id: this.user.id,
|
||||||
role: this.user.role,
|
type: 'logout',
|
||||||
user_id: this.user.id,
|
timestamp: new Date().getTime(),
|
||||||
username: this.user.name,
|
|
||||||
created_at: new Date().getTime(),
|
|
||||||
source: AppSource.POS_ADMIN,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
import { Body, Controller, Delete, Param, Post, Put } from '@nestjs/common';
|
|
||||||
import { ExcludePrivilege, Public } from 'src/core/guards';
|
|
||||||
import { ApiBearerAuth } from '@nestjs/swagger';
|
|
||||||
import { ForceLogoutDto, LoginQueueDto } from './dto/login.dto';
|
|
||||||
import { AuthAdminQueueOrchestrator } from '../domain/auth-admin-queue.orchestrator';
|
|
||||||
|
|
||||||
@Controller('v1/auth/queue')
|
|
||||||
export class AuthAdminQueueController {
|
|
||||||
constructor(private orchestrator: AuthAdminQueueOrchestrator) {}
|
|
||||||
|
|
||||||
@Post()
|
|
||||||
@Public(true)
|
|
||||||
async login(@Body() body: LoginQueueDto) {
|
|
||||||
return await this.orchestrator.login(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiBearerAuth('JWT')
|
|
||||||
@Public(false)
|
|
||||||
@ExcludePrivilege()
|
|
||||||
@Delete('logout')
|
|
||||||
async logout() {
|
|
||||||
return await this.orchestrator.logout();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Put(':user_id/logout')
|
|
||||||
async logoutQueueAdmin(@Param('user_id') userId: string) {
|
|
||||||
return await this.orchestrator.logout(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post('force-logout')
|
|
||||||
@Public(true)
|
|
||||||
async forceLogout(@Body() body: ForceLogoutDto) {
|
|
||||||
return await this.orchestrator.forceLogout(body.token);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Body, Controller, Delete, Post } from '@nestjs/common';
|
import { Body, Controller, Delete, Post } from '@nestjs/common';
|
||||||
import { ExcludePrivilege, Public } from 'src/core/guards';
|
import { Public } from 'src/core/guards';
|
||||||
import { AuthOrchestrator } from '../domain/auth.orchestrator';
|
import { AuthOrchestrator } from '../domain/auth.orchestrator';
|
||||||
import { ApiBearerAuth } from '@nestjs/swagger';
|
import { ApiBearerAuth } from '@nestjs/swagger';
|
||||||
import { ForceLogoutDto, LoginDto } from './dto/login.dto';
|
import { LoginDto } from './dto/login.dto';
|
||||||
|
|
||||||
@Controller('v1/auth')
|
@Controller('v1/auth')
|
||||||
export class AuthController {
|
export class AuthController {
|
||||||
|
@ -16,15 +16,8 @@ export class AuthController {
|
||||||
|
|
||||||
@ApiBearerAuth('JWT')
|
@ApiBearerAuth('JWT')
|
||||||
@Public(false)
|
@Public(false)
|
||||||
@ExcludePrivilege()
|
|
||||||
@Delete('logout')
|
@Delete('logout')
|
||||||
async logout() {
|
async logoout() {
|
||||||
return await this.orchestrator.logout();
|
return await this.orchestrator.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('force-logout')
|
|
||||||
@Public(true)
|
|
||||||
async forceLogout(@Body() body: ForceLogoutDto) {
|
|
||||||
return await this.orchestrator.forceLogout(body.token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,27 +11,3 @@ export class LoginDto implements LoginRequest {
|
||||||
@IsString()
|
@IsString()
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LoginQueueDto implements LoginRequest {
|
|
||||||
@ApiProperty({ name: 'username', required: true, default: 'superadmin' })
|
|
||||||
@IsString()
|
|
||||||
username: string;
|
|
||||||
|
|
||||||
@ApiProperty({ name: 'password', required: true, default: 'Eigen123!' })
|
|
||||||
@IsString()
|
|
||||||
password: string;
|
|
||||||
|
|
||||||
@ApiProperty({ name: 'item_id', required: true, default: 'string' })
|
|
||||||
@IsString()
|
|
||||||
item_id: string;
|
|
||||||
|
|
||||||
@ApiProperty({ name: 'item_name', required: true, default: 'string' })
|
|
||||||
@IsString()
|
|
||||||
item_name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class ForceLogoutDto {
|
|
||||||
@ApiProperty({ required: true })
|
|
||||||
@IsString()
|
|
||||||
token: string;
|
|
||||||
}
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ import {
|
||||||
import { SeasonPeriodDataService } from 'src/modules/season-related/season-period/data/services/season-period-data.service';
|
import { SeasonPeriodDataService } from 'src/modules/season-related/season-period/data/services/season-period-data.service';
|
||||||
import { SeasonPeriodModel } from 'src/modules/season-related/season-period/data/models/season-period.model';
|
import { SeasonPeriodModel } from 'src/modules/season-related/season-period/data/models/season-period.model';
|
||||||
import { TransactionDemographyModel } from 'src/modules/transaction/transaction/data/models/transaction-demography.model';
|
import { TransactionDemographyModel } from 'src/modules/transaction/transaction/data/models/transaction-demography.model';
|
||||||
import { UserLoginModel } from 'src/modules/user-related/user/data/models/user-login.model';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -62,7 +61,6 @@ import { UserLoginModel } from 'src/modules/user-related/user/data/models/user-l
|
||||||
ItemRateModel,
|
ItemRateModel,
|
||||||
SeasonPeriodModel,
|
SeasonPeriodModel,
|
||||||
UserModel,
|
UserModel,
|
||||||
UserLoginModel,
|
|
||||||
TransactionModel,
|
TransactionModel,
|
||||||
TransactionTaxModel,
|
TransactionTaxModel,
|
||||||
TransactionItemModel,
|
TransactionItemModel,
|
||||||
|
|
|
@ -19,7 +19,6 @@ export class CouchService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModuleInit() {
|
async onModuleInit() {
|
||||||
// return;
|
|
||||||
const nano = this.nanoInstance;
|
const nano = this.nanoInstance;
|
||||||
for (const database of DatabaseListen) {
|
for (const database of DatabaseListen) {
|
||||||
const db = nano.db.use(database);
|
const db = nano.db.use(database);
|
||||||
|
@ -96,41 +95,4 @@ export class CouchService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnixTimestampLast7Days() {
|
|
||||||
const date = new Date();
|
|
||||||
date.setDate(date.getDate() - 4);
|
|
||||||
date.setHours(0, 0, 0, 0);
|
|
||||||
return date.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async clearTransactions() {
|
|
||||||
const nano = this.nanoInstance;
|
|
||||||
const transaction = nano.use('transaction');
|
|
||||||
|
|
||||||
const expiredDate = this.getUnixTimestampLast7Days();
|
|
||||||
|
|
||||||
const selectorPayment = {
|
|
||||||
created_at: {
|
|
||||||
$lt: expiredDate,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const transactions = await transaction.find({
|
|
||||||
selector: selectorPayment,
|
|
||||||
fields: ['_id', '_rev'],
|
|
||||||
limit: 100000,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { docs } = transactions;
|
|
||||||
console.log(docs.length);
|
|
||||||
const deletedDocs = {
|
|
||||||
docs: docs.map((doc) => ({
|
|
||||||
_id: doc._id,
|
|
||||||
_rev: doc._rev,
|
|
||||||
_deleted: true,
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
await transaction.bulk(deletedDocs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,9 @@ export class ChangeStatusBookingHandler
|
||||||
},
|
},
|
||||||
relations: ['items', 'items.bundling_items'],
|
relations: ['items', 'items.bundling_items'],
|
||||||
});
|
});
|
||||||
|
console.log('change status', { dataID, couchData, booking });
|
||||||
mappingTransaction(booking);
|
mappingTransaction(booking);
|
||||||
|
console.log('after mapping');
|
||||||
|
|
||||||
if (!couchData) {
|
if (!couchData) {
|
||||||
console.log('save data to couch');
|
console.log('save data to couch');
|
||||||
|
|
|
@ -5,17 +5,13 @@ import { Public } from 'src/core/guards';
|
||||||
import * as Nano from 'nano';
|
import * as Nano from 'nano';
|
||||||
import { CreateUserPrivilegeDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/create-user-privilege.dto';
|
import { CreateUserPrivilegeDto } from 'src/modules/user-related/user-privilege/infrastructure/dto/create-user-privilege.dto';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { CouchService } from '../data/services/couch.service';
|
|
||||||
|
|
||||||
@ApiTags(`couch`)
|
@ApiTags(`couch`)
|
||||||
@Controller('v1/couch')
|
@Controller('v1/couch')
|
||||||
@Public()
|
@Public()
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CouchDataController {
|
export class CouchDataController {
|
||||||
constructor(
|
constructor(private configService: ConfigService) {}
|
||||||
private configService: ConfigService,
|
|
||||||
private couchService: CouchService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
get nanoInstance() {
|
get nanoInstance() {
|
||||||
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
|
const couchConfiguration = this.configService.get<string>('COUCHDB_CONFIG');
|
||||||
|
@ -68,11 +64,4 @@ export class CouchDataController {
|
||||||
// return people.get();
|
// return people.get();
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Public(true)
|
|
||||||
@Get('clear-transactions')
|
|
||||||
async clearTransactions(): Promise<string> {
|
|
||||||
await this.couchService.clearTransactions();
|
|
||||||
return 'OK';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
import { UserEntity } from '../../../../user-related/user/domain/entities/user.entity';
|
|
||||||
import { Column, Entity } from 'typeorm';
|
|
||||||
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
|
|
||||||
import { LogUserLoginEntity } from '../../domain/entities/log-user-login.entity';
|
|
||||||
import { UserRole } from '../../../../user-related/user/constants';
|
|
||||||
import { AppSource, LogUserType } from 'src/core/helpers/constant';
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.LOG_USER_LOGIN)
|
|
||||||
export class LogUserLoginModel
|
|
||||||
extends BaseCoreModel<UserEntity>
|
|
||||||
implements LogUserLoginEntity
|
|
||||||
{
|
|
||||||
@Column({ type: 'enum', enum: LogUserType, nullable: true })
|
|
||||||
type: LogUserType;
|
|
||||||
|
|
||||||
@Column({ type: 'enum', enum: UserRole, nullable: true })
|
|
||||||
role: UserRole;
|
|
||||||
|
|
||||||
@Column({ type: 'uuid', nullable: true })
|
|
||||||
user_id: string;
|
|
||||||
|
|
||||||
@Column({ type: 'uuid', nullable: true })
|
|
||||||
item_id: string;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', nullable: true })
|
|
||||||
item_name: string;
|
|
||||||
|
|
||||||
@Column({ type: 'varchar', nullable: true })
|
|
||||||
username: string;
|
|
||||||
|
|
||||||
@Column({ type: 'bigint', nullable: true })
|
|
||||||
created_at: number;
|
|
||||||
|
|
||||||
@Column({ type: 'enum', enum: AppSource, nullable: true })
|
|
||||||
source: AppSource;
|
|
||||||
}
|
|
|
@ -14,9 +14,6 @@ export class PosLogModel
|
||||||
@Column('bigint', { name: 'pos_number', nullable: true })
|
@Column('bigint', { name: 'pos_number', nullable: true })
|
||||||
pos_number: number;
|
pos_number: number;
|
||||||
|
|
||||||
@Column('varchar', { name: 'pos_name', nullable: true })
|
|
||||||
pos_name: string;
|
|
||||||
|
|
||||||
@Column('decimal', { name: 'total_balance', nullable: true })
|
@Column('decimal', { name: 'total_balance', nullable: true })
|
||||||
total_balance: number;
|
total_balance: number;
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { LogUserLoginEntity } from '../../domain/entities/log-user-login.entity';
|
|
||||||
import { LogUserLoginModel } from '../models/log-user-login.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class LogUserLoginService extends BaseDataService<LogUserLoginEntity> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(LogUserLoginModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<LogUserLoginModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
async saveData(data) {
|
|
||||||
this.repo.save(data);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
import { LogUserType } from 'src/core/helpers/constant';
|
|
||||||
import { UserRole } from '../../../../user-related/user/constants';
|
|
||||||
import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entity';
|
|
||||||
|
|
||||||
export interface LogUserLoginEntity extends BaseCoreEntity {
|
|
||||||
type: LogUserType;
|
|
||||||
role: UserRole;
|
|
||||||
user_id: string;
|
|
||||||
item_id: string;
|
|
||||||
item_name: string;
|
|
||||||
username: string;
|
|
||||||
created_at: number;
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
import { IEvent } from 'src/core/strings/constants/interface.constants';
|
|
||||||
|
|
||||||
export class LogUserLoginEvent {
|
|
||||||
constructor(public readonly data: IEvent) {}
|
|
||||||
}
|
|
|
@ -3,7 +3,6 @@ import { BaseCoreEntity } from 'src/core/modules/domain/entities/base-core.entit
|
||||||
export interface PosLogEntity extends BaseCoreEntity {
|
export interface PosLogEntity extends BaseCoreEntity {
|
||||||
type: PosLogType;
|
type: PosLogType;
|
||||||
pos_number: number;
|
pos_number: number;
|
||||||
pos_name: string;
|
|
||||||
total_balance: number;
|
total_balance: number;
|
||||||
created_at: number;
|
created_at: number;
|
||||||
creator_name: string;
|
creator_name: string;
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { EventsHandler, IEventHandler } from '@nestjs/cqrs';
|
|
||||||
|
|
||||||
import { LogUserLoginEvent } from '../entities/log-user-login.event';
|
|
||||||
import { LogUserLoginService } from '../../data/services/log-user-login.service';
|
|
||||||
|
|
||||||
@EventsHandler(LogUserLoginEvent)
|
|
||||||
export class LogUserLoginHandler implements IEventHandler<LogUserLoginEvent> {
|
|
||||||
constructor(private service: LogUserLoginService) {}
|
|
||||||
|
|
||||||
async handle(event: LogUserLoginEvent) {
|
|
||||||
const data = event.data.data;
|
|
||||||
await this.service.saveData(data);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,7 +26,6 @@ export class RecordPosLogHandler implements IEventHandler<ChangeDocEvent> {
|
||||||
type: PosLogType[data.type],
|
type: PosLogType[data.type],
|
||||||
total_balance: data.withdrawal_cash ?? data.opening_cash_balance,
|
total_balance: data.withdrawal_cash ?? data.opening_cash_balance,
|
||||||
pos_number: data.pos_number,
|
pos_number: data.pos_number,
|
||||||
pos_name: data.pos_name,
|
|
||||||
creator_id: data.pos_admin?.id,
|
creator_id: data.pos_admin?.id,
|
||||||
creator_name: data.pos_admin?.name ?? data.pos_admin?.username,
|
creator_name: data.pos_admin?.name ?? data.pos_admin?.username,
|
||||||
drawn_by_id: data.withdraw_user?.id,
|
drawn_by_id: data.withdraw_user?.id,
|
||||||
|
|
|
@ -12,15 +12,12 @@ import { LogService } from './data/services/log.service';
|
||||||
import { PosLogModel } from './data/models/pos-log.model';
|
import { PosLogModel } from './data/models/pos-log.model';
|
||||||
import { PosLogService } from './data/services/pos-log.service';
|
import { PosLogService } from './data/services/pos-log.service';
|
||||||
import { RecordPosLogHandler } from './domain/handlers/pos-log.handler';
|
import { RecordPosLogHandler } from './domain/handlers/pos-log.handler';
|
||||||
import { LogUserLoginModel } from './data/models/log-user-login.model';
|
|
||||||
import { LogUserLoginService } from './data/services/log-user-login.service';
|
|
||||||
import { LogUserLoginHandler } from './domain/handlers/log-user-login.handler';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
ConfigModule.forRoot(),
|
ConfigModule.forRoot(),
|
||||||
TypeOrmModule.forFeature(
|
TypeOrmModule.forFeature(
|
||||||
[LogModel, ErrorLogModel, PosLogModel, LogUserLoginModel],
|
[LogModel, ErrorLogModel, PosLogModel],
|
||||||
CONNECTION_NAME.DEFAULT,
|
CONNECTION_NAME.DEFAULT,
|
||||||
),
|
),
|
||||||
CqrsModule,
|
CqrsModule,
|
||||||
|
@ -30,12 +27,10 @@ import { LogUserLoginHandler } from './domain/handlers/log-user-login.handler';
|
||||||
RecordLogHandler,
|
RecordLogHandler,
|
||||||
RecordPosLogHandler,
|
RecordPosLogHandler,
|
||||||
RecordErrorLogHandler,
|
RecordErrorLogHandler,
|
||||||
LogUserLoginHandler,
|
|
||||||
|
|
||||||
LogService,
|
LogService,
|
||||||
PosLogService,
|
PosLogService,
|
||||||
ErrorLogService,
|
ErrorLogService,
|
||||||
LogUserLoginService,
|
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class LogModule {}
|
export class LogModule {}
|
||||||
|
|
|
@ -40,13 +40,11 @@ export class SupersetService {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const cookie = response.headers['set-cookie'];
|
return { loginToken, csrfToken: response.data.result };
|
||||||
|
|
||||||
return { loginToken, csrfToken: response.data.result, cookie };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGuestToken(uuid: string) {
|
async getGuestToken(uuid: string) {
|
||||||
const { loginToken, csrfToken, cookie } = await this.getCSRFToken();
|
const { loginToken, csrfToken } = await this.getCSRFToken();
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
resources: [{ type: 'dashboard', id: uuid }],
|
resources: [{ type: 'dashboard', id: uuid }],
|
||||||
|
@ -54,14 +52,11 @@ export class SupersetService {
|
||||||
user: { username: 'pos_embed', first_name: 'pos', last_name: 'embed' },
|
user: { username: 'pos_embed', first_name: 'pos', last_name: 'embed' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const [requestCookie] = cookie[0].split(';');
|
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
Authorization: `Bearer ${loginToken}`,
|
|
||||||
Cookie: requestCookie,
|
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: `Bearer ${loginToken}`,
|
||||||
'X-CSRFToken': `${csrfToken}`,
|
'X-CSRFToken': `${csrfToken}`,
|
||||||
'Access-Control-Allow-Credentials': true,
|
Referer: `${this.supersetURL}/v1/security/guest_token/`,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await firstValueFrom(
|
const response = await firstValueFrom(
|
||||||
|
|
|
@ -3,9 +3,3 @@ export interface GateScanEntity {
|
||||||
type: string;
|
type: string;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GateLogEntity {
|
|
||||||
gate_id: string;
|
|
||||||
code: string;
|
|
||||||
error: any;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { IsNotEmpty, IsString } from 'class-validator';
|
|
||||||
import { GateLogEntity } from '../../domain/entity/gate-request.entity';
|
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
|
|
||||||
export class GateLogDto implements GateLogEntity {
|
|
||||||
@ApiProperty({
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
})
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
|
||||||
gate_id: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
})
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
|
||||||
code: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
required: false,
|
|
||||||
})
|
|
||||||
error: any;
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
GateResponseEntity,
|
GateResponseEntity,
|
||||||
} from '../domain/entity/gate-response.entity';
|
} from '../domain/entity/gate-response.entity';
|
||||||
import { Gate } from 'src/core/response';
|
import { Gate } from 'src/core/response';
|
||||||
import { GateLogDto } from './dto/logs.dto';
|
|
||||||
|
|
||||||
const masterGates = [
|
const masterGates = [
|
||||||
'319b6d3e-b661-4d19-8695-0dd6fb76465e',
|
'319b6d3e-b661-4d19-8695-0dd6fb76465e',
|
||||||
|
@ -73,13 +72,6 @@ export class GateController {
|
||||||
return responseValue;
|
return responseValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('logs')
|
|
||||||
async logs(@Body() data: GateLogDto): Promise<GateResponseEntity> {
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
return { code: 1, message: 'success' };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get(':id/master')
|
@Get(':id/master')
|
||||||
async detail(@Param('id') id: string): Promise<GateMasterEntity> {
|
async detail(@Param('id') id: string): Promise<GateMasterEntity> {
|
||||||
if (id == '1') return { codes: masterGates };
|
if (id == '1') return { codes: masterGates };
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
export enum ItemType {
|
|
||||||
TIKET_MASUK = 'tiket masuk',
|
|
||||||
WAHANA = 'wahana',
|
|
||||||
BUNDLING = 'bundling',
|
|
||||||
FREE_GIFT = 'free gift',
|
|
||||||
OTHER = 'other',
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
|
|
||||||
import { Column, Entity, OneToMany } from 'typeorm';
|
|
||||||
import { BaseStatusModel } from 'src/core/modules/data/model/base-status.model';
|
|
||||||
import { ItemType } from '../../constants';
|
|
||||||
import { ItemModel } from 'src/modules/item-related/item/data/models/item.model';
|
|
||||||
|
|
||||||
@Entity(TABLE_NAME.ITEM_QUEUE)
|
|
||||||
export class ItemQueueModel
|
|
||||||
extends BaseStatusModel<ItemQueueEntity>
|
|
||||||
implements ItemQueueEntity
|
|
||||||
{
|
|
||||||
@Column('int', { default: 100 })
|
|
||||||
max_peak_level: number;
|
|
||||||
|
|
||||||
@Column('int', { default: 5 })
|
|
||||||
call_preparation: number;
|
|
||||||
|
|
||||||
@Column('varchar', { name: 'name' })
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@Column('varchar', { name: 'information', nullable: true })
|
|
||||||
information: string;
|
|
||||||
|
|
||||||
@Column('enum', {
|
|
||||||
name: 'item_type',
|
|
||||||
enum: ItemType,
|
|
||||||
default: ItemType.TIKET_MASUK,
|
|
||||||
})
|
|
||||||
item_type: ItemType;
|
|
||||||
|
|
||||||
@OneToMany(() => ItemModel, (model) => model.item_queue, {
|
|
||||||
onUpdate: 'CASCADE',
|
|
||||||
})
|
|
||||||
items: ItemModel[];
|
|
||||||
|
|
||||||
@Column('boolean', { default: true })
|
|
||||||
use_notification: boolean;
|
|
||||||
|
|
||||||
@Column('boolean', { default: false })
|
|
||||||
requiring_notification: boolean;
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseDataService } from 'src/core/modules/data/service/base-data.service';
|
|
||||||
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { ItemQueueModel } from '../models/item-queue.model';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ItemQueueDataService extends BaseDataService<ItemQueueEntity> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(ItemQueueModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<ItemQueueModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { ItemQueueEntity } from '../../domain/entities/item-queue.entity';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { ItemQueueModel } from '../models/item-queue.model';
|
|
||||||
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { BaseReadService } from 'src/core/modules/data/service/base-read.service';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ItemQueueReadService extends BaseReadService<ItemQueueEntity> {
|
|
||||||
constructor(
|
|
||||||
@InjectRepository(ItemQueueModel, CONNECTION_NAME.DEFAULT)
|
|
||||||
private repo: Repository<ItemQueueModel>,
|
|
||||||
) {
|
|
||||||
super(repo);
|
|
||||||
}
|
|
||||||
|
|
||||||
async list(): Promise<ItemQueueEntity[]> {
|
|
||||||
return this.repo.find();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
import { BaseFilterEntity } from 'src/core/modules/domain/entities/base-filter.entity';
|
|
||||||
|
|
||||||
export interface FilterItemQueueEntity extends BaseFilterEntity {
|
|
||||||
item_types: string[];
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { BaseStatusEntity } from 'src/core/modules/domain/entities/base-status.entity';
|
|
||||||
import { ItemType } from '../../constants';
|
|
||||||
import { ItemEntity } from 'src/modules/item-related/item/domain/entities/item.entity';
|
|
||||||
|
|
||||||
export interface ItemQueueEntity extends BaseStatusEntity {
|
|
||||||
name: string;
|
|
||||||
item_type: ItemType;
|
|
||||||
information?: string;
|
|
||||||
max_peak_level: number;
|
|
||||||
call_preparation: number;
|
|
||||||
items: ItemEntity[];
|
|
||||||
use_notification?: boolean;
|
|
||||||
requiring_notification?: boolean;
|
|
||||||
}
|
|
|
@ -1,122 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { CreateItemQueueManager } from './managers/create-item-queue.manager';
|
|
||||||
import { ItemQueueDataService } from '../../data/services/item-queue-data.service';
|
|
||||||
import { ItemQueueEntity } from '../entities/item-queue.entity';
|
|
||||||
import { DeleteItemQueueManager } from './managers/delete-item-queue.manager';
|
|
||||||
import { UpdateItemQueueManager } from './managers/update-item-queue.manager';
|
|
||||||
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
|
|
||||||
import { ActiveItemQueueManager } from './managers/active-item-queue.manager';
|
|
||||||
import { InactiveItemQueueManager } from './managers/inactive-item-queue.manager';
|
|
||||||
import { ConfirmItemQueueManager } from './managers/confirm-item-queue.manager';
|
|
||||||
import { STATUS } from 'src/core/strings/constants/base.constants';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { BatchConfirmItemQueueManager } from './managers/batch-confirm-item-queue.manager';
|
|
||||||
import { BatchInactiveItemQueueManager } from './managers/batch-inactive-item-queue.manager';
|
|
||||||
import { BatchActiveItemQueueManager } from './managers/batch-active-item-queue.manager';
|
|
||||||
import { BatchDeleteItemQueueManager } from './managers/batch-delete-item-queue.manager';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ItemQueueDataOrchestrator extends BaseDataTransactionOrchestrator<ItemQueueEntity> {
|
|
||||||
constructor(
|
|
||||||
private createManager: CreateItemQueueManager,
|
|
||||||
private updateManager: UpdateItemQueueManager,
|
|
||||||
private deleteManager: DeleteItemQueueManager,
|
|
||||||
private activeManager: ActiveItemQueueManager,
|
|
||||||
private confirmManager: ConfirmItemQueueManager,
|
|
||||||
private inactiveManager: InactiveItemQueueManager,
|
|
||||||
private batchDeleteManager: BatchDeleteItemQueueManager,
|
|
||||||
private batchActiveManager: BatchActiveItemQueueManager,
|
|
||||||
private batchConfirmManager: BatchConfirmItemQueueManager,
|
|
||||||
private batchInactiveManager: BatchInactiveItemQueueManager,
|
|
||||||
private serviceData: ItemQueueDataService,
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
async create(data): Promise<ItemQueueEntity> {
|
|
||||||
data.items = data.item_ids.map((id) => {
|
|
||||||
return { id };
|
|
||||||
});
|
|
||||||
this.createManager.setData(data);
|
|
||||||
this.createManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.createManager.execute();
|
|
||||||
await this.createManager.generateConfig();
|
|
||||||
return this.createManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async update(dataId, data): Promise<ItemQueueEntity> {
|
|
||||||
this.updateManager.setData(dataId, data);
|
|
||||||
this.updateManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.updateManager.execute();
|
|
||||||
return this.updateManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete(dataId): Promise<string> {
|
|
||||||
this.deleteManager.setData(dataId);
|
|
||||||
this.deleteManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.deleteManager.execute();
|
|
||||||
return this.deleteManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async batchDelete(dataIds: string[]): Promise<BatchResult> {
|
|
||||||
this.batchDeleteManager.setData(dataIds);
|
|
||||||
this.batchDeleteManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.ITEM_CATEGORY,
|
|
||||||
);
|
|
||||||
await this.batchDeleteManager.execute();
|
|
||||||
return this.batchDeleteManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async active(dataId): Promise<string> {
|
|
||||||
this.activeManager.setData(dataId, STATUS.ACTIVE);
|
|
||||||
this.activeManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.activeManager.execute();
|
|
||||||
return this.activeManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async batchActive(dataIds: string[]): Promise<BatchResult> {
|
|
||||||
this.batchActiveManager.setData(dataIds, STATUS.ACTIVE);
|
|
||||||
this.batchActiveManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.ITEM_CATEGORY,
|
|
||||||
);
|
|
||||||
await this.batchActiveManager.execute();
|
|
||||||
return this.batchActiveManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async confirm(dataId): Promise<string> {
|
|
||||||
this.confirmManager.setData(dataId, STATUS.ACTIVE);
|
|
||||||
this.confirmManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.confirmManager.execute();
|
|
||||||
return this.confirmManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async batchConfirm(dataIds: string[]): Promise<BatchResult> {
|
|
||||||
this.batchConfirmManager.setData(dataIds, STATUS.ACTIVE);
|
|
||||||
this.batchConfirmManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.ITEM_CATEGORY,
|
|
||||||
);
|
|
||||||
await this.batchConfirmManager.execute();
|
|
||||||
return this.batchConfirmManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async inactive(dataId): Promise<string> {
|
|
||||||
this.inactiveManager.setData(dataId, STATUS.INACTIVE);
|
|
||||||
this.inactiveManager.setService(this.serviceData, TABLE_NAME.ITEM_CATEGORY);
|
|
||||||
await this.inactiveManager.execute();
|
|
||||||
return this.inactiveManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async batchInactive(dataIds: string[]): Promise<BatchResult> {
|
|
||||||
this.batchInactiveManager.setData(dataIds, STATUS.INACTIVE);
|
|
||||||
this.batchInactiveManager.setService(
|
|
||||||
this.serviceData,
|
|
||||||
TABLE_NAME.ITEM_CATEGORY,
|
|
||||||
);
|
|
||||||
await this.batchInactiveManager.execute();
|
|
||||||
return this.batchInactiveManager.getResult();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { IndexItemQueueManager } from './managers/index-item-queue.manager';
|
|
||||||
import { ItemQueueReadService } from '../../data/services/item-queue-read.service';
|
|
||||||
import { ItemQueueEntity } from '../entities/item-queue.entity';
|
|
||||||
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
|
|
||||||
import { DetailItemQueueManager } from './managers/detail-item-queue.manager';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ItemQueueReadOrchestrator extends BaseReadOrchestrator<ItemQueueEntity> {
|
|
||||||
constructor(
|
|
||||||
private indexManager: IndexItemQueueManager,
|
|
||||||
private detailManager: DetailItemQueueManager,
|
|
||||||
private serviceData: ItemQueueReadService,
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
async index(params): Promise<PaginationResponse<ItemQueueEntity>> {
|
|
||||||
this.indexManager.setFilterParam(params);
|
|
||||||
this.indexManager.setService(this.serviceData, TABLE_NAME.ITEM_QUEUE);
|
|
||||||
await this.indexManager.execute();
|
|
||||||
return this.indexManager.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
async list(): Promise<ItemQueueEntity[]> {
|
|
||||||
const items = await this.serviceData.list();
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
async detail(dataId: string): Promise<ItemQueueEntity> {
|
|
||||||
this.detailManager.setData(dataId);
|
|
||||||
this.detailManager.setService(this.serviceData, TABLE_NAME.ITEM_QUEUE);
|
|
||||||
await this.detailManager.execute();
|
|
||||||
return this.detailManager.getResult();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ActiveItemQueueManager extends BaseUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success active data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class BatchActiveItemQueueManager extends BaseBatchUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
validateData(data: ItemQueueEntity): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): BatchResult {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class BatchConfirmItemQueueManager extends BaseBatchUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
validateData(data: ItemQueueEntity): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): BatchResult {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
import { BaseBatchDeleteManager } from 'src/core/modules/domain/usecase/managers/base-batch-delete.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class BatchDeleteItemQueueManager extends BaseBatchDeleteManager<ItemQueueEntity> {
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateData(data: ItemQueueEntity): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
relation: 'items',
|
|
||||||
message:
|
|
||||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): BatchResult {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
import { BaseBatchUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-batch-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class BatchInactiveItemQueueManager extends BaseBatchUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
validateData(data: ItemQueueEntity): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
relation: 'items',
|
|
||||||
message:
|
|
||||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): BatchResult {
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ConfirmItemQueueManager extends BaseUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success active data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
columnUniques,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import { BaseCreateManager } from 'src/core/modules/domain/usecase/managers/base-create.manager';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class CreateItemQueueManager extends BaseCreateManager<ItemQueueEntity> {
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
Object.assign(this.data, {
|
|
||||||
item_type: this.data.item_type.toLowerCase(),
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async generateConfig(): Promise<void> {
|
|
||||||
// TODO: Implement logic here
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get uniqueColumns(): columnUniques[] {
|
|
||||||
return [{ column: 'name' }];
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseDeleteManager } from 'src/core/modules/domain/usecase/managers/base-delete.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DeleteItemQueueManager extends BaseDeleteManager<ItemQueueEntity> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseDetailManager } from 'src/core/modules/domain/usecase/managers/base-detail.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import { RelationParam } from 'src/core/modules/domain/entities/base-filter.entity';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DetailItemQueueManager extends BaseDetailManager<ItemQueueEntity> {
|
|
||||||
async prepareData(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get relations(): RelationParam {
|
|
||||||
return {
|
|
||||||
joinRelations: [],
|
|
||||||
selectRelations: ['items'],
|
|
||||||
countRelations: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
get selects(): string[] {
|
|
||||||
return [
|
|
||||||
`${this.tableName}.id`,
|
|
||||||
`${this.tableName}.status`,
|
|
||||||
`${this.tableName}.name`,
|
|
||||||
`${this.tableName}.information`,
|
|
||||||
`${this.tableName}.item_type`,
|
|
||||||
`${this.tableName}.created_at`,
|
|
||||||
`${this.tableName}.creator_name`,
|
|
||||||
`${this.tableName}.updated_at`,
|
|
||||||
`${this.tableName}.editor_name`,
|
|
||||||
`${this.tableName}.max_peak_level`,
|
|
||||||
`${this.tableName}.call_preparation`,
|
|
||||||
`${this.tableName}.use_notification`,
|
|
||||||
`${this.tableName}.requiring_notification`,
|
|
||||||
|
|
||||||
`items.id`,
|
|
||||||
`items.created_at`,
|
|
||||||
`items.status`,
|
|
||||||
`items.item_type`,
|
|
||||||
`items.name`,
|
|
||||||
`items.hpp`,
|
|
||||||
`items.limit_type`,
|
|
||||||
`items.limit_value`,
|
|
||||||
`items.base_price`,
|
|
||||||
`items.share_profit`,
|
|
||||||
`items.play_estimation`,
|
|
||||||
`items.video_url`,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get setFindProperties(): any {
|
|
||||||
return {
|
|
||||||
id: this.dataId,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getResult(): ItemQueueEntity {
|
|
||||||
const videos = this.result.items.map((item) => {
|
|
||||||
return item.video_url ?? [];
|
|
||||||
});
|
|
||||||
this.result['videos'] = videos.flat();
|
|
||||||
return this.result;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateStatusManager } from 'src/core/modules/domain/usecase/managers/base-update-status.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class InactiveItemQueueManager extends BaseUpdateStatusManager<ItemQueueEntity> {
|
|
||||||
getResult(): string {
|
|
||||||
return `Success inactive data ${this.result.name}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
relation: 'items',
|
|
||||||
message:
|
|
||||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseIndexManager } from 'src/core/modules/domain/usecase/managers/base-index.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import { SelectQueryBuilder } from 'typeorm';
|
|
||||||
import {
|
|
||||||
Param,
|
|
||||||
RelationParam,
|
|
||||||
} from 'src/core/modules/domain/entities/base-filter.entity';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class IndexItemQueueManager extends BaseIndexManager<ItemQueueEntity> {
|
|
||||||
async prepareData(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get relations(): RelationParam {
|
|
||||||
return {
|
|
||||||
joinRelations: [],
|
|
||||||
selectRelations: ['items'],
|
|
||||||
countRelations: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
get selects(): string[] {
|
|
||||||
return [
|
|
||||||
`${this.tableName}.id`,
|
|
||||||
`${this.tableName}.status`,
|
|
||||||
`${this.tableName}.name`,
|
|
||||||
`${this.tableName}.item_type`,
|
|
||||||
`${this.tableName}.created_at`,
|
|
||||||
`${this.tableName}.creator_name`,
|
|
||||||
`${this.tableName}.updated_at`,
|
|
||||||
`${this.tableName}.editor_name`,
|
|
||||||
`${this.tableName}.max_peak_level`,
|
|
||||||
`${this.tableName}.call_preparation`,
|
|
||||||
`${this.tableName}.use_notification`,
|
|
||||||
`${this.tableName}.requiring_notification`,
|
|
||||||
|
|
||||||
`items.id`,
|
|
||||||
`items.created_at`,
|
|
||||||
`items.status`,
|
|
||||||
`items.item_type`,
|
|
||||||
`items.name`,
|
|
||||||
`items.hpp`,
|
|
||||||
`items.limit_type`,
|
|
||||||
`items.limit_value`,
|
|
||||||
`items.base_price`,
|
|
||||||
`items.share_profit`,
|
|
||||||
`items.play_estimation`,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
get specificFilter(): Param[] {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.name`,
|
|
||||||
data: this.filterParam.names,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cols: `${this.tableName}.item_type::text`,
|
|
||||||
data: this.filterParam.item_types,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
setQueryFilter(
|
|
||||||
queryBuilder: SelectQueryBuilder<ItemQueueEntity>,
|
|
||||||
): SelectQueryBuilder<ItemQueueEntity> {
|
|
||||||
return queryBuilder;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { BaseUpdateManager } from 'src/core/modules/domain/usecase/managers/base-update.manager';
|
|
||||||
import { ItemQueueEntity } from '../../entities/item-queue.entity';
|
|
||||||
import { ItemQueueModel } from '../../../data/models/item-queue.model';
|
|
||||||
import {
|
|
||||||
EventTopics,
|
|
||||||
columnUniques,
|
|
||||||
validateRelations,
|
|
||||||
} from 'src/core/strings/constants/interface.constants';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UpdateItemQueueManager extends BaseUpdateManager<ItemQueueEntity> {
|
|
||||||
async validateProcess(): Promise<void> {
|
|
||||||
Object.assign(this.data, {
|
|
||||||
item_type: this.data.item_type.toLowerCase(),
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async afterProcess(): Promise<void> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
|
||||||
if (this.data.item_type != this.oldData.item_type) {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
relation: 'items',
|
|
||||||
message:
|
|
||||||
'Gagal! tidak dapat mengubah tipe item karena sudah berelasi dengan item',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get uniqueColumns(): columnUniques[] {
|
|
||||||
return [{ column: 'name' }];
|
|
||||||
}
|
|
||||||
|
|
||||||
get entityTarget(): any {
|
|
||||||
return ItemQueueModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue