feat: implement VehicleCategory entity and master data module support
This commit is contained in:
@@ -268,7 +268,9 @@ SELECT code, name, "tableName", description, "displayOrder", true FROM (VALUES
|
|||||||
('eligible-fare-type', 'Eligible Fare Type', 'tbl_eligible_fare_types', 'Eligible Fare Type master', 38),
|
('eligible-fare-type', 'Eligible Fare Type', 'tbl_eligible_fare_types', 'Eligible Fare Type master', 38),
|
||||||
('applicable-product', 'Applicable Product', 'tbl_applicable_products', 'Applicable Product master', 39),
|
('applicable-product', 'Applicable Product', 'tbl_applicable_products', 'Applicable Product master', 39),
|
||||||
('meal-type', 'Meal Type', 'tbl_meal_types', 'Meal Type master', 40),
|
('meal-type', 'Meal Type', 'tbl_meal_types', 'Meal Type master', 40),
|
||||||
('airport-restriction', 'Airport Restriction', 'tbl_airport_restrictions', 'Airport Restriction master', 41)
|
('airport-restriction', 'Airport Restriction', 'tbl_airport_restrictions', 'Airport Restriction master', 41),
|
||||||
|
('destination-type', 'Destination Type', 'tbl_destination_types', 'Destination Type master', 42),
|
||||||
|
('vehicle-category', 'Vehicle Category', 'tbl_vehicle_categories', 'Vehicle Category master', 43)
|
||||||
) AS t(code, name, "tableName", description, "displayOrder")
|
) AS t(code, name, "tableName", description, "displayOrder")
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_rules_categories WHERE masters.tbl_rules_categories.code = t.code);
|
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_rules_categories WHERE masters.tbl_rules_categories.code = t.code);
|
||||||
|
|
||||||
@@ -316,7 +318,9 @@ FROM (VALUES
|
|||||||
('eligible-fare-type', 'tbl_eligible_fare_types'),
|
('eligible-fare-type', 'tbl_eligible_fare_types'),
|
||||||
('applicable-product', 'tbl_applicable_products'),
|
('applicable-product', 'tbl_applicable_products'),
|
||||||
('meal-type', 'tbl_meal_types'),
|
('meal-type', 'tbl_meal_types'),
|
||||||
('airport-restriction', 'tbl_airport_restrictions')
|
('airport-restriction', 'tbl_airport_restrictions'),
|
||||||
|
('destination-type', 'tbl_destination_types'),
|
||||||
|
('vehicle-category', 'tbl_vehicle_categories')
|
||||||
) AS v(code, "tableName")
|
) AS v(code, "tableName")
|
||||||
WHERE c.code = v.code AND (c."tableName" IS NULL OR c."tableName" != v."tableName");
|
WHERE c.code = v.code AND (c."tableName" IS NULL OR c."tableName" != v."tableName");
|
||||||
|
|
||||||
@@ -714,3 +718,22 @@ SELECT label, value, true FROM (VALUES
|
|||||||
('Any Airport', 'any-airport')
|
('Any Airport', 'any-airport')
|
||||||
) AS t(label, value)
|
) AS t(label, value)
|
||||||
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_airport_restrictions WHERE masters.tbl_airport_restrictions.value = t.value);
|
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_airport_restrictions WHERE masters.tbl_airport_restrictions.value = t.value);
|
||||||
|
|
||||||
|
-- 45. Destination Types
|
||||||
|
INSERT INTO masters.tbl_destination_types (label, value, "isActive")
|
||||||
|
SELECT label, value, true FROM (VALUES
|
||||||
|
('Home', 'home'),
|
||||||
|
('Hotel', 'hotel'),
|
||||||
|
('Airport', 'airport'),
|
||||||
|
('City Center', 'city-center')
|
||||||
|
) AS t(label, value)
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_destination_types WHERE masters.tbl_destination_types.value = t.value);
|
||||||
|
|
||||||
|
-- 46. Vehicle Categories
|
||||||
|
INSERT INTO masters.tbl_vehicle_categories (label, value, "isActive")
|
||||||
|
SELECT label, value, true FROM (VALUES
|
||||||
|
('Executive Sedan', 'executive-sedan'),
|
||||||
|
('Luxury SUV', 'luxury-suv'),
|
||||||
|
('Premium Van', 'premium-van')
|
||||||
|
) AS t(label, value)
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM masters.tbl_vehicle_categories WHERE masters.tbl_vehicle_categories.value = t.value);
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import {
|
||||||
|
Entity,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
Column,
|
||||||
|
CreateDateColumn,
|
||||||
|
UpdateDateColumn,
|
||||||
|
} from 'typeorm';
|
||||||
|
|
||||||
|
@Entity({ name: 'tbl_vehicle_categories', schema: 'masters' })
|
||||||
|
export class VehicleCategory {
|
||||||
|
@PrimaryGeneratedColumn('uuid')
|
||||||
|
id!: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
label!: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
value!: string;
|
||||||
|
|
||||||
|
@Column({ default: true })
|
||||||
|
isActive!: boolean;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
createdAt!: Date;
|
||||||
|
|
||||||
|
@UpdateDateColumn()
|
||||||
|
updatedAt!: Date;
|
||||||
|
}
|
||||||
@@ -52,6 +52,7 @@ import { ApplicableProduct } from './entities/applicable-product.entity';
|
|||||||
import { MealType } from './entities/meal-type.entity';
|
import { MealType } from './entities/meal-type.entity';
|
||||||
import { AirportRestriction } from './entities/airport-restriction.entity';
|
import { AirportRestriction } from './entities/airport-restriction.entity';
|
||||||
import { DestinationType } from './entities/destination-type.entity';
|
import { DestinationType } from './entities/destination-type.entity';
|
||||||
|
import { VehicleCategory } from './entities/vehicle-category.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -104,6 +105,7 @@ import { DestinationType } from './entities/destination-type.entity';
|
|||||||
MealType,
|
MealType,
|
||||||
AirportRestriction,
|
AirportRestriction,
|
||||||
DestinationType,
|
DestinationType,
|
||||||
|
VehicleCategory,
|
||||||
]),
|
]),
|
||||||
],
|
],
|
||||||
controllers: [MasterDataController],
|
controllers: [MasterDataController],
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ import { ApplicableProduct } from './entities/applicable-product.entity';
|
|||||||
import { MealType } from './entities/meal-type.entity';
|
import { MealType } from './entities/meal-type.entity';
|
||||||
import { AirportRestriction } from './entities/airport-restriction.entity';
|
import { AirportRestriction } from './entities/airport-restriction.entity';
|
||||||
import { DestinationType } from './entities/destination-type.entity';
|
import { DestinationType } from './entities/destination-type.entity';
|
||||||
|
import { VehicleCategory } from './entities/vehicle-category.entity';
|
||||||
|
|
||||||
import { CreateActionCategoryDto } from './dto/create-action-category.dto';
|
import { CreateActionCategoryDto } from './dto/create-action-category.dto';
|
||||||
import { UpdateActionCategoryDto } from './dto/update-action-category.dto';
|
import { UpdateActionCategoryDto } from './dto/update-action-category.dto';
|
||||||
@@ -117,6 +118,7 @@ export class MasterDataService implements OnModuleInit {
|
|||||||
@InjectRepository(MealType) private mealTypeRepo: Repository<MealType>,
|
@InjectRepository(MealType) private mealTypeRepo: Repository<MealType>,
|
||||||
@InjectRepository(AirportRestriction) private airportRestrictionRepo: Repository<AirportRestriction>,
|
@InjectRepository(AirportRestriction) private airportRestrictionRepo: Repository<AirportRestriction>,
|
||||||
@InjectRepository(DestinationType) private destinationTypeRepo: Repository<DestinationType>,
|
@InjectRepository(DestinationType) private destinationTypeRepo: Repository<DestinationType>,
|
||||||
|
@InjectRepository(VehicleCategory) private vehicleCategoryRepo: Repository<VehicleCategory>,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
private getRepositoryByCategory(category: string): Repository<any> {
|
private getRepositoryByCategory(category: string): Repository<any> {
|
||||||
@@ -308,6 +310,11 @@ export class MasterDataService implements OnModuleInit {
|
|||||||
case 'TBL_DESTINATION_TYPES':
|
case 'TBL_DESTINATION_TYPES':
|
||||||
return this.destinationTypeRepo;
|
return this.destinationTypeRepo;
|
||||||
|
|
||||||
|
case 'VEHICLE_CATEGORY':
|
||||||
|
case 'VEHICLE_CATEGORIES':
|
||||||
|
case 'TBL_VEHICLE_CATEGORIES':
|
||||||
|
return this.vehicleCategoryRepo;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException(`Invalid category: ${category}`);
|
throw new BadRequestException(`Invalid category: ${category}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user