|
|
@@ -6,4 +6,31 @@ export class HetongService extends GenericCrudService<Hetong> {
|
|
|
constructor(dataSource: DataSource) {
|
|
|
super(dataSource, Hetong);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 重写getList方法,支持关联查询客户信息
|
|
|
+ */
|
|
|
+ async getList(
|
|
|
+ page: number = 1,
|
|
|
+ pageSize: number = 10,
|
|
|
+ keyword?: string,
|
|
|
+ searchFields?: string[],
|
|
|
+ where: Partial<Hetong> = {},
|
|
|
+ relations: string[] = ['client'], // 默认关联查询客户信息
|
|
|
+ order: { [P in keyof Hetong]?: 'ASC' | 'DESC' } = {}
|
|
|
+ ): Promise<[Hetong[], number]> {
|
|
|
+ return super.getList(page, pageSize, keyword, searchFields, where, relations, order);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据客户ID查询合同列表
|
|
|
+ * @param clientId 客户ID
|
|
|
+ * @returns 合同列表
|
|
|
+ */
|
|
|
+ async findByClientId(clientId: number): Promise<Hetong[]> {
|
|
|
+ return this.repository.find({
|
|
|
+ where: { clientId },
|
|
|
+ relations: ['client'], // 关联查询客户信息
|
|
|
+ order: { createdAt: 'DESC' }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|