diff --git a/bruno/Common Cents/Categories/LOC GET Categories.bru b/bruno/Common Cents/Categories/LOC GET Categories.bru index 54aee7f..8d46826 100644 --- a/bruno/Common Cents/Categories/LOC GET Categories.bru +++ b/bruno/Common Cents/Categories/LOC GET Categories.bru @@ -5,11 +5,7 @@ meta { } get { - url: {{localBaseUrl}}/{{resourcePath}}?sort=desc + url: {{localBaseUrl}}/{{resourcePath}} body: none auth: inherit } - -params:query { - sort: desc -} diff --git a/bruno/Common Cents/Merchants/LOC GET Merchants.bru b/bruno/Common Cents/Merchants/LOC GET Merchants.bru index bd061db..5ba79b7 100644 --- a/bruno/Common Cents/Merchants/LOC GET Merchants.bru +++ b/bruno/Common Cents/Merchants/LOC GET Merchants.bru @@ -5,11 +5,7 @@ meta { } get { - url: {{localBaseUrl}}/{{resourcePath}}?sort=desc + url: {{localBaseUrl}}/{{resourcePath}} body: none auth: inherit } - -params:query { - sort: desc -} diff --git a/bruno/Common Cents/Tags/LOC GET Tags.bru b/bruno/Common Cents/Tags/LOC GET Tags.bru index 65caa02..dc19694 100644 --- a/bruno/Common Cents/Tags/LOC GET Tags.bru +++ b/bruno/Common Cents/Tags/LOC GET Tags.bru @@ -9,7 +9,3 @@ get { body: none auth: inherit } - -params:query { - ~tags: Tundra -} diff --git a/src/categories/categories.controller.ts b/src/categories/categories.controller.ts index d8a8775..878f76c 100644 --- a/src/categories/categories.controller.ts +++ b/src/categories/categories.controller.ts @@ -6,7 +6,6 @@ import { Delete, Body, Param, - Query, HttpCode, HttpStatus, BadRequestException, @@ -24,12 +23,8 @@ export class CategoriesController { @Get() @HttpCode(HttpStatus.OK) - public async find(@Query() filters: GetCategoryFilters): Promise { - const ids = Array.isArray(filters.ids) ? filters.ids : filters.ids ? [filters.ids] : []; - const categories = Array.isArray(filters.categories) ? filters.categories : filters.categories ? [filters.categories] : []; - const sort = filters.sort?.toLowerCase() === 'desc' ? 'desc' : 'asc'; - - return await this.categoriesService.find({ ids, categories, sort}); + public async findAll(): Promise { + return await this.categoriesService.findAll(); } @Get(':id') @@ -78,9 +73,3 @@ export class CategoriesController { return await this.categoriesService.remove(id); } } - -export interface GetCategoryFilters { - ids?: string[]; - categories?: string[]; - sort?: 'asc' | 'desc'; -} diff --git a/src/categories/categories.service.ts b/src/categories/categories.service.ts index ee93b0a..8753b43 100644 --- a/src/categories/categories.service.ts +++ b/src/categories/categories.service.ts @@ -3,14 +3,13 @@ import { CreateCategoryDto } from './dto/create-category.dto'; import { UpdateCategoryDto } from './dto/update-category.dto'; import { CategoryDataService } from './category-data.service'; import { Category } from './entities/category.entity'; -import { GetCategoryFilters } from './categories.controller'; @Injectable() export class CategoriesService { public constructor(private categoryDataService: CategoryDataService) { } - public async find(filters: GetCategoryFilters): Promise { - return await this.categoryDataService.get(filters); + public async findAll(): Promise { + return await this.categoryDataService.getAll(); } public async findById(id: string): Promise { diff --git a/src/categories/category-data.service.ts b/src/categories/category-data.service.ts index 7277274..455bac4 100644 --- a/src/categories/category-data.service.ts +++ b/src/categories/category-data.service.ts @@ -1,8 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { DataSource, ILike, Repository } from 'typeorm'; +import { DataSource, Repository } from 'typeorm'; import { Category } from './entities/category.entity'; import { UpdateCategoryDto } from './dto/update-category.dto'; -import { GetCategoryFilters } from './categories.controller'; @Injectable() export class CategoryDataService { @@ -12,14 +11,8 @@ export class CategoryDataService { this.categories = this.dataSource.getRepository(Category); } - public async get(filters: GetCategoryFilters): Promise { - const idFilters = filters.ids?.map(id => { return { id }}) ?? []; - const nameFilters = filters.categories?.map(tag => { return { name: ILike('%' + tag + '%') }}) ?? []; - - return await this.categories.find({ - where: [...idFilters, ...nameFilters], - order: { name: filters.sort === 'desc' ? 'desc' : 'asc' } - }); + public async getAll(): Promise { + return await this.categories.find(); } public async getById(id: string): Promise { diff --git a/src/merchants/merchant-data.service.ts b/src/merchants/merchant-data.service.ts index 23f8ee8..efbb956 100644 --- a/src/merchants/merchant-data.service.ts +++ b/src/merchants/merchant-data.service.ts @@ -1,8 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { DataSource, ILike, Repository } from 'typeorm'; +import { DataSource, Repository } from 'typeorm'; import { Merchant } from './entities/merchant.entity'; import { UpdateMerchantDto } from './dto/update-merchant.dto'; -import { GetMerchantFilters } from './merchants.controller'; @Injectable() export class MerchantDataService { @@ -12,14 +11,8 @@ export class MerchantDataService { this.merchants = this.dataSource.getRepository(Merchant); } - public async get(filters: GetMerchantFilters): Promise { - const idFilters = filters.ids?.map(id => { return { id }}) ?? []; - const nameFilters = filters.merchants?.map(tag => { return { name: ILike('%' + tag + '%') }}) ?? []; - - return await this.merchants.find({ - where: [...idFilters, ...nameFilters], - order: { name: filters.sort === 'desc' ? 'desc' : 'asc' } - }); + public async getAll(): Promise { + return await this.merchants.find(); } public async getById(id: string): Promise { diff --git a/src/merchants/merchants.controller.ts b/src/merchants/merchants.controller.ts index 2cff37d..97a7ac3 100644 --- a/src/merchants/merchants.controller.ts +++ b/src/merchants/merchants.controller.ts @@ -6,7 +6,6 @@ import { Delete, Body, Param, - Query, HttpCode, HttpStatus, NotFoundException, @@ -24,12 +23,8 @@ export class MerchantsController { @Get() @HttpCode(HttpStatus.OK) - public async find(@Query() filters: GetMerchantFilters): Promise { - const ids = Array.isArray(filters.ids) ? filters.ids : filters.ids ? [filters.ids] : []; - const merchants = Array.isArray(filters.merchants) ? filters.merchants : filters.merchants ? [filters.merchants] : []; - const sort = filters.sort?.toLowerCase() === 'desc' ? 'desc' : 'asc'; - - return await this.merchantsService.find({ ids, merchants, sort }); + public async findAll(): Promise { + return await this.merchantsService.findAll(); } @Get(':id') @@ -78,9 +73,3 @@ export class MerchantsController { return await this.merchantsService.remove(id); } } - -export interface GetMerchantFilters { - ids?: string[]; - merchants?: string[]; - sort?: 'asc' | 'desc'; -} diff --git a/src/merchants/merchants.service.ts b/src/merchants/merchants.service.ts index 56a5d84..ef98690 100644 --- a/src/merchants/merchants.service.ts +++ b/src/merchants/merchants.service.ts @@ -3,14 +3,13 @@ import { CreateMerchantDto } from './dto/create-merchant.dto'; import { UpdateMerchantDto } from './dto/update-merchant.dto'; import { MerchantDataService } from './merchant-data.service'; import { Merchant } from './entities/merchant.entity'; -import { GetMerchantFilters } from './merchants.controller'; @Injectable() export class MerchantsService { public constructor(private merchantDataService: MerchantDataService) { } - public async find(filters: GetMerchantFilters): Promise { - return await this.merchantDataService.get(filters); + public async findAll(): Promise { + return await this.merchantDataService.getAll(); } public async findById(id: string): Promise { diff --git a/src/tags/tag-data.service.ts b/src/tags/tag-data.service.ts index c9b0137..df417c5 100644 --- a/src/tags/tag-data.service.ts +++ b/src/tags/tag-data.service.ts @@ -1,8 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { DataSource, ILike, Repository } from 'typeorm'; +import { DataSource, Repository } from 'typeorm'; import { Tag } from './entities/tag.entity'; import { UpdateTagDto } from './dto/update-tag.dto'; -import { GetTagFilters } from './tags.controller'; @Injectable() export class TagDataService { @@ -12,14 +11,8 @@ export class TagDataService { this.tags = this.dataSource.getRepository(Tag); } - public async get(filters: GetTagFilters): Promise { - const idFilters = filters.ids?.map(id => { return { id }}) ?? []; - const nameFilters = filters.tags?.map(tag => { return { name: ILike('%' + tag + '%') }}) ?? []; - - return await this.tags.find({ - where: [...idFilters, ...nameFilters], - order: { name: filters.sort === 'desc' ? 'desc' : 'asc' } - }); + public async getAll(): Promise { + return await this.tags.find(); } public async getById(id: string): Promise { diff --git a/src/tags/tags.controller.ts b/src/tags/tags.controller.ts index b27e5fa..d627f8e 100644 --- a/src/tags/tags.controller.ts +++ b/src/tags/tags.controller.ts @@ -6,7 +6,6 @@ import { Delete, Body, Param, - Query, HttpCode, HttpStatus, BadRequestException, @@ -24,12 +23,8 @@ export class TagsController { @Get() @HttpCode(HttpStatus.OK) - public async find(@Query() filters: GetTagFilters): Promise { - const ids = Array.isArray(filters.ids) ? filters.ids : filters.ids ? [filters.ids] : []; - const tags = Array.isArray(filters.tags) ? filters.tags : filters.tags ? [filters.tags] : []; - const sort = filters.sort?.toLowerCase() === 'desc' ? 'desc' : 'asc'; - - return await this.tagsService.find({ ids, tags, sort }); + public async findAll(): Promise { + return await this.tagsService.findAll(); } @Get(':id') @@ -78,9 +73,3 @@ export class TagsController { return await this.tagsService.remove(id); } } - -export interface GetTagFilters { - ids?: string[]; - tags?: string[]; - sort?: 'asc' | 'desc'; -} diff --git a/src/tags/tags.service.ts b/src/tags/tags.service.ts index 954dbb2..ab5ff92 100644 --- a/src/tags/tags.service.ts +++ b/src/tags/tags.service.ts @@ -3,14 +3,13 @@ import { CreateTagDto } from './dto/create-tag.dto'; import { UpdateTagDto } from './dto/update-tag.dto'; import { TagDataService } from './tag-data.service'; import { Tag } from './entities/tag.entity'; -import { GetTagFilters } from './tags.controller'; @Injectable() export class TagsService { public constructor(private tagDataService: TagDataService) { } - public async find(filters: GetTagFilters): Promise { - return await this.tagDataService.get(filters); + public async findAll(): Promise { + return await this.tagDataService.getAll(); } public async findById(id: string): Promise {