feat: implement MasterDataService with comprehensive entity repositories for application reference data
This commit is contained in:
@@ -437,7 +437,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
|
||||
const repo = this.getRepositoryByCategory(category);
|
||||
return repo.find({
|
||||
where: { isActive: true },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -471,7 +470,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
|
||||
async findAllRuleCategories(): Promise<RuleCategory[]> {
|
||||
return this.ruleCategoryRepo.find({
|
||||
where: { isActive: true },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
}
|
||||
@@ -586,7 +584,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
}
|
||||
|
||||
const items = await repo.find({
|
||||
where: { isActive: true },
|
||||
});
|
||||
|
||||
return items.map((item) => ({
|
||||
@@ -614,7 +611,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
|
||||
if (!category) {
|
||||
return this.conditionGroupRepo.find({
|
||||
where: { isActive: true },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
}
|
||||
@@ -626,20 +622,19 @@ export class MasterDataService implements OnModuleInit {
|
||||
|
||||
const groups = mappings
|
||||
.map((m) => m.conditionGroup)
|
||||
.filter((g) => g && g.isActive)
|
||||
.filter((g) => g)
|
||||
.sort((a, b) => (a.displayOrder || 0) - (b.displayOrder || 0));
|
||||
|
||||
return groups.length > 0
|
||||
? groups
|
||||
: this.conditionGroupRepo.find({
|
||||
where: { isActive: true },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
}
|
||||
|
||||
async findConditionFieldsByGroup(groupIdOrCode: string): Promise<ConditionField[]> {
|
||||
let group = await this.conditionGroupRepo.findOne({
|
||||
where: { code: groupIdOrCode, isActive: true },
|
||||
where: { code: groupIdOrCode },
|
||||
});
|
||||
|
||||
if (!group && groupIdOrCode) {
|
||||
@@ -653,7 +648,7 @@ export class MasterDataService implements OnModuleInit {
|
||||
}
|
||||
|
||||
return this.conditionFieldRepo.find({
|
||||
where: { groupId: group.id, isActive: true },
|
||||
where: { groupId: group.id },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
}
|
||||
@@ -678,7 +673,7 @@ export class MasterDataService implements OnModuleInit {
|
||||
}
|
||||
|
||||
const repo = this.getRepositoryByCategory(field.lookupTable);
|
||||
const items = await repo.find({ where: { isActive: true } });
|
||||
const items = await repo.find();
|
||||
return items.map((item) => ({
|
||||
id: item.id,
|
||||
code: item.value || item.code,
|
||||
@@ -691,7 +686,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
|
||||
async findAllOperators(): Promise<Operator[]> {
|
||||
return this.operatorRepo.find({
|
||||
where: { isActive: true },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
}
|
||||
@@ -725,7 +719,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
if (page !== undefined && limit !== undefined) {
|
||||
const skip = (page - 1) * limit;
|
||||
const [data, total] = await this.actionCategoryRepo.findAndCount({
|
||||
where: { isActive: true },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
skip,
|
||||
take: limit,
|
||||
@@ -739,7 +732,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
};
|
||||
}
|
||||
return this.actionCategoryRepo.find({
|
||||
where: { isActive: true },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
}
|
||||
@@ -773,7 +765,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
if (page !== undefined && limit !== undefined) {
|
||||
const skip = (page - 1) * limit;
|
||||
const [data, total] = await this.actionTypeRepo.findAndCount({
|
||||
where: { isActive: true },
|
||||
relations: { category: true },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
skip,
|
||||
@@ -788,7 +779,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
};
|
||||
}
|
||||
return this.actionTypeRepo.find({
|
||||
where: { isActive: true },
|
||||
relations: { category: true },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
@@ -801,14 +791,14 @@ export class MasterDataService implements OnModuleInit {
|
||||
return this.findActionTypesByCategoryId(categoryCode);
|
||||
}
|
||||
return this.actionTypeRepo.find({
|
||||
where: { categoryId: category.id, isActive: true },
|
||||
where: { categoryId: category.id },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
}
|
||||
|
||||
async findActionTypesByCategoryId(categoryId: string): Promise<ActionType[]> {
|
||||
return this.actionTypeRepo.find({
|
||||
where: { categoryId, isActive: true },
|
||||
where: { categoryId },
|
||||
order: { displayOrder: 'ASC', name: 'ASC' },
|
||||
});
|
||||
}
|
||||
@@ -849,7 +839,7 @@ export class MasterDataService implements OnModuleInit {
|
||||
}
|
||||
|
||||
const fields = await this.fieldDefinitionRepo.find({
|
||||
where: { actionTypeId: actionType.id, isActive: true },
|
||||
where: { actionTypeId: actionType.id },
|
||||
order: { displayOrder: 'ASC' },
|
||||
});
|
||||
|
||||
@@ -917,7 +907,6 @@ export class MasterDataService implements OnModuleInit {
|
||||
// --- Field Definitions Management ---
|
||||
async findAllFieldDefinitions(): Promise<FieldDefinition[]> {
|
||||
return this.fieldDefinitionRepo.find({
|
||||
where: { isActive: true },
|
||||
relations: { actionType: true },
|
||||
order: { displayOrder: 'ASC' },
|
||||
});
|
||||
@@ -925,7 +914,7 @@ export class MasterDataService implements OnModuleInit {
|
||||
|
||||
async findFieldsByActionType(actionTypeId: string): Promise<FieldDefinition[]> {
|
||||
return this.fieldDefinitionRepo.find({
|
||||
where: { actionTypeId, isActive: true },
|
||||
where: { actionTypeId },
|
||||
order: { displayOrder: 'ASC' },
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user