-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
T-12 Add product filtering ability: - Add Filter* models - Add fetch available filters error - Add get available filter route and ability - Add raw sql for available filter with product count - Add DTOFactory makeFilters func - Add product filtering ability
- Loading branch information
Showing
9 changed files
with
317 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
Sources/App/Models/NetworkModel/Product/Filter/FilterDBResponse.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// FilterDBResponse.swift | ||
// | ||
// | ||
// Created by Artem Mayer on 07.09.2024. | ||
// | ||
|
||
import Vapor | ||
|
||
struct FilterDBResponse: Content { | ||
|
||
let propertyCode: String | ||
let propertyName: String | ||
let propertyValue: String | ||
var count: Int | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case propertyCode = "property_code" | ||
case propertyName = "property_name" | ||
case propertyValue = "property_value" | ||
case count | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
Sources/App/Models/NetworkModel/Product/Filter/FilterDTO.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// FilterDTO.swift | ||
// | ||
// | ||
// Created by Artem Mayer on 07.09.2024. | ||
// | ||
|
||
import Vapor | ||
|
||
struct FilterDTO: Content { | ||
|
||
let name: String | ||
let displayName: String | ||
let type: FilterType | ||
let values: [FilterValueDTO] | ||
let defaultValue: String? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case name | ||
case displayName = "display_name" | ||
case type, values | ||
case defaultValue = "default_value" | ||
} | ||
|
||
init(name: String = "sort", | ||
displayName: String = "Сортировка", | ||
type: FilterType = .multiple, | ||
values: [FilterValueDTO], | ||
defaultValue: String? = nil) { | ||
|
||
self.name = name | ||
self.displayName = displayName | ||
self.type = type | ||
self.values = values | ||
self.defaultValue = defaultValue | ||
} | ||
|
||
} | ||
|
||
extension FilterDTO { | ||
|
||
static var getSortFilter: FilterDTO { | ||
FilterDTO(type: .single, values: FilterValueDTO.getSortValues, defaultValue: "index") | ||
} | ||
|
||
} |
Oops, something went wrong.