|
|
@@ -26,14 +26,14 @@ export abstract class GenericCrudService<T extends ObjectLiteral> {
|
|
|
const skip = (page - 1) * pageSize;
|
|
|
const query = this.repository.createQueryBuilder('entity');
|
|
|
|
|
|
- // 添加关联关系(支持嵌套关联,如 ['contract', 'contract.client'])
|
|
|
+ // 添加关联关系(支持嵌套关联,如 ['contract.client'])
|
|
|
if (relations.length > 0) {
|
|
|
- relations.forEach(relation => {
|
|
|
+ relations.forEach((relation, relationIndex) => {
|
|
|
const parts = relation.split('.');
|
|
|
let currentAlias = 'entity';
|
|
|
|
|
|
parts.forEach((part, index) => {
|
|
|
- const newAlias = index === 0 ? part : `${currentAlias}_${part}`;
|
|
|
+ const newAlias = index === 0 ? part : `${currentAlias}_${relationIndex}`;
|
|
|
query.leftJoinAndSelect(`${currentAlias}.${part}`, newAlias);
|
|
|
currentAlias = newAlias;
|
|
|
});
|