transform core api codes into this project, update modules as admin/pos context modules
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common'
|
||||
import { CustomersService } from './customers.service'
|
||||
|
||||
@Controller('pos/customers')
|
||||
export class CustomersController {
|
||||
constructor(private readonly customerService: CustomersService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.customerService.findAll()
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.customerService.findOne(+id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() data: any) {
|
||||
return this.customerService.create(data)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { CustomersController } from './customers.controller'
|
||||
import { CustomersService } from './customers.service'
|
||||
|
||||
@Module({
|
||||
controllers: [CustomersController],
|
||||
providers: [CustomersService],
|
||||
})
|
||||
export class PosCustomersModule {}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
|
||||
@Injectable()
|
||||
export class CustomersService {
|
||||
findAll() {
|
||||
// TODO: Implement fetching all customers
|
||||
return []
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
// TODO: Implement fetching a single customer
|
||||
return {}
|
||||
}
|
||||
|
||||
create(data: any) {
|
||||
// TODO: Implement customer creation
|
||||
return data
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { IsBoolean, IsNumber, IsString, MaxLength, MinLength } from 'class-validator'
|
||||
|
||||
export class CreateCustomerIndividualDto {
|
||||
@IsString()
|
||||
@ApiProperty({ required: true })
|
||||
first_name: string
|
||||
|
||||
@IsString()
|
||||
@ApiProperty({ required: true })
|
||||
last_name: string
|
||||
|
||||
@IsNumber()
|
||||
@MaxLength(10)
|
||||
@MinLength(10)
|
||||
@ApiProperty({ required: true, maxLength: 10, minLength: 10 })
|
||||
national_code: number
|
||||
|
||||
@IsNumber()
|
||||
@MaxLength(10)
|
||||
@MinLength(10)
|
||||
@ApiProperty({ required: true, maxLength: 10, minLength: 10 })
|
||||
postal_code: number
|
||||
|
||||
@IsBoolean()
|
||||
@ApiProperty({ required: false, default: false })
|
||||
is_favorite: boolean
|
||||
|
||||
@IsNumber()
|
||||
@ApiProperty({ required: false })
|
||||
economic_code: number
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { IsNumber, IsString, MaxLength, MinLength } from 'class-validator'
|
||||
|
||||
export class CreateCustomerLegalDto {
|
||||
@IsString()
|
||||
@ApiProperty({ required: true })
|
||||
company_name: string
|
||||
|
||||
@IsString()
|
||||
@ApiProperty({ required: true })
|
||||
economic_code: string
|
||||
|
||||
@IsString()
|
||||
@ApiProperty({ required: true })
|
||||
registration_number: string
|
||||
|
||||
@IsNumber()
|
||||
@MaxLength(10)
|
||||
@MinLength(10)
|
||||
@ApiProperty({ required: true, maxLength: 10, minLength: 10 })
|
||||
postal_code: number
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsBoolean, IsEmail, IsOptional, IsString } from 'class-validator'
|
||||
|
||||
export class CreateCustomerDto {
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
first_name: string
|
||||
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
last_name: string
|
||||
|
||||
@IsOptional()
|
||||
@IsEmail()
|
||||
@ApiProperty({ required: false })
|
||||
email?: string
|
||||
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
mobile_number: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({ required: false })
|
||||
address?: string
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
@ApiProperty({ required: false })
|
||||
is_active?: boolean
|
||||
}
|
||||
|
||||
export class UpdateCustomerDto extends PartialType(CreateCustomerDto) {}
|
||||
Reference in New Issue
Block a user