barname
This commit is contained in:
@@ -6411,17 +6411,7 @@
|
|||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": true,
|
||||||
"length": 255,
|
|
||||||
"mappedType": "string"
|
|
||||||
},
|
|
||||||
"weight": {
|
|
||||||
"name": "weight",
|
|
||||||
"type": "varchar(255)",
|
|
||||||
"unsigned": false,
|
|
||||||
"autoincrement": false,
|
|
||||||
"primary": false,
|
|
||||||
"nullable": false,
|
|
||||||
"length": 255,
|
"length": 255,
|
||||||
"mappedType": "string"
|
"mappedType": "string"
|
||||||
},
|
},
|
||||||
@@ -6451,7 +6441,7 @@
|
|||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": true,
|
||||||
"length": 255,
|
"length": 255,
|
||||||
"mappedType": "string"
|
"mappedType": "string"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20260307082551 extends Migration {
|
||||||
|
|
||||||
|
override async up(): Promise<void> {
|
||||||
|
this.addSql(`alter table "barname" alter column "description" type varchar(255) using ("description"::varchar(255));`);
|
||||||
|
this.addSql(`alter table "barname" alter column "description" drop not null;`);
|
||||||
|
}
|
||||||
|
|
||||||
|
override async down(): Promise<void> {
|
||||||
|
this.addSql(`alter table "barname" add column "weight" varchar(255) not null;`);
|
||||||
|
this.addSql(`alter table "barname" alter column "description" type varchar(255) using ("description"::varchar(255));`);
|
||||||
|
this.addSql(`alter table "barname" alter column "description" set not null;`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20260307082850 extends Migration {
|
||||||
|
|
||||||
|
override async up(): Promise<void> {
|
||||||
|
this.addSql(`alter table "barname" alter column "origin" type varchar(255) using ("origin"::varchar(255));`);
|
||||||
|
this.addSql(`alter table "barname" alter column "origin" drop not null;`);
|
||||||
|
}
|
||||||
|
|
||||||
|
override async down(): Promise<void> {
|
||||||
|
this.addSql(`alter table "barname" alter column "origin" type varchar(255) using ("origin"::varchar(255));`);
|
||||||
|
this.addSql(`alter table "barname" alter column "origin" set not null;`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -40,6 +40,12 @@ export class BarnameController {
|
|||||||
return this.billsService.findOne(paramDto.id, businessId);
|
return this.billsService.findOne(paramDto.id, businessId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation({ summary: "Update Barname by watcher" })
|
||||||
|
@Get(":id/watcher")
|
||||||
|
update(@Param() dto: ParamDto, @BusinessDec("id") businessId: string) {
|
||||||
|
return this.billsService.findOne(dto.id, businessId);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "Remove a barname" })
|
@ApiOperation({ summary: "Remove a barname" })
|
||||||
@Delete(":id")
|
@Delete(":id")
|
||||||
remove(@Param() paramDto: ParamDto, @BusinessDec("id") businessId: string) {
|
remove(@Param() paramDto: ParamDto, @BusinessDec("id") businessId: string) {
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ export class BarnameService {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
async createBarname(dto: CreateBarnameDto, business: Business, userId: string) {
|
async createBarname(dto: CreateBarnameDto, business: Business, userId: string) {
|
||||||
const { description, driverName, driverPhone, carType, exitAt, origin, plaque, weight, attachments } = dto;
|
const { description, driverName, driverPhone, carType, exitAt, origin, plaque, attachments } = dto;
|
||||||
|
|
||||||
const company = await this.em.findOne(Company, { business, user: { id: userId }, deletedAt: null });
|
const company = await this.em.findOne(Company, { business, user: { id: userId }, deletedAt: null });
|
||||||
if (!company) throw new BadRequestException(CompanyMessage.COMPANY_NOT_FOUND);
|
if (!company) throw new BadRequestException(CompanyMessage.COMPANY_NOT_FOUND);
|
||||||
|
|
||||||
const bill = this.em.create(Barname,
|
const bill = this.em.create(Barname,
|
||||||
{ carType, exitAt, origin, plaque, weight, business, description, driverName, driverPhone, company, attachments });
|
{ carType, exitAt, origin, plaque, business, description, driverName, driverPhone, company, attachments });
|
||||||
|
|
||||||
await this.em.persistAndFlush(bill);
|
await this.em.persistAndFlush(bill);
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,6 @@ export class CreateBarnameDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
origin: string;
|
origin: string;
|
||||||
|
|
||||||
@ApiPropertyOptional()
|
|
||||||
@IsString()
|
|
||||||
@IsOptional()
|
|
||||||
weight: string;
|
|
||||||
|
|
||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { ApiProperty } from "@nestjs/swagger";
|
||||||
|
import { IsDateString } from "class-validator";
|
||||||
|
|
||||||
|
|
||||||
|
export class UpdateBarnameAsWatcherDto {
|
||||||
|
@ApiProperty()
|
||||||
|
@IsDateString()
|
||||||
|
exitAt: string;
|
||||||
|
}
|
||||||
|
|
||||||
+1
-1
@@ -2,4 +2,4 @@ import { PartialType } from "@nestjs/swagger";
|
|||||||
|
|
||||||
import { CreateBarnameDto } from "./create-barname.dto";
|
import { CreateBarnameDto } from "./create-barname.dto";
|
||||||
|
|
||||||
export class UpdateBillDto extends PartialType(CreateBarnameDto) {}
|
export class UpdateBarnameDto extends PartialType(CreateBarnameDto) {}
|
||||||
@@ -23,11 +23,8 @@ export class Barname extends BaseEntity {
|
|||||||
@Property({ type: 'string' })
|
@Property({ type: 'string' })
|
||||||
driverPhone: string;
|
driverPhone: string;
|
||||||
|
|
||||||
@Property({ type: 'string' })
|
@Property({ type: 'string', nullable: true })
|
||||||
origin: string;
|
origin?: string;
|
||||||
|
|
||||||
@Property({ type: 'string' })
|
|
||||||
weight: string;
|
|
||||||
|
|
||||||
@Property({ type: 'string' })
|
@Property({ type: 'string' })
|
||||||
carType: string;
|
carType: string;
|
||||||
@@ -35,8 +32,8 @@ export class Barname extends BaseEntity {
|
|||||||
@Property({ type: 'string' })
|
@Property({ type: 'string' })
|
||||||
plaque: string;
|
plaque: string;
|
||||||
|
|
||||||
@Property({ type: 'string' })
|
@Property({ type: 'string', nullable: true })
|
||||||
description: string;
|
description?: string;
|
||||||
|
|
||||||
|
|
||||||
@Property({ type: 'json' })
|
@Property({ type: 'json' })
|
||||||
|
|||||||
Reference in New Issue
Block a user