add: rent fields to company
This commit is contained in:
@@ -3636,6 +3636,35 @@
|
||||
"default": "true",
|
||||
"mappedType": "boolean"
|
||||
},
|
||||
"is_rented": {
|
||||
"name": "is_rented",
|
||||
"type": "boolean",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"default": "false",
|
||||
"mappedType": "boolean"
|
||||
},
|
||||
"rent_contract_images": {
|
||||
"name": "rent_contract_images",
|
||||
"type": "jsonb",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": true,
|
||||
"mappedType": "json"
|
||||
},
|
||||
"rent_end_at": {
|
||||
"name": "rent_end_at",
|
||||
"type": "timestamptz",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": true,
|
||||
"length": 6,
|
||||
"mappedType": "datetime"
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "company_status",
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Migration } from '@mikro-orm/migrations';
|
||||
|
||||
export class Migration20260316055843 extends Migration {
|
||||
|
||||
override async up(): Promise<void> {
|
||||
this.addSql(`alter table "company" add column "is_rented" boolean not null default false, add column "rent_contract_images" jsonb null, add column "rent_end_at" timestamptz null;`);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApiProperty, PickType } from "@nestjs/swagger";
|
||||
import { ApiProperty, ApiPropertyOptional, PickType } from "@nestjs/swagger";
|
||||
import { Type } from "class-transformer";
|
||||
import {
|
||||
ArrayMinSize,
|
||||
@@ -87,6 +87,21 @@ export class CreateCompanyDto extends PickType(CompleteRegistrationDto, ["phone"
|
||||
@ApiProperty({ description: "وضعیت فعالیت", example: true })
|
||||
isActive?: boolean;
|
||||
|
||||
@IsBoolean()
|
||||
@ApiProperty({ description: "وضعیت اجاره", example: true })
|
||||
isRented: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
@ApiPropertyOptional({ description: " تاریخ پایان قرارداد اجاره در صورتیکه اجاره ای است" })
|
||||
rentEndAt?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@ApiPropertyOptional({ description: "تصاویر قرارداد اجاره" })
|
||||
rentContractImages?: string[];
|
||||
|
||||
@IsNotEmpty({ message: CompanyMessage.INDUSTRY_ID_REQUIRED })
|
||||
@IsUUID("7", { message: CompanyMessage.INDUSTRY_ID_SHOULD_BE_UUID })
|
||||
@ApiProperty({ description: "شناسه صنعت", example: "123e4567-e89b-12d3-a456-426614174000" })
|
||||
|
||||
@@ -54,6 +54,15 @@ export class Company extends BaseEntity {
|
||||
@Property({ type: "boolean", default: true })
|
||||
isActive!: boolean & Opt;
|
||||
|
||||
@Property({ type: "boolean", default: false })
|
||||
isRented!: boolean & Opt;
|
||||
|
||||
@Property({ type: "json", nullable: true })
|
||||
rentContractImages?: string[];
|
||||
|
||||
@Property({ nullable: true })
|
||||
rentEndAt?: Date;
|
||||
|
||||
@Enum({ items: () => CompanyStatus, nativeEnumName: "company_status", nullable: false })
|
||||
status!: CompanyStatus;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export class CompaniesService {
|
||||
private readonly passwordService: PasswordService,
|
||||
private readonly em: EntityManager,
|
||||
private readonly companyRequestRepository: CompanyRequestRepository,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async create(createDto: CreateCompanyDto, business: Business) {
|
||||
const em = this.em.fork();
|
||||
@@ -452,7 +452,7 @@ export class CompaniesService {
|
||||
business,
|
||||
chiefExecutiveOfficer: "chiefExecutiveOfficer" in createDto ? createDto.chiefExecutiveOfficer : `${createDto.firstName} ${createDto.lastName}`,
|
||||
email: createDto.email,
|
||||
phone: createDto.phone,
|
||||
phone: createDto.phone
|
||||
});
|
||||
|
||||
await em.persistAndFlush(company);
|
||||
|
||||
Reference in New Issue
Block a user