mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
feat: export input progress report for expenses, marketings, purchases, and recordings
This commit is contained in:
@@ -7,7 +7,9 @@ import (
|
||||
"mime/multipart"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/exportprogress"
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/modules/purchases/dto"
|
||||
service "gitlab.com/mbugroup/lti-api.git/internal/modules/purchases/services"
|
||||
validation "gitlab.com/mbugroup/lti-api.git/internal/modules/purchases/validations"
|
||||
@@ -27,6 +29,25 @@ func NewPurchaseController(s service.PurchaseService) *PurchaseController {
|
||||
}
|
||||
|
||||
func (ctrl *PurchaseController) GetAll(c *fiber.Ctx) error {
|
||||
if exportprogress.IsProgressExportRequest(c) {
|
||||
query, err := exportprogress.ParseQuery(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rows, err := ctrl.service.GetProgressRows(c, query)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
content, err := exportprogress.BuildWorkbook("Purchases", query, rows)
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, "failed to generate progress excel file")
|
||||
}
|
||||
filename := fmt.Sprintf("purchases_progress_%s.xlsx", time.Now().Format("20060102_150405"))
|
||||
c.Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
c.Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, filename))
|
||||
return c.Status(fiber.StatusOK).Send(content)
|
||||
}
|
||||
|
||||
query := &validation.Query{
|
||||
Page: c.QueryInt("page", 1),
|
||||
Limit: c.QueryInt("limit", 10),
|
||||
|
||||
Reference in New Issue
Block a user