Align document handlers/repo with contract updates
This commit is contained in:
@@ -36,16 +36,13 @@ func NewDocumentHandler(documentService *services.DocumentService, storageServic
|
||||
func (h *DocumentHandler) ListDocuments(c echo.Context) error {
|
||||
user := c.Get(middleware.AuthUserKey).(*models.User)
|
||||
|
||||
// Build filter from query params (matching KMP DocumentApi parameters)
|
||||
// Build filter from supported query params.
|
||||
var filter *repositories.DocumentFilter
|
||||
if c.QueryParam("residence") != "" || c.QueryParam("document_type") != "" ||
|
||||
c.QueryParam("category") != "" || c.QueryParam("contractor") != "" ||
|
||||
c.QueryParam("is_active") != "" || c.QueryParam("expiring_soon") != "" ||
|
||||
c.QueryParam("tags") != "" || c.QueryParam("search") != "" {
|
||||
c.QueryParam("search") != "" {
|
||||
filter = &repositories.DocumentFilter{
|
||||
DocumentType: c.QueryParam("document_type"),
|
||||
Category: c.QueryParam("category"),
|
||||
Tags: c.QueryParam("tags"),
|
||||
Search: c.QueryParam("search"),
|
||||
}
|
||||
if rid := c.QueryParam("residence"); rid != "" {
|
||||
@@ -54,12 +51,6 @@ func (h *DocumentHandler) ListDocuments(c echo.Context) error {
|
||||
filter.ResidenceID = &residenceID
|
||||
}
|
||||
}
|
||||
if cid := c.QueryParam("contractor"); cid != "" {
|
||||
if parsed, err := strconv.ParseUint(cid, 10, 32); err == nil {
|
||||
contractorID := uint(parsed)
|
||||
filter.ContractorID = &contractorID
|
||||
}
|
||||
}
|
||||
if ia := c.QueryParam("is_active"); ia != "" {
|
||||
isActive := ia == "true" || ia == "1"
|
||||
filter.IsActive = &isActive
|
||||
|
||||
Reference in New Issue
Block a user