Compare commits
No commits in common. "75663c4f9974238ea52f3a861382f78b01d1c10b" and "84f7ed6d097a7965fce90c3f85d23a1ac24c0690" have entirely different histories.
75663c4f99
...
84f7ed6d09
|
@ -37,7 +37,6 @@
|
||||||
"@nestjs/schedule": "^4.1.0",
|
"@nestjs/schedule": "^4.1.0",
|
||||||
"@nestjs/swagger": "^7.3.1",
|
"@nestjs/swagger": "^7.3.1",
|
||||||
"@nestjs/typeorm": "^10.0.2",
|
"@nestjs/typeorm": "^10.0.2",
|
||||||
"@types/multer": "^1.4.11",
|
|
||||||
"algebra.js": "^0.2.6",
|
"algebra.js": "^0.2.6",
|
||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "^5.1.1",
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
|
|
|
@ -63,7 +63,6 @@ import { TermConditionModule } from './modules/web-information/term-condition/te
|
||||||
import { TermConditionModel } from './modules/web-information/term-condition/data/models/term-condition.model';
|
import { TermConditionModel } from './modules/web-information/term-condition/data/models/term-condition.model';
|
||||||
import { FaqModel } from './modules/web-information/faq/data/models/faq.model';
|
import { FaqModel } from './modules/web-information/faq/data/models/faq.model';
|
||||||
import { FaqModule } from './modules/web-information/faq/faq.module';
|
import { FaqModule } from './modules/web-information/faq/faq.module';
|
||||||
import { UploadModule } from './modules/configuration/upload/upload.module';
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -118,7 +117,6 @@ import { UploadModule } from './modules/configuration/upload/upload.module';
|
||||||
LogModule,
|
LogModule,
|
||||||
MidtransModule,
|
MidtransModule,
|
||||||
SessionModule,
|
SessionModule,
|
||||||
UploadModule,
|
|
||||||
|
|
||||||
// user
|
// user
|
||||||
TenantModule,
|
TenantModule,
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
import * as fs from 'fs';
|
|
||||||
|
|
||||||
export function MoveFilePathHelper() {}
|
|
||||||
|
|
||||||
// export class MoveFileToDirIdHelper {
|
|
||||||
// public srcDir: string;
|
|
||||||
// public fileName: string;
|
|
||||||
|
|
||||||
// constructor(private file_url: string = null) {}
|
|
||||||
|
|
||||||
// execute(): string {
|
|
||||||
// try {
|
|
||||||
// this.getSrcDir();
|
|
||||||
// this.getFileName();
|
|
||||||
|
|
||||||
// const copyFile = `${this.fileName}-copy`;
|
|
||||||
// fs.mkdirSync(`./uploads/${this.srcDir}`, { recursive: true });
|
|
||||||
// fs.copyFileSync(
|
|
||||||
// this.file_url,
|
|
||||||
// `./uploads/${this.srcDir}/${this.fileName}`,
|
|
||||||
// );
|
|
||||||
// fs.unlinkSync(`${this.file_url}`);
|
|
||||||
|
|
||||||
// this.file_url = `uploads/${this.srcDir}/${this.fileName}`;
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error('Error moving file:', error);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return this.file_url;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private getSrcDir(): void {
|
|
||||||
// this.srcDir = this.file_url.split('/').slice(2, -1).join('/');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private getFileName(): void {
|
|
||||||
// this.fileName = this.file_url.split('/').slice(-1).join('/');
|
|
||||||
// }
|
|
||||||
// }
|
|
|
@ -1,44 +0,0 @@
|
||||||
import { extname } from 'path';
|
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
|
||||||
import { HttpException, HttpStatus } from '@nestjs/common';
|
|
||||||
import * as fs from 'fs';
|
|
||||||
import { MulterOptions } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';
|
|
||||||
import { diskStorage } from 'multer';
|
|
||||||
|
|
||||||
const MB = 1024 * 1024;
|
|
||||||
|
|
||||||
const fileFilter = (req, file, callback) => {
|
|
||||||
if (file.mimetype.match(/\/(jpg|jpeg|png)$/)) {
|
|
||||||
callback(null, true);
|
|
||||||
} else {
|
|
||||||
callback(
|
|
||||||
new HttpException(
|
|
||||||
`Unsupported file type ${extname(file.originalname)}`,
|
|
||||||
HttpStatus.BAD_REQUEST,
|
|
||||||
),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const editFileName = (req, file, callback) => {
|
|
||||||
const fileExtName = extname(file.originalname);
|
|
||||||
const randomName = uuidv4();
|
|
||||||
callback(null, `${randomName}${fileExtName}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const destinationPath = (req, file, cb) => {
|
|
||||||
let modulePath = req.body.module;
|
|
||||||
if (req.body.sub_module) modulePath = `${modulePath}/${req.body.sub_module}`;
|
|
||||||
|
|
||||||
fs.mkdirSync(`./uploads/tmp/${modulePath}`, { recursive: true });
|
|
||||||
cb(null, `./uploads/tmp/${modulePath}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const StoreFileConfig: MulterOptions = {
|
|
||||||
storage: diskStorage({
|
|
||||||
destination: destinationPath,
|
|
||||||
filename: editFileName,
|
|
||||||
}),
|
|
||||||
fileFilter: fileFilter,
|
|
||||||
};
|
|
|
@ -1,17 +1,14 @@
|
||||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
export class UpdateRefund1721031712642 implements MigrationInterface {
|
export class UpdateRefund1721031712642 implements MigrationInterface {
|
||||||
name = 'UpdateRefund1721031712642';
|
name = 'UpdateRefund1721031712642'
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(
|
await queryRunner.query(`ALTER TABLE "refunds" ADD "refund_sub_total" numeric`);
|
||||||
`ALTER TABLE "refunds" ADD "refund_sub_total" numeric`,
|
}
|
||||||
);
|
|
||||||
}
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "refunds" DROP COLUMN "refund_sub_total"`);
|
||||||
|
}
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(
|
|
||||||
`ALTER TABLE "refunds" DROP COLUMN "refund_sub_total"`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
export interface UploadEntity {
|
|
||||||
module: string;
|
|
||||||
sub_module: string;
|
|
||||||
file: any;
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
|
||||||
import { UploadEntity } from '../../domain/entities/upload.entity';
|
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
|
||||||
|
|
||||||
export class UploadDto implements UploadEntity {
|
|
||||||
@ApiProperty({
|
|
||||||
type: 'string',
|
|
||||||
required: true,
|
|
||||||
default: TABLE_NAME.ITEM,
|
|
||||||
})
|
|
||||||
module: string;
|
|
||||||
|
|
||||||
@ApiProperty({
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
default: TABLE_NAME.ITEM,
|
|
||||||
})
|
|
||||||
sub_module: string;
|
|
||||||
|
|
||||||
@ApiProperty({ type: 'string', format: 'binary', required: true })
|
|
||||||
file: any;
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
import {
|
|
||||||
Controller,
|
|
||||||
Post,
|
|
||||||
UseInterceptors,
|
|
||||||
Body,
|
|
||||||
UploadedFile,
|
|
||||||
} from '@nestjs/common';
|
|
||||||
import { ModuleRef } from '@nestjs/core';
|
|
||||||
import { ApiBody, ApiConsumes, ApiTags } from '@nestjs/swagger';
|
|
||||||
import { FileInterceptor } from '@nestjs/platform-express';
|
|
||||||
import { UploadDto } from './dto/upload.dto';
|
|
||||||
import { Public } from 'src/core/guards';
|
|
||||||
import { StoreFileConfig } from 'src/core/helpers/path/upload-store-path.helper';
|
|
||||||
|
|
||||||
@ApiTags('uploads')
|
|
||||||
@Controller('uploads')
|
|
||||||
@Public(true)
|
|
||||||
export class UploadController {
|
|
||||||
constructor(private moduleRef: ModuleRef) {}
|
|
||||||
|
|
||||||
@Post()
|
|
||||||
@ApiConsumes('multipart/form-data')
|
|
||||||
@ApiBody({ type: UploadDto })
|
|
||||||
@UseInterceptors(FileInterceptor('file', StoreFileConfig))
|
|
||||||
async storeFile(
|
|
||||||
@UploadedFile() file: Express.Multer.File,
|
|
||||||
@Body() body: UploadDto,
|
|
||||||
): Promise<any> {
|
|
||||||
return {
|
|
||||||
path: file.path,
|
|
||||||
full_path: `${process.env.ASSETS}${file.path}`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { ConfigModule } from '@nestjs/config';
|
|
||||||
import { MulterModule } from '@nestjs/platform-express';
|
|
||||||
import { UploadController } from './infrastructure/upload.controller';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [
|
|
||||||
ConfigModule.forRoot(),
|
|
||||||
MulterModule.register({
|
|
||||||
dest: './uploads',
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
controllers: [UploadController],
|
|
||||||
providers: [],
|
|
||||||
})
|
|
||||||
export class UploadModule {}
|
|
|
@ -17,19 +17,6 @@ import { STATUS } from 'src/core/strings/constants/base.constants';
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
|
export class CreateRefundManager extends BaseCreateManager<RefundEntity> {
|
||||||
async beforeProcess(): Promise<void> {
|
async beforeProcess(): Promise<void> {
|
||||||
const refund_items = this.data.refund_items?.map((item) => {
|
|
||||||
return {
|
|
||||||
transaction_item: item,
|
|
||||||
qty_refund: item.qty_refund,
|
|
||||||
refund_total: item.refund_total,
|
|
||||||
refund_sub_total: item.refund_sub_total,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.assign(this.data, {
|
|
||||||
refund_items: refund_items,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.data.transaction?.status != STATUS.SETTLED) {
|
if (this.data.transaction?.status != STATUS.SETTLED) {
|
||||||
throw new UnprocessableEntityException({
|
throw new UnprocessableEntityException({
|
||||||
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
statusCode: HttpStatus.UNPROCESSABLE_ENTITY,
|
||||||
|
|
|
@ -28,18 +28,6 @@ export class UpdateRefundManager extends BaseUpdateManager<RefundEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeProcess(): Promise<void> {
|
async beforeProcess(): Promise<void> {
|
||||||
const refund_items = this.data.refund_items?.map((item) => {
|
|
||||||
return {
|
|
||||||
transaction_item: item,
|
|
||||||
qty_refund: item.qty_refund,
|
|
||||||
refund_total: item.refund_total,
|
|
||||||
refund_sub_total: item.refund_sub_total,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.assign(this.data, {
|
|
||||||
refund_items: refund_items ?? [],
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1081,7 +1081,7 @@
|
||||||
"@types/range-parser" "*"
|
"@types/range-parser" "*"
|
||||||
"@types/send" "*"
|
"@types/send" "*"
|
||||||
|
|
||||||
"@types/express@*", "@types/express@^4.17.13":
|
"@types/express@^4.17.13":
|
||||||
version "4.17.21"
|
version "4.17.21"
|
||||||
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d"
|
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d"
|
||||||
integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==
|
integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==
|
||||||
|
@ -1178,13 +1178,6 @@
|
||||||
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690"
|
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690"
|
||||||
integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==
|
integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==
|
||||||
|
|
||||||
"@types/multer@^1.4.11":
|
|
||||||
version "1.4.11"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/multer/-/multer-1.4.11.tgz#c70792670513b4af1159a2b60bf48cc932af55c5"
|
|
||||||
integrity sha512-svK240gr6LVWvv3YGyhLlA+6LRRWA4mnGIU7RcNmgjBYFl6665wcXrRfxGp5tEPVHUNm5FMcmq7too9bxCwX/w==
|
|
||||||
dependencies:
|
|
||||||
"@types/express" "*"
|
|
||||||
|
|
||||||
"@types/node@*", "@types/node@^20.12.13":
|
"@types/node@*", "@types/node@^20.12.13":
|
||||||
version "20.14.10"
|
version "20.14.10"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.10.tgz#a1a218290f1b6428682e3af044785e5874db469a"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.10.tgz#a1a218290f1b6428682e3af044785e5874db469a"
|
||||||
|
|
Loading…
Reference in New Issue