mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 00:00:27 +00:00
added nested query for QR codes, generateQRCodeURLs refactor
This commit is contained in:
parent
396160b0c8
commit
9f1e0746ef
1 changed files with 4 additions and 8 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
"fmt"
|
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
"github.com/hay-kot/homebox/backend/internal/core/services"
|
"github.com/hay-kot/homebox/backend/internal/core/services"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/repo"
|
"github.com/hay-kot/homebox/backend/internal/data/repo"
|
||||||
|
@ -113,8 +112,6 @@ func (ctrl *V1Controller) HandleGenerateQRCodeForLocations() errchain.HandlerFun
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(routeUUID)
|
|
||||||
|
|
||||||
auth := services.NewContext(r.Context())
|
auth := services.NewContext(r.Context())
|
||||||
locations, err := ctrl.repo.Locations.Get(auth, routeUUID) //get the location
|
locations, err := ctrl.repo.Locations.Get(auth, routeUUID) //get the location
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -122,20 +119,19 @@ func (ctrl *V1Controller) HandleGenerateQRCodeForLocations() errchain.HandlerFun
|
||||||
}
|
}
|
||||||
|
|
||||||
var URLs []string
|
var URLs []string
|
||||||
|
|
||||||
URLs, err = ctrl.generateQRCodeURLs(locations, URLs, data) //this will append URLS to the URLs slice based on config (data)
|
URLs, err = ctrl.generateQRCodeURLs(locations, URLs, data) //this will append URLS to the URLs slice based on config (data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
pdf, err := ctrl.generatePDF(URLs)
|
pdf, err := ctrl.generatePDF(URLs) //URLs to PDF
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Return the concatenated QR code images as a response
|
|
||||||
w.Header().Set("Content-Type", "application/pdf")
|
w.Header().Set("Content-Type", "application/pdf")
|
||||||
w.Header().Set("Content-Disposition", "attachment; filename=qrCodes.pdf")
|
w.Header().Set("Content-Disposition", "attachment; filename=qrCodes.pdf")
|
||||||
|
|
||||||
fmt.Printf("%v", URLs)
|
|
||||||
//_, err = w.Write([]byte(fmt.Sprintf("%v", URLs)))
|
|
||||||
_, err = pdf.WriteTo(w)
|
_, err = pdf.WriteTo(w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue