Deploy via committed dist: local Nest build, server runs with .env
Build on the developer machine without Docker, commit dist/, and run on the server with Dockerfile.dist plus compose env_file. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+91
@@ -0,0 +1,91 @@
|
||||
import { CustomersService } from './customers.service';
|
||||
import { CreateCustomerDto, SetCustomerActiveDto, UpdateCustomerDto } from './dto/customer.dto';
|
||||
export declare class CustomersController {
|
||||
private readonly customersService;
|
||||
constructor(customersService: CustomersService);
|
||||
findAll(q?: string): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}[]>;
|
||||
findOne(id: string): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
create(dto: CreateCustomerDto): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
update(id: string, dto: UpdateCustomerDto): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
setActive(id: string, dto: SetCustomerActiveDto): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CustomersController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const customers_service_1 = require("./customers.service");
|
||||
const auth_decorators_1 = require("../common/decorators/auth.decorators");
|
||||
const customer_dto_1 = require("./dto/customer.dto");
|
||||
let CustomersController = class CustomersController {
|
||||
customersService;
|
||||
constructor(customersService) {
|
||||
this.customersService = customersService;
|
||||
}
|
||||
findAll(q) {
|
||||
return this.customersService.findAll(q);
|
||||
}
|
||||
findOne(id) {
|
||||
return this.customersService.findOne(id);
|
||||
}
|
||||
create(dto) {
|
||||
return this.customersService.create(dto);
|
||||
}
|
||||
update(id, dto) {
|
||||
return this.customersService.update(id, dto);
|
||||
}
|
||||
setActive(id, dto) {
|
||||
return this.customersService.setActive(id, dto.isActive);
|
||||
}
|
||||
};
|
||||
exports.CustomersController = CustomersController;
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__param(0, (0, common_1.Query)('q')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomersController.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomersController.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)(),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [customer_dto_1.CreateCustomerDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomersController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':id'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, customer_dto_1.UpdateCustomerDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomersController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':id/active'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, customer_dto_1.SetCustomerActiveDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomersController.prototype, "setActive", null);
|
||||
exports.CustomersController = CustomersController = __decorate([
|
||||
(0, common_1.Controller)('admin/customers'),
|
||||
(0, auth_decorators_1.AuthType)('admin'),
|
||||
__metadata("design:paramtypes", [customers_service_1.CustomersService])
|
||||
], CustomersController);
|
||||
//# sourceMappingURL=customers.controller.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"customers.controller.js","sourceRoot":"","sources":["../../src/customers/customers.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,2DAAuD;AACvD,0EAAgE;AAChE,qDAI4B;AAIrB,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACD;IAA7B,YAA6B,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAGnE,OAAO,CAAa,CAAU;QAC5B,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IAGD,OAAO,CAAc,EAAU;QAC7B,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IAGD,MAAM,CAAS,GAAsB;QACnC,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAGD,MAAM,CAAc,EAAU,EAAU,GAAsB;QAC5D,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC/C,CAAC;IAGD,SAAS,CAAc,EAAU,EAAU,GAAyB;QAClE,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AA3BY,kDAAmB;AAI9B;IADC,IAAA,YAAG,GAAE;IACG,WAAA,IAAA,cAAK,EAAC,GAAG,CAAC,CAAA;;;;kDAElB;AAGD;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;kDAEnB;AAGD;IADC,IAAA,aAAI,GAAE;IACC,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAM,gCAAiB;;iDAEpC;AAGD;IADC,IAAA,cAAK,EAAC,KAAK,CAAC;IACL,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,gCAAiB;;iDAE7D;AAGD;IADC,IAAA,cAAK,EAAC,YAAY,CAAC;IACT,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IAAc,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,mCAAoB;;oDAEnE;8BA1BU,mBAAmB;IAF/B,IAAA,mBAAU,EAAC,iBAAiB,CAAC;IAC7B,IAAA,0BAAQ,EAAC,OAAO,CAAC;qCAE+B,oCAAgB;GADpD,mBAAmB,CA2B/B"}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export declare class CustomersModule {
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CustomersModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const customers_controller_1 = require("./customers.controller");
|
||||
const customers_service_1 = require("./customers.service");
|
||||
let CustomersModule = class CustomersModule {
|
||||
};
|
||||
exports.CustomersModule = CustomersModule;
|
||||
exports.CustomersModule = CustomersModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
controllers: [customers_controller_1.CustomersController],
|
||||
providers: [customers_service_1.CustomersService],
|
||||
exports: [customers_service_1.CustomersService],
|
||||
})
|
||||
], CustomersModule);
|
||||
//# sourceMappingURL=customers.module.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"customers.module.js","sourceRoot":"","sources":["../../src/customers/customers.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iEAA6D;AAC7D,2DAAuD;AAOhD,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAL3B,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,0CAAmB,CAAC;QAClC,SAAS,EAAE,CAAC,oCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,oCAAgB,CAAC;KAC5B,CAAC;GACW,eAAe,CAAG"}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { CreateCustomerDto, UpdateCustomerDto } from './dto/customer.dto';
|
||||
export declare class CustomersService {
|
||||
private readonly prisma;
|
||||
constructor(prisma: PrismaService);
|
||||
findAll(q?: string): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}[]>;
|
||||
findOne(id: string): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
create(dto: CreateCustomerDto): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
update(id: string, dto: UpdateCustomerDto): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
setActive(id: string, isActive: boolean): Promise<{
|
||||
id: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
nationalId: string;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
companyId: string | null;
|
||||
companyName: string;
|
||||
orderCount: number;
|
||||
totalMeterage: number;
|
||||
isActive: boolean;
|
||||
registeredAt: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
private resolveNames;
|
||||
private ensure;
|
||||
private map;
|
||||
}
|
||||
Vendored
+192
@@ -0,0 +1,192 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CustomersService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
const phone_1 = require("../common/utils/phone");
|
||||
const name_1 = require("../common/utils/name");
|
||||
let CustomersService = class CustomersService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
this.prisma = prisma;
|
||||
}
|
||||
async findAll(q) {
|
||||
const customers = await this.prisma.customer.findMany({
|
||||
where: q
|
||||
? {
|
||||
OR: [
|
||||
{ firstName: { contains: q, mode: 'insensitive' } },
|
||||
{ lastName: { contains: q, mode: 'insensitive' } },
|
||||
{ phone: { contains: (0, phone_1.toEnglishDigits)(q) } },
|
||||
{ nationalId: { contains: (0, phone_1.toEnglishDigits)(q) } },
|
||||
],
|
||||
}
|
||||
: undefined,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: {
|
||||
company: { select: { name: true } },
|
||||
orders: { select: { totalMeterage: true } },
|
||||
},
|
||||
});
|
||||
return customers.map((c) => this.map(c));
|
||||
}
|
||||
async findOne(id) {
|
||||
const customer = await this.prisma.customer.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
company: { select: { name: true } },
|
||||
orders: { select: { totalMeterage: true } },
|
||||
},
|
||||
});
|
||||
if (!customer)
|
||||
throw new common_1.NotFoundException('مشتری یافت نشد');
|
||||
return this.map(customer);
|
||||
}
|
||||
async create(dto) {
|
||||
const phone = (0, phone_1.normalizePhone)((0, phone_1.toEnglishDigits)(dto.phone));
|
||||
if (!(0, phone_1.isValidPhone)(phone)) {
|
||||
throw new common_1.BadRequestException('شماره موبایل نامعتبر است');
|
||||
}
|
||||
const { firstName, lastName } = this.resolveNames(dto);
|
||||
if (dto.companyId) {
|
||||
const company = await this.prisma.company.findUnique({
|
||||
where: { id: dto.companyId },
|
||||
});
|
||||
if (!company)
|
||||
throw new common_1.NotFoundException('شرکت یافت نشد');
|
||||
}
|
||||
try {
|
||||
const customer = await this.prisma.customer.create({
|
||||
data: {
|
||||
firstName,
|
||||
lastName,
|
||||
phone,
|
||||
nationalId: dto.nationalId?.trim() || null,
|
||||
customerType: dto.customerType ?? client_1.CustomerType.wholesale,
|
||||
companyId: dto.companyId || null,
|
||||
isActive: dto.isActive ?? true,
|
||||
},
|
||||
include: {
|
||||
company: { select: { name: true } },
|
||||
orders: { select: { totalMeterage: true } },
|
||||
},
|
||||
});
|
||||
return this.map(customer);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof client_1.Prisma.PrismaClientKnownRequestError && e.code === 'P2002') {
|
||||
throw new common_1.ConflictException('این شماره قبلاً ثبت شده است');
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async update(id, dto) {
|
||||
await this.ensure(id);
|
||||
const phone = dto.phone !== undefined
|
||||
? (0, phone_1.normalizePhone)((0, phone_1.toEnglishDigits)(dto.phone))
|
||||
: undefined;
|
||||
if (phone !== undefined && !(0, phone_1.isValidPhone)(phone)) {
|
||||
throw new common_1.BadRequestException('شماره موبایل نامعتبر است');
|
||||
}
|
||||
let firstName;
|
||||
let lastName;
|
||||
if (dto.name !== undefined || dto.firstName !== undefined || dto.lastName !== undefined) {
|
||||
const names = this.resolveNames(dto);
|
||||
firstName = names.firstName;
|
||||
lastName = names.lastName;
|
||||
}
|
||||
try {
|
||||
const customer = await this.prisma.customer.update({
|
||||
where: { id },
|
||||
data: {
|
||||
firstName,
|
||||
lastName,
|
||||
phone,
|
||||
nationalId: dto.nationalId === undefined
|
||||
? undefined
|
||||
: dto.nationalId?.trim() || null,
|
||||
customerType: dto.customerType,
|
||||
companyId: dto.companyId === undefined ? undefined : dto.companyId || null,
|
||||
isActive: dto.isActive,
|
||||
},
|
||||
include: {
|
||||
company: { select: { name: true } },
|
||||
orders: { select: { totalMeterage: true } },
|
||||
},
|
||||
});
|
||||
return this.map(customer);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof client_1.Prisma.PrismaClientKnownRequestError && e.code === 'P2002') {
|
||||
throw new common_1.ConflictException('این شماره قبلاً ثبت شده است');
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async setActive(id, isActive) {
|
||||
await this.ensure(id);
|
||||
const customer = await this.prisma.customer.update({
|
||||
where: { id },
|
||||
data: { isActive },
|
||||
include: {
|
||||
company: { select: { name: true } },
|
||||
orders: { select: { totalMeterage: true } },
|
||||
},
|
||||
});
|
||||
return this.map(customer);
|
||||
}
|
||||
resolveNames(dto) {
|
||||
if (dto.name?.trim()) {
|
||||
return (0, name_1.splitFullName)(dto.name);
|
||||
}
|
||||
const firstName = dto.firstName?.trim();
|
||||
const lastName = dto.lastName?.trim() ?? '';
|
||||
if (!firstName) {
|
||||
throw new common_1.BadRequestException('نام مشتری الزامی است');
|
||||
}
|
||||
return { firstName, lastName };
|
||||
}
|
||||
async ensure(id) {
|
||||
const customer = await this.prisma.customer.findUnique({ where: { id } });
|
||||
if (!customer)
|
||||
throw new common_1.NotFoundException('مشتری یافت نشد');
|
||||
return customer;
|
||||
}
|
||||
map(customer) {
|
||||
const totalMeterage = customer.orders.reduce((sum, o) => sum + o.totalMeterage, 0);
|
||||
const name = (0, name_1.joinFullName)(customer.firstName, customer.lastName);
|
||||
return {
|
||||
id: customer.id,
|
||||
firstName: customer.firstName,
|
||||
lastName: customer.lastName,
|
||||
name,
|
||||
phone: customer.phone,
|
||||
nationalId: customer.nationalId ?? '',
|
||||
customerType: customer.customerType,
|
||||
companyId: customer.companyId,
|
||||
companyName: customer.company?.name ?? '',
|
||||
orderCount: customer.orders.length,
|
||||
totalMeterage,
|
||||
isActive: customer.isActive,
|
||||
registeredAt: customer.createdAt.toISOString(),
|
||||
createdAt: customer.createdAt.toISOString(),
|
||||
updatedAt: customer.updatedAt.toISOString(),
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.CustomersService = CustomersService;
|
||||
exports.CustomersService = CustomersService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
], CustomersService);
|
||||
//# sourceMappingURL=customers.service.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
import { CustomerType } from '@prisma/client';
|
||||
export declare class CreateCustomerDto {
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
name?: string;
|
||||
phone: string;
|
||||
nationalId?: string;
|
||||
customerType?: CustomerType;
|
||||
companyId?: string | null;
|
||||
isActive?: boolean;
|
||||
}
|
||||
export declare class UpdateCustomerDto {
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
name?: string;
|
||||
phone?: string;
|
||||
nationalId?: string | null;
|
||||
customerType?: CustomerType;
|
||||
companyId?: string | null;
|
||||
isActive?: boolean;
|
||||
}
|
||||
export declare class SetCustomerActiveDto {
|
||||
isActive: boolean;
|
||||
}
|
||||
Vendored
+125
@@ -0,0 +1,125 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SetCustomerActiveDto = exports.UpdateCustomerDto = exports.CreateCustomerDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const client_1 = require("@prisma/client");
|
||||
class CreateCustomerDto {
|
||||
firstName;
|
||||
lastName;
|
||||
name;
|
||||
phone;
|
||||
nationalId;
|
||||
customerType;
|
||||
companyId;
|
||||
isActive;
|
||||
}
|
||||
exports.CreateCustomerDto = CreateCustomerDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateCustomerDto.prototype, "firstName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateCustomerDto.prototype, "lastName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateCustomerDto.prototype, "name", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
(0, class_validator_1.MinLength)(10),
|
||||
__metadata("design:type", String)
|
||||
], CreateCustomerDto.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateCustomerDto.prototype, "nationalId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.CustomerType),
|
||||
__metadata("design:type", String)
|
||||
], CreateCustomerDto.prototype, "customerType", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", Object)
|
||||
], CreateCustomerDto.prototype, "companyId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], CreateCustomerDto.prototype, "isActive", void 0);
|
||||
class UpdateCustomerDto {
|
||||
firstName;
|
||||
lastName;
|
||||
name;
|
||||
phone;
|
||||
nationalId;
|
||||
customerType;
|
||||
companyId;
|
||||
isActive;
|
||||
}
|
||||
exports.UpdateCustomerDto = UpdateCustomerDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateCustomerDto.prototype, "firstName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateCustomerDto.prototype, "lastName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateCustomerDto.prototype, "name", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateCustomerDto.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", Object)
|
||||
], UpdateCustomerDto.prototype, "nationalId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.CustomerType),
|
||||
__metadata("design:type", String)
|
||||
], UpdateCustomerDto.prototype, "customerType", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", Object)
|
||||
], UpdateCustomerDto.prototype, "companyId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], UpdateCustomerDto.prototype, "isActive", void 0);
|
||||
class SetCustomerActiveDto {
|
||||
isActive;
|
||||
}
|
||||
exports.SetCustomerActiveDto = SetCustomerActiveDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], SetCustomerActiveDto.prototype, "isActive", void 0);
|
||||
//# sourceMappingURL=customer.dto.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"customer.dto.js","sourceRoot":"","sources":["../../../src/customers/dto/customer.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAMyB;AACzB,2CAA8C;AAE9C,MAAa,iBAAiB;IAG5B,SAAS,CAAU;IAInB,QAAQ,CAAU;IAKlB,IAAI,CAAU;IAId,KAAK,CAAU;IAIf,UAAU,CAAU;IAIpB,YAAY,CAAgB;IAI5B,SAAS,CAAiB;IAI1B,QAAQ,CAAW;CACpB;AAjCD,8CAiCC;AA9BC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACQ;AAInB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACO;AAKlB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;+CACG;AAId;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,EAAE,CAAC;;gDACC;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACS;AAIpB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,qBAAY,CAAC;;uDACO;AAI5B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACe;AAI1B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;mDACO;AAGrB,MAAa,iBAAiB;IAG5B,SAAS,CAAU;IAInB,QAAQ,CAAU;IAIlB,IAAI,CAAU;IAId,KAAK,CAAU;IAIf,UAAU,CAAiB;IAI3B,YAAY,CAAgB;IAI5B,SAAS,CAAiB;IAI1B,QAAQ,CAAW;CACpB;AAhCD,8CAgCC;AA7BC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACQ;AAInB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;mDACO;AAIlB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;+CACG;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;gDACI;AAIf;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACgB;AAI3B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,qBAAY,CAAC;;uDACO;AAI5B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACe;AAI1B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,GAAE;;mDACO;AAGrB,MAAa,oBAAoB;IAE/B,QAAQ,CAAW;CACpB;AAHD,oDAGC;AADC;IADC,IAAA,2BAAS,GAAE;;sDACO"}
|
||||
Reference in New Issue
Block a user