add restuarant to contact entity

This commit is contained in:
2026-01-06 23:08:58 +03:30
parent 69dedaa981
commit 9fe2321c9b
7 changed files with 239 additions and 158 deletions
@@ -12,7 +12,8 @@ type FindContactsOpts = {
orderBy?: string;
order?: 'asc' | 'desc';
status?: ContactStatusEnum;
scope?: ContactScope
scope?: ContactScope;
restaurantId?: string;
};
@Injectable()
@@ -26,7 +27,7 @@ export class ContactRepository extends EntityRepository<Contact> {
* Supports: search (subject/content/phone), status, ordering.
*/
async findAllPaginated(opts: FindContactsOpts = {}): Promise<PaginatedResult<Contact>> {
const { page = 1, limit = 10, search, scope, orderBy = 'createdAt', order = 'desc', status } = opts;
const { page = 1, limit = 10, search, scope, orderBy = 'createdAt', order = 'desc', status, restaurantId } = opts;
const offset = (page - 1) * limit;
@@ -38,6 +39,9 @@ export class ContactRepository extends EntityRepository<Contact> {
if (scope) {
where.scope = scope;
}
if (restaurantId) {
where.restaurant = restaurantId;
}
if (search) {
const pattern = `%${search}%`;