fix : fixing update products, banner, sales_agents
This commit is contained in:
parent
1bef2a45e5
commit
bb53b92cc1
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
utilRes "jaecoo-be/utils/response"
|
utilRes "jaecoo-be/utils/response"
|
||||||
utilVal "jaecoo-be/utils/validator"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type bannersController struct {
|
type bannersController struct {
|
||||||
|
|
@ -171,12 +170,17 @@ func (_i *bannersController) Save(c *fiber.Ctx) error {
|
||||||
|
|
||||||
// Update Banner
|
// Update Banner
|
||||||
// @Summary Update Banner
|
// @Summary Update Banner
|
||||||
// @Description API for updating Banner
|
// @Description API for updating Banner with file upload
|
||||||
// @Tags Banners
|
// @Tags Banners
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
// @Param X-Client-Key header string true "Insert the X-Client-Key"
|
// @Param X-Client-Key header string true "Insert the X-Client-Key"
|
||||||
// @Param id path int true "Banner ID"
|
// @Param id path int true "Banner ID"
|
||||||
// @Param payload body request.BannersUpdateRequest true "Required payload"
|
// @Param file formData file false "Upload file"
|
||||||
|
// @Param title formData string false "Banner title"
|
||||||
|
// @Param description formData string false "Banner description"
|
||||||
|
// @Param position formData string false "Banner position"
|
||||||
|
// @Param status formData string false "Banner status"
|
||||||
|
// @Param is_active formData bool false "Banner is_active"
|
||||||
// @Success 200 {object} response.Response
|
// @Success 200 {object} response.Response
|
||||||
// @Failure 400 {object} response.BadRequestError
|
// @Failure 400 {object} response.BadRequestError
|
||||||
// @Failure 401 {object} response.UnauthorizedError
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
|
@ -188,12 +192,45 @@ func (_i *bannersController) Update(c *fiber.Ctx) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
req := new(request.BannersUpdateRequest)
|
// Parse multipart form
|
||||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
form, err := c.MultipartForm()
|
||||||
return err
|
if err != nil {
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: false,
|
||||||
|
Messages: utilRes.Messages{"Failed to parse form data"},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
dataResult, err := _i.bannersService.Update(uint(id), *req)
|
// Extract form values
|
||||||
|
req := request.BannersUpdateRequest{}
|
||||||
|
|
||||||
|
if title := c.FormValue("title"); title != "" {
|
||||||
|
req.Title = &title
|
||||||
|
}
|
||||||
|
|
||||||
|
if description := c.FormValue("description"); description != "" {
|
||||||
|
req.Description = &description
|
||||||
|
}
|
||||||
|
|
||||||
|
if position := c.FormValue("position"); position != "" {
|
||||||
|
req.Position = &position
|
||||||
|
}
|
||||||
|
|
||||||
|
if status := c.FormValue("status"); status != "" {
|
||||||
|
req.Status = &status
|
||||||
|
}
|
||||||
|
|
||||||
|
if isActiveStr := c.FormValue("is_active"); isActiveStr != "" {
|
||||||
|
isActive := isActiveStr == "true" || isActiveStr == "1"
|
||||||
|
req.IsActive = &isActive
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if file is uploaded
|
||||||
|
if len(form.File["file"]) > 0 {
|
||||||
|
// File will be handled in service
|
||||||
|
}
|
||||||
|
|
||||||
|
dataResult, err := _i.bannersService.Update(c, uint(id), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ type BannersService interface {
|
||||||
GetAll(req request.BannersQueryRequest) (banners []*response.BannersResponse, paging paginator.Pagination, err error)
|
GetAll(req request.BannersQueryRequest) (banners []*response.BannersResponse, paging paginator.Pagination, err error)
|
||||||
GetOne(id uint) (banner *response.BannersResponse, err error)
|
GetOne(id uint) (banner *response.BannersResponse, err error)
|
||||||
Create(c *fiber.Ctx, req request.BannersCreateRequest) (banner *response.BannersResponse, err error)
|
Create(c *fiber.Ctx, req request.BannersCreateRequest) (banner *response.BannersResponse, err error)
|
||||||
Update(id uint, req request.BannersUpdateRequest) (banner *response.BannersResponse, err error)
|
Update(c *fiber.Ctx, id uint, req request.BannersUpdateRequest) (banner *response.BannersResponse, err error)
|
||||||
Delete(id uint) (err error)
|
Delete(id uint) (err error)
|
||||||
UploadFileToMinio(c *fiber.Ctx, fileKey string) (filePath *string, err error)
|
UploadFileToMinio(c *fiber.Ctx, fileKey string) (filePath *string, err error)
|
||||||
Viewer(c *fiber.Ctx) (err error)
|
Viewer(c *fiber.Ctx) (err error)
|
||||||
|
|
@ -168,7 +168,12 @@ func (_i *bannersService) UploadFileToMinio(c *fiber.Ctx, fileKey string) (fileP
|
||||||
return &objectName, nil
|
return &objectName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *bannersService) Update(id uint, req request.BannersUpdateRequest) (banner *response.BannersResponse, err error) {
|
func (_i *bannersService) Update(c *fiber.Ctx, id uint, req request.BannersUpdateRequest) (banner *response.BannersResponse, err error) {
|
||||||
|
// Handle file upload if exists
|
||||||
|
if filePath, uploadErr := _i.UploadFileToMinio(c, "file"); uploadErr == nil && filePath != nil {
|
||||||
|
req.ThumbnailPath = filePath
|
||||||
|
}
|
||||||
|
|
||||||
bannerEntity := req.ToEntity()
|
bannerEntity := req.ToEntity()
|
||||||
|
|
||||||
err = _i.Repo.Update(id, bannerEntity)
|
err = _i.Repo.Update(id, bannerEntity)
|
||||||
|
|
|
||||||
|
|
@ -175,12 +175,17 @@ func (_i *productsController) Save(c *fiber.Ctx) error {
|
||||||
|
|
||||||
// Update Product
|
// Update Product
|
||||||
// @Summary Update Product
|
// @Summary Update Product
|
||||||
// @Description API for updating Product
|
// @Description API for updating Product with file upload
|
||||||
// @Tags Products
|
// @Tags Products
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
// @Param X-Client-Key header string true "Insert the X-Client-Key"
|
// @Param X-Client-Key header string true "Insert the X-Client-Key"
|
||||||
// @Param id path int true "Product ID"
|
// @Param id path int true "Product ID"
|
||||||
// @Param payload body request.ProductsUpdateRequest true "Required payload"
|
// @Param file formData file false "Upload file"
|
||||||
|
// @Param title formData string false "Product title"
|
||||||
|
// @Param variant formData string false "Product variant"
|
||||||
|
// @Param price formData string false "Product price"
|
||||||
|
// @Param colors formData string false "Product colors (JSON array)"
|
||||||
|
// @Param is_active formData bool false "Product is_active"
|
||||||
// @Success 200 {object} response.Response
|
// @Success 200 {object} response.Response
|
||||||
// @Failure 400 {object} response.BadRequestError
|
// @Failure 400 {object} response.BadRequestError
|
||||||
// @Failure 401 {object} response.UnauthorizedError
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
|
@ -192,12 +197,49 @@ func (_i *productsController) Update(c *fiber.Ctx) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
req := new(request.ProductsUpdateRequest)
|
// Parse multipart form
|
||||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
form, err := c.MultipartForm()
|
||||||
return err
|
if err != nil {
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: false,
|
||||||
|
Messages: utilRes.Messages{"Failed to parse form data"},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
dataResult, err := _i.productsService.Update(uint(id), *req)
|
// Extract form values
|
||||||
|
req := request.ProductsUpdateRequest{}
|
||||||
|
|
||||||
|
if title := c.FormValue("title"); title != "" {
|
||||||
|
req.Title = &title
|
||||||
|
}
|
||||||
|
|
||||||
|
if variant := c.FormValue("variant"); variant != "" {
|
||||||
|
req.Variant = &variant
|
||||||
|
}
|
||||||
|
|
||||||
|
if price := c.FormValue("price"); price != "" {
|
||||||
|
req.Price = &price
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle colors (JSON array string)
|
||||||
|
if colorsStr := c.FormValue("colors"); colorsStr != "" {
|
||||||
|
var colors []string
|
||||||
|
if err := json.Unmarshal([]byte(colorsStr), &colors); err == nil {
|
||||||
|
req.Colors = colors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if isActiveStr := c.FormValue("is_active"); isActiveStr != "" {
|
||||||
|
isActive := isActiveStr == "true" || isActiveStr == "1"
|
||||||
|
req.IsActive = &isActive
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if file is uploaded
|
||||||
|
if len(form.File["file"]) > 0 {
|
||||||
|
// File will be handled in service
|
||||||
|
}
|
||||||
|
|
||||||
|
dataResult, err := _i.productsService.Update(c, uint(id), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ type ProductsService interface {
|
||||||
GetAll(req request.ProductsQueryRequest) (products []*response.ProductsResponse, paging paginator.Pagination, err error)
|
GetAll(req request.ProductsQueryRequest) (products []*response.ProductsResponse, paging paginator.Pagination, err error)
|
||||||
GetOne(id uint) (product *response.ProductsResponse, err error)
|
GetOne(id uint) (product *response.ProductsResponse, err error)
|
||||||
Create(c *fiber.Ctx, req request.ProductsCreateRequest) (product *response.ProductsResponse, err error)
|
Create(c *fiber.Ctx, req request.ProductsCreateRequest) (product *response.ProductsResponse, err error)
|
||||||
Update(id uint, req request.ProductsUpdateRequest) (product *response.ProductsResponse, err error)
|
Update(c *fiber.Ctx, id uint, req request.ProductsUpdateRequest) (product *response.ProductsResponse, err error)
|
||||||
Delete(id uint) (err error)
|
Delete(id uint) (err error)
|
||||||
UploadFileToMinio(c *fiber.Ctx, fileKey string) (filePath *string, err error)
|
UploadFileToMinio(c *fiber.Ctx, fileKey string) (filePath *string, err error)
|
||||||
Viewer(c *fiber.Ctx) (err error)
|
Viewer(c *fiber.Ctx) (err error)
|
||||||
|
|
@ -168,7 +168,12 @@ func (_i *productsService) UploadFileToMinio(c *fiber.Ctx, fileKey string) (file
|
||||||
return &objectName, nil
|
return &objectName, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *productsService) Update(id uint, req request.ProductsUpdateRequest) (product *response.ProductsResponse, err error) {
|
func (_i *productsService) Update(c *fiber.Ctx, id uint, req request.ProductsUpdateRequest) (product *response.ProductsResponse, err error) {
|
||||||
|
// Handle file upload if exists
|
||||||
|
if filePath, uploadErr := _i.UploadFileToMinio(c, "file"); uploadErr == nil && filePath != nil {
|
||||||
|
req.ThumbnailPath = filePath
|
||||||
|
}
|
||||||
|
|
||||||
productEntity := req.ToEntity()
|
productEntity := req.ToEntity()
|
||||||
|
|
||||||
err = _i.Repo.Update(id, productEntity)
|
err = _i.Repo.Update(id, productEntity)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"jaecoo-be/app/module/sales_agents/request"
|
"jaecoo-be/app/module/sales_agents/request"
|
||||||
"jaecoo-be/app/module/sales_agents/service"
|
"jaecoo-be/app/module/sales_agents/service"
|
||||||
"jaecoo-be/utils/paginator"
|
"jaecoo-be/utils/paginator"
|
||||||
|
|
@ -9,7 +10,6 @@ import (
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
utilRes "jaecoo-be/utils/response"
|
utilRes "jaecoo-be/utils/response"
|
||||||
utilVal "jaecoo-be/utils/validator"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type salesAgentsController struct {
|
type salesAgentsController struct {
|
||||||
|
|
@ -102,23 +102,65 @@ func (_i *salesAgentsController) Show(c *fiber.Ctx) error {
|
||||||
|
|
||||||
// Save SalesAgent
|
// Save SalesAgent
|
||||||
// @Summary Create SalesAgent
|
// @Summary Create SalesAgent
|
||||||
// @Description API for creating SalesAgent
|
// @Description API for creating SalesAgent with file upload
|
||||||
// @Tags SalesAgents
|
// @Tags SalesAgents
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
// @Param X-Client-Key header string true "Insert the X-Client-Key"
|
// @Param X-Client-Key header string true "Insert the X-Client-Key"
|
||||||
// @Param payload body request.SalesAgentsCreateRequest true "Required payload"
|
// @Param file formData file false "Upload file"
|
||||||
|
// @Param name formData string true "SalesAgent name"
|
||||||
|
// @Param job_title formData string false "SalesAgent job title"
|
||||||
|
// @Param phone formData string false "SalesAgent phone"
|
||||||
|
// @Param agent_type formData string false "SalesAgent agent type (JSON array)"
|
||||||
// @Success 200 {object} response.Response
|
// @Success 200 {object} response.Response
|
||||||
// @Failure 400 {object} response.BadRequestError
|
// @Failure 400 {object} response.BadRequestError
|
||||||
// @Failure 401 {object} response.UnauthorizedError
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
// @Failure 500 {object} response.InternalServerError
|
// @Failure 500 {object} response.InternalServerError
|
||||||
// @Router /sales-agents [post]
|
// @Router /sales-agents [post]
|
||||||
func (_i *salesAgentsController) Save(c *fiber.Ctx) error {
|
func (_i *salesAgentsController) Save(c *fiber.Ctx) error {
|
||||||
req := new(request.SalesAgentsCreateRequest)
|
// Parse multipart form
|
||||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
form, err := c.MultipartForm()
|
||||||
return err
|
if err != nil {
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: false,
|
||||||
|
Messages: utilRes.Messages{"Failed to parse form data"},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
dataResult, err := _i.salesAgentsService.Create(*req)
|
// Extract form values
|
||||||
|
req := request.SalesAgentsCreateRequest{
|
||||||
|
Name: c.FormValue("name"),
|
||||||
|
}
|
||||||
|
|
||||||
|
if jobTitle := c.FormValue("job_title"); jobTitle != "" {
|
||||||
|
req.JobTitle = &jobTitle
|
||||||
|
}
|
||||||
|
|
||||||
|
if phone := c.FormValue("phone"); phone != "" {
|
||||||
|
req.Phone = &phone
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle agent_type (JSON array string)
|
||||||
|
if agentTypeStr := c.FormValue("agent_type"); agentTypeStr != "" {
|
||||||
|
var agentType []string
|
||||||
|
if err := json.Unmarshal([]byte(agentTypeStr), &agentType); err == nil {
|
||||||
|
req.AgentType = agentType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate required fields
|
||||||
|
if req.Name == "" {
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: false,
|
||||||
|
Messages: utilRes.Messages{"Name is required"},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if file is uploaded
|
||||||
|
if len(form.File["file"]) > 0 {
|
||||||
|
// File will be handled in service
|
||||||
|
}
|
||||||
|
|
||||||
|
dataResult, err := _i.salesAgentsService.Create(c, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -132,12 +174,17 @@ func (_i *salesAgentsController) Save(c *fiber.Ctx) error {
|
||||||
|
|
||||||
// Update SalesAgent
|
// Update SalesAgent
|
||||||
// @Summary Update SalesAgent
|
// @Summary Update SalesAgent
|
||||||
// @Description API for updating SalesAgent
|
// @Description API for updating SalesAgent with file upload
|
||||||
// @Tags SalesAgents
|
// @Tags SalesAgents
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
// @Param X-Client-Key header string true "Insert the X-Client-Key"
|
// @Param X-Client-Key header string true "Insert the X-Client-Key"
|
||||||
// @Param id path int true "SalesAgent ID"
|
// @Param id path int true "SalesAgent ID"
|
||||||
// @Param payload body request.SalesAgentsUpdateRequest true "Required payload"
|
// @Param file formData file false "Upload file"
|
||||||
|
// @Param name formData string false "SalesAgent name"
|
||||||
|
// @Param job_title formData string false "SalesAgent job title"
|
||||||
|
// @Param phone formData string false "SalesAgent phone"
|
||||||
|
// @Param agent_type formData string false "SalesAgent agent type (JSON array)"
|
||||||
|
// @Param is_active formData bool false "SalesAgent is_active"
|
||||||
// @Success 200 {object} response.Response
|
// @Success 200 {object} response.Response
|
||||||
// @Failure 400 {object} response.BadRequestError
|
// @Failure 400 {object} response.BadRequestError
|
||||||
// @Failure 401 {object} response.UnauthorizedError
|
// @Failure 401 {object} response.UnauthorizedError
|
||||||
|
|
@ -149,12 +196,49 @@ func (_i *salesAgentsController) Update(c *fiber.Ctx) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
req := new(request.SalesAgentsUpdateRequest)
|
// Parse multipart form
|
||||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
form, err := c.MultipartForm()
|
||||||
return err
|
if err != nil {
|
||||||
|
return utilRes.Resp(c, utilRes.Response{
|
||||||
|
Success: false,
|
||||||
|
Messages: utilRes.Messages{"Failed to parse form data"},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
dataResult, err := _i.salesAgentsService.Update(uint(id), *req)
|
// Extract form values
|
||||||
|
req := request.SalesAgentsUpdateRequest{}
|
||||||
|
|
||||||
|
if name := c.FormValue("name"); name != "" {
|
||||||
|
req.Name = &name
|
||||||
|
}
|
||||||
|
|
||||||
|
if jobTitle := c.FormValue("job_title"); jobTitle != "" {
|
||||||
|
req.JobTitle = &jobTitle
|
||||||
|
}
|
||||||
|
|
||||||
|
if phone := c.FormValue("phone"); phone != "" {
|
||||||
|
req.Phone = &phone
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle agent_type (JSON array string)
|
||||||
|
if agentTypeStr := c.FormValue("agent_type"); agentTypeStr != "" {
|
||||||
|
var agentType []string
|
||||||
|
if err := json.Unmarshal([]byte(agentTypeStr), &agentType); err == nil {
|
||||||
|
req.AgentType = agentType
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if isActiveStr := c.FormValue("is_active"); isActiveStr != "" {
|
||||||
|
isActive := isActiveStr == "true" || isActiveStr == "1"
|
||||||
|
req.IsActive = &isActive
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if file is uploaded
|
||||||
|
if len(form.File["file"]) > 0 {
|
||||||
|
// File will be handled in service
|
||||||
|
}
|
||||||
|
|
||||||
|
dataResult, err := _i.salesAgentsService.Update(c, uint(id), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,49 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"jaecoo-be/app/module/sales_agents/mapper"
|
"jaecoo-be/app/module/sales_agents/mapper"
|
||||||
"jaecoo-be/app/module/sales_agents/repository"
|
"jaecoo-be/app/module/sales_agents/repository"
|
||||||
"jaecoo-be/app/module/sales_agents/request"
|
"jaecoo-be/app/module/sales_agents/request"
|
||||||
"jaecoo-be/app/module/sales_agents/response"
|
"jaecoo-be/app/module/sales_agents/response"
|
||||||
"jaecoo-be/config/config"
|
"jaecoo-be/config/config"
|
||||||
|
minioStorage "jaecoo-be/config/config"
|
||||||
"jaecoo-be/utils/paginator"
|
"jaecoo-be/utils/paginator"
|
||||||
|
"math/rand"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
"github.com/minio/minio-go/v7"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
)
|
)
|
||||||
|
|
||||||
type salesAgentsService struct {
|
type salesAgentsService struct {
|
||||||
Repo repository.SalesAgentsRepository
|
Repo repository.SalesAgentsRepository
|
||||||
Log zerolog.Logger
|
Log zerolog.Logger
|
||||||
Cfg *config.Config
|
Cfg *config.Config
|
||||||
|
MinioStorage *minioStorage.MinioStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
type SalesAgentsService interface {
|
type SalesAgentsService interface {
|
||||||
GetAll(req request.SalesAgentsQueryRequest) (agents []*response.SalesAgentsResponse, paging paginator.Pagination, err error)
|
GetAll(req request.SalesAgentsQueryRequest) (agents []*response.SalesAgentsResponse, paging paginator.Pagination, err error)
|
||||||
GetOne(id uint) (agent *response.SalesAgentsResponse, err error)
|
GetOne(id uint) (agent *response.SalesAgentsResponse, err error)
|
||||||
Create(req request.SalesAgentsCreateRequest) (agent *response.SalesAgentsResponse, err error)
|
Create(c *fiber.Ctx, req request.SalesAgentsCreateRequest) (agent *response.SalesAgentsResponse, err error)
|
||||||
Update(id uint, req request.SalesAgentsUpdateRequest) (agent *response.SalesAgentsResponse, err error)
|
Update(c *fiber.Ctx, id uint, req request.SalesAgentsUpdateRequest) (agent *response.SalesAgentsResponse, err error)
|
||||||
Delete(id uint) (err error)
|
Delete(id uint) (err error)
|
||||||
|
UploadFileToMinio(c *fiber.Ctx, fileKey string) (filePath *string, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSalesAgentsService(repo repository.SalesAgentsRepository, log zerolog.Logger, cfg *config.Config) SalesAgentsService {
|
func NewSalesAgentsService(repo repository.SalesAgentsRepository, log zerolog.Logger, cfg *config.Config, minioStorage *minioStorage.MinioStorage) SalesAgentsService {
|
||||||
return &salesAgentsService{
|
return &salesAgentsService{
|
||||||
Repo: repo,
|
Repo: repo,
|
||||||
Log: log,
|
Log: log,
|
||||||
Cfg: cfg,
|
Cfg: cfg,
|
||||||
|
MinioStorage: minioStorage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +79,12 @@ func (_i *salesAgentsService) GetOne(id uint) (agent *response.SalesAgentsRespon
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *salesAgentsService) Create(req request.SalesAgentsCreateRequest) (agent *response.SalesAgentsResponse, err error) {
|
func (_i *salesAgentsService) Create(c *fiber.Ctx, req request.SalesAgentsCreateRequest) (agent *response.SalesAgentsResponse, err error) {
|
||||||
|
// Handle file upload if exists
|
||||||
|
if filePath, uploadErr := _i.UploadFileToMinio(c, "file"); uploadErr == nil && filePath != nil {
|
||||||
|
req.ProfilePicturePath = filePath
|
||||||
|
}
|
||||||
|
|
||||||
agentEntity := req.ToEntity()
|
agentEntity := req.ToEntity()
|
||||||
isActive := true
|
isActive := true
|
||||||
agentEntity.IsActive = &isActive
|
agentEntity.IsActive = &isActive
|
||||||
|
|
@ -82,7 +100,12 @@ func (_i *salesAgentsService) Create(req request.SalesAgentsCreateRequest) (agen
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_i *salesAgentsService) Update(id uint, req request.SalesAgentsUpdateRequest) (agent *response.SalesAgentsResponse, err error) {
|
func (_i *salesAgentsService) Update(c *fiber.Ctx, id uint, req request.SalesAgentsUpdateRequest) (agent *response.SalesAgentsResponse, err error) {
|
||||||
|
// Handle file upload if exists
|
||||||
|
if filePath, uploadErr := _i.UploadFileToMinio(c, "file"); uploadErr == nil && filePath != nil {
|
||||||
|
req.ProfilePicturePath = filePath
|
||||||
|
}
|
||||||
|
|
||||||
agentEntity := req.ToEntity()
|
agentEntity := req.ToEntity()
|
||||||
|
|
||||||
err = _i.Repo.Update(id, agentEntity)
|
err = _i.Repo.Update(id, agentEntity)
|
||||||
|
|
@ -101,6 +124,71 @@ func (_i *salesAgentsService) Update(id uint, req request.SalesAgentsUpdateReque
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (_i *salesAgentsService) UploadFileToMinio(c *fiber.Ctx, fileKey string) (filePath *string, err error) {
|
||||||
|
form, err := c.MultipartForm()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
files := form.File[fileKey]
|
||||||
|
if len(files) == 0 {
|
||||||
|
return nil, nil // No file uploaded, return nil without error
|
||||||
|
}
|
||||||
|
|
||||||
|
fileHeader := files[0]
|
||||||
|
|
||||||
|
// Create minio connection
|
||||||
|
minioClient, err := _i.MinioStorage.ConnectMinio()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
bucketName := _i.MinioStorage.Cfg.ObjectStorage.MinioStorage.BucketName
|
||||||
|
|
||||||
|
// Open file
|
||||||
|
src, err := fileHeader.Open()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer src.Close()
|
||||||
|
|
||||||
|
// Process filename
|
||||||
|
filename := filepath.Base(fileHeader.Filename)
|
||||||
|
filename = strings.ReplaceAll(filename, " ", "")
|
||||||
|
filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))])
|
||||||
|
extension := filepath.Ext(fileHeader.Filename)[1:]
|
||||||
|
|
||||||
|
// Generate unique filename
|
||||||
|
now := time.Now()
|
||||||
|
rand.New(rand.NewSource(now.UnixNano()))
|
||||||
|
randUniqueId := rand.Intn(1000000)
|
||||||
|
|
||||||
|
newFilenameWithoutExt := filenameWithoutExt + "_" + strconv.Itoa(randUniqueId)
|
||||||
|
newFilename := newFilenameWithoutExt + "." + extension
|
||||||
|
|
||||||
|
// Create object name with path structure
|
||||||
|
objectName := fmt.Sprintf("sales_agents/upload/%d/%d/%s", now.Year(), now.Month(), newFilename)
|
||||||
|
|
||||||
|
_i.Log.Info().Str("timestamp", time.Now().
|
||||||
|
Format(time.RFC3339)).Str("Service:Resource", "SalesAgents:UploadFileToMinio").
|
||||||
|
Interface("Uploading file", objectName).Msg("")
|
||||||
|
|
||||||
|
// Upload file to MinIO
|
||||||
|
_, err = minioClient.PutObject(context.Background(), bucketName, objectName, src, fileHeader.Size, minio.PutObjectOptions{})
|
||||||
|
if err != nil {
|
||||||
|
_i.Log.Error().Str("timestamp", time.Now().
|
||||||
|
Format(time.RFC3339)).Str("Service:Resource", "SalesAgents:UploadFileToMinio").
|
||||||
|
Interface("Error uploading file", err).Msg("")
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_i.Log.Info().Str("timestamp", time.Now().
|
||||||
|
Format(time.RFC3339)).Str("Service:Resource", "SalesAgents:UploadFileToMinio").
|
||||||
|
Interface("Successfully uploaded", objectName).Msg("")
|
||||||
|
|
||||||
|
return &objectName, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (_i *salesAgentsService) Delete(id uint) (err error) {
|
func (_i *salesAgentsService) Delete(id uint) (err error) {
|
||||||
err = _i.Repo.Delete(id)
|
err = _i.Repo.Delete(id)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -3521,7 +3521,7 @@ const docTemplate = `{
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for updating Banner",
|
"description": "API for updating Banner with file upload",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Banners"
|
"Banners"
|
||||||
],
|
],
|
||||||
|
|
@ -3542,13 +3542,40 @@ const docTemplate = `{
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"type": "file",
|
||||||
"name": "payload",
|
"description": "Upload file",
|
||||||
"in": "body",
|
"name": "file",
|
||||||
"required": true,
|
"in": "formData"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/request.BannersUpdateRequest"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "Banner title",
|
||||||
|
"name": "title",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Banner description",
|
||||||
|
"name": "description",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Banner position",
|
||||||
|
"name": "position",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Banner status",
|
||||||
|
"name": "status",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Banner is_active",
|
||||||
|
"name": "is_active",
|
||||||
|
"in": "formData"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
@ -6336,7 +6363,7 @@ const docTemplate = `{
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for updating Product",
|
"description": "API for updating Product with file upload",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Products"
|
"Products"
|
||||||
],
|
],
|
||||||
|
|
@ -6357,13 +6384,40 @@ const docTemplate = `{
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"type": "file",
|
||||||
"name": "payload",
|
"description": "Upload file",
|
||||||
"in": "body",
|
"name": "file",
|
||||||
"required": true,
|
"in": "formData"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/request.ProductsUpdateRequest"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "Product title",
|
||||||
|
"name": "title",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Product variant",
|
||||||
|
"name": "variant",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Product price",
|
||||||
|
"name": "price",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Product colors (JSON array)",
|
||||||
|
"name": "colors",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Product is_active",
|
||||||
|
"name": "is_active",
|
||||||
|
"in": "formData"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
@ -7197,7 +7251,7 @@ const docTemplate = `{
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for creating SalesAgent",
|
"description": "API for creating SalesAgent with file upload",
|
||||||
"tags": [
|
"tags": [
|
||||||
"SalesAgents"
|
"SalesAgents"
|
||||||
],
|
],
|
||||||
|
|
@ -7211,13 +7265,35 @@ const docTemplate = `{
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"type": "file",
|
||||||
"name": "payload",
|
"description": "Upload file",
|
||||||
"in": "body",
|
"name": "file",
|
||||||
"required": true,
|
"in": "formData"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/request.SalesAgentsCreateRequest"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "SalesAgent name",
|
||||||
|
"name": "name",
|
||||||
|
"in": "formData",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent job title",
|
||||||
|
"name": "job_title",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent phone",
|
||||||
|
"name": "phone",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent agent type (JSON array)",
|
||||||
|
"name": "agent_type",
|
||||||
|
"in": "formData"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
@ -7309,7 +7385,7 @@ const docTemplate = `{
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for updating SalesAgent",
|
"description": "API for updating SalesAgent with file upload",
|
||||||
"tags": [
|
"tags": [
|
||||||
"SalesAgents"
|
"SalesAgents"
|
||||||
],
|
],
|
||||||
|
|
@ -7330,13 +7406,40 @@ const docTemplate = `{
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"type": "file",
|
||||||
"name": "payload",
|
"description": "Upload file",
|
||||||
"in": "body",
|
"name": "file",
|
||||||
"required": true,
|
"in": "formData"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/request.SalesAgentsUpdateRequest"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "SalesAgent name",
|
||||||
|
"name": "name",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent job title",
|
||||||
|
"name": "job_title",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent phone",
|
||||||
|
"name": "phone",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent agent type (JSON array)",
|
||||||
|
"name": "agent_type",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "SalesAgent is_active",
|
||||||
|
"name": "is_active",
|
||||||
|
"in": "formData"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
@ -10175,29 +10278,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"request.BannersUpdateRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"description": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"is_active": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"position": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"thumbnail_path": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"title": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"request.CitiesCreateRequest": {
|
"request.CitiesCreateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -10393,32 +10473,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"request.ProductsUpdateRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"colors": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"is_active": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"price": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"thumbnail_path": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"title": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"variant": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"request.PromotionsUpdateRequest": {
|
"request.PromotionsUpdateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -10436,58 +10490,6 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"request.SalesAgentsCreateRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"name"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"agent_type": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"job_title": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"phone": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"profile_picture_path": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"request.SalesAgentsUpdateRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"agent_type": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"is_active": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"job_title": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"phone": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"profile_picture_path": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"request.UserEmailValidationRequest": {
|
"request.UserEmailValidationRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -3510,7 +3510,7 @@
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for updating Banner",
|
"description": "API for updating Banner with file upload",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Banners"
|
"Banners"
|
||||||
],
|
],
|
||||||
|
|
@ -3531,13 +3531,40 @@
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"type": "file",
|
||||||
"name": "payload",
|
"description": "Upload file",
|
||||||
"in": "body",
|
"name": "file",
|
||||||
"required": true,
|
"in": "formData"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/request.BannersUpdateRequest"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "Banner title",
|
||||||
|
"name": "title",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Banner description",
|
||||||
|
"name": "description",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Banner position",
|
||||||
|
"name": "position",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Banner status",
|
||||||
|
"name": "status",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Banner is_active",
|
||||||
|
"name": "is_active",
|
||||||
|
"in": "formData"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
@ -6325,7 +6352,7 @@
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for updating Product",
|
"description": "API for updating Product with file upload",
|
||||||
"tags": [
|
"tags": [
|
||||||
"Products"
|
"Products"
|
||||||
],
|
],
|
||||||
|
|
@ -6346,13 +6373,40 @@
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"type": "file",
|
||||||
"name": "payload",
|
"description": "Upload file",
|
||||||
"in": "body",
|
"name": "file",
|
||||||
"required": true,
|
"in": "formData"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/request.ProductsUpdateRequest"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "Product title",
|
||||||
|
"name": "title",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Product variant",
|
||||||
|
"name": "variant",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Product price",
|
||||||
|
"name": "price",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "Product colors (JSON array)",
|
||||||
|
"name": "colors",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Product is_active",
|
||||||
|
"name": "is_active",
|
||||||
|
"in": "formData"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
@ -7186,7 +7240,7 @@
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for creating SalesAgent",
|
"description": "API for creating SalesAgent with file upload",
|
||||||
"tags": [
|
"tags": [
|
||||||
"SalesAgents"
|
"SalesAgents"
|
||||||
],
|
],
|
||||||
|
|
@ -7200,13 +7254,35 @@
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"type": "file",
|
||||||
"name": "payload",
|
"description": "Upload file",
|
||||||
"in": "body",
|
"name": "file",
|
||||||
"required": true,
|
"in": "formData"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/request.SalesAgentsCreateRequest"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "SalesAgent name",
|
||||||
|
"name": "name",
|
||||||
|
"in": "formData",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent job title",
|
||||||
|
"name": "job_title",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent phone",
|
||||||
|
"name": "phone",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent agent type (JSON array)",
|
||||||
|
"name": "agent_type",
|
||||||
|
"in": "formData"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
@ -7298,7 +7374,7 @@
|
||||||
"Bearer": []
|
"Bearer": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "API for updating SalesAgent",
|
"description": "API for updating SalesAgent with file upload",
|
||||||
"tags": [
|
"tags": [
|
||||||
"SalesAgents"
|
"SalesAgents"
|
||||||
],
|
],
|
||||||
|
|
@ -7319,13 +7395,40 @@
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Required payload",
|
"type": "file",
|
||||||
"name": "payload",
|
"description": "Upload file",
|
||||||
"in": "body",
|
"name": "file",
|
||||||
"required": true,
|
"in": "formData"
|
||||||
"schema": {
|
},
|
||||||
"$ref": "#/definitions/request.SalesAgentsUpdateRequest"
|
{
|
||||||
}
|
"type": "string",
|
||||||
|
"description": "SalesAgent name",
|
||||||
|
"name": "name",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent job title",
|
||||||
|
"name": "job_title",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent phone",
|
||||||
|
"name": "phone",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "SalesAgent agent type (JSON array)",
|
||||||
|
"name": "agent_type",
|
||||||
|
"in": "formData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "SalesAgent is_active",
|
||||||
|
"name": "is_active",
|
||||||
|
"in": "formData"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|
@ -10164,29 +10267,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"request.BannersUpdateRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"description": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"is_active": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"position": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"status": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"thumbnail_path": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"title": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"request.CitiesCreateRequest": {
|
"request.CitiesCreateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -10382,32 +10462,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"request.ProductsUpdateRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"colors": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"is_active": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"price": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"thumbnail_path": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"title": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"variant": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"request.PromotionsUpdateRequest": {
|
"request.PromotionsUpdateRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -10425,58 +10479,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"request.SalesAgentsCreateRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"name"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"agent_type": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"job_title": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"phone": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"profile_picture_path": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"request.SalesAgentsUpdateRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"agent_type": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"is_active": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"job_title": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"phone": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"profile_picture_path": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"request.UserEmailValidationRequest": {
|
"request.UserEmailValidationRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
||||||
|
|
@ -281,21 +281,6 @@ definitions:
|
||||||
- title
|
- title
|
||||||
- typeId
|
- typeId
|
||||||
type: object
|
type: object
|
||||||
request.BannersUpdateRequest:
|
|
||||||
properties:
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
is_active:
|
|
||||||
type: boolean
|
|
||||||
position:
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
thumbnail_path:
|
|
||||||
type: string
|
|
||||||
title:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
request.CitiesCreateRequest:
|
request.CitiesCreateRequest:
|
||||||
properties:
|
properties:
|
||||||
cityName:
|
cityName:
|
||||||
|
|
@ -427,23 +412,6 @@ definitions:
|
||||||
title:
|
title:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
request.ProductsUpdateRequest:
|
|
||||||
properties:
|
|
||||||
colors:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
is_active:
|
|
||||||
type: boolean
|
|
||||||
price:
|
|
||||||
type: string
|
|
||||||
thumbnail_path:
|
|
||||||
type: string
|
|
||||||
title:
|
|
||||||
type: string
|
|
||||||
variant:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
request.PromotionsUpdateRequest:
|
request.PromotionsUpdateRequest:
|
||||||
properties:
|
properties:
|
||||||
description:
|
description:
|
||||||
|
|
@ -455,40 +423,6 @@ definitions:
|
||||||
title:
|
title:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
request.SalesAgentsCreateRequest:
|
|
||||||
properties:
|
|
||||||
agent_type:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
job_title:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
phone:
|
|
||||||
type: string
|
|
||||||
profile_picture_path:
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- name
|
|
||||||
type: object
|
|
||||||
request.SalesAgentsUpdateRequest:
|
|
||||||
properties:
|
|
||||||
agent_type:
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
type: array
|
|
||||||
is_active:
|
|
||||||
type: boolean
|
|
||||||
job_title:
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
phone:
|
|
||||||
type: string
|
|
||||||
profile_picture_path:
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
request.UserEmailValidationRequest:
|
request.UserEmailValidationRequest:
|
||||||
properties:
|
properties:
|
||||||
newEmail:
|
newEmail:
|
||||||
|
|
@ -3084,7 +3018,7 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Banners
|
- Banners
|
||||||
put:
|
put:
|
||||||
description: API for updating Banner
|
description: API for updating Banner with file upload
|
||||||
parameters:
|
parameters:
|
||||||
- description: Insert the X-Client-Key
|
- description: Insert the X-Client-Key
|
||||||
in: header
|
in: header
|
||||||
|
|
@ -3096,12 +3030,30 @@ paths:
|
||||||
name: id
|
name: id
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
- description: Required payload
|
- description: Upload file
|
||||||
in: body
|
in: formData
|
||||||
name: payload
|
name: file
|
||||||
required: true
|
type: file
|
||||||
schema:
|
- description: Banner title
|
||||||
$ref: '#/definitions/request.BannersUpdateRequest'
|
in: formData
|
||||||
|
name: title
|
||||||
|
type: string
|
||||||
|
- description: Banner description
|
||||||
|
in: formData
|
||||||
|
name: description
|
||||||
|
type: string
|
||||||
|
- description: Banner position
|
||||||
|
in: formData
|
||||||
|
name: position
|
||||||
|
type: string
|
||||||
|
- description: Banner status
|
||||||
|
in: formData
|
||||||
|
name: status
|
||||||
|
type: string
|
||||||
|
- description: Banner is_active
|
||||||
|
in: formData
|
||||||
|
name: is_active
|
||||||
|
type: boolean
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -4879,7 +4831,7 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- Products
|
- Products
|
||||||
put:
|
put:
|
||||||
description: API for updating Product
|
description: API for updating Product with file upload
|
||||||
parameters:
|
parameters:
|
||||||
- description: Insert the X-Client-Key
|
- description: Insert the X-Client-Key
|
||||||
in: header
|
in: header
|
||||||
|
|
@ -4891,12 +4843,30 @@ paths:
|
||||||
name: id
|
name: id
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
- description: Required payload
|
- description: Upload file
|
||||||
in: body
|
in: formData
|
||||||
name: payload
|
name: file
|
||||||
required: true
|
type: file
|
||||||
schema:
|
- description: Product title
|
||||||
$ref: '#/definitions/request.ProductsUpdateRequest'
|
in: formData
|
||||||
|
name: title
|
||||||
|
type: string
|
||||||
|
- description: Product variant
|
||||||
|
in: formData
|
||||||
|
name: variant
|
||||||
|
type: string
|
||||||
|
- description: Product price
|
||||||
|
in: formData
|
||||||
|
name: price
|
||||||
|
type: string
|
||||||
|
- description: Product colors (JSON array)
|
||||||
|
in: formData
|
||||||
|
name: colors
|
||||||
|
type: string
|
||||||
|
- description: Product is_active
|
||||||
|
in: formData
|
||||||
|
name: is_active
|
||||||
|
type: boolean
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -5429,19 +5399,34 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- SalesAgents
|
- SalesAgents
|
||||||
post:
|
post:
|
||||||
description: API for creating SalesAgent
|
description: API for creating SalesAgent with file upload
|
||||||
parameters:
|
parameters:
|
||||||
- description: Insert the X-Client-Key
|
- description: Insert the X-Client-Key
|
||||||
in: header
|
in: header
|
||||||
name: X-Client-Key
|
name: X-Client-Key
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
- description: Required payload
|
- description: Upload file
|
||||||
in: body
|
in: formData
|
||||||
name: payload
|
name: file
|
||||||
|
type: file
|
||||||
|
- description: SalesAgent name
|
||||||
|
in: formData
|
||||||
|
name: name
|
||||||
required: true
|
required: true
|
||||||
schema:
|
type: string
|
||||||
$ref: '#/definitions/request.SalesAgentsCreateRequest'
|
- description: SalesAgent job title
|
||||||
|
in: formData
|
||||||
|
name: job_title
|
||||||
|
type: string
|
||||||
|
- description: SalesAgent phone
|
||||||
|
in: formData
|
||||||
|
name: phone
|
||||||
|
type: string
|
||||||
|
- description: SalesAgent agent type (JSON array)
|
||||||
|
in: formData
|
||||||
|
name: agent_type
|
||||||
|
type: string
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
@ -5536,7 +5521,7 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- SalesAgents
|
- SalesAgents
|
||||||
put:
|
put:
|
||||||
description: API for updating SalesAgent
|
description: API for updating SalesAgent with file upload
|
||||||
parameters:
|
parameters:
|
||||||
- description: Insert the X-Client-Key
|
- description: Insert the X-Client-Key
|
||||||
in: header
|
in: header
|
||||||
|
|
@ -5548,12 +5533,30 @@ paths:
|
||||||
name: id
|
name: id
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
- description: Required payload
|
- description: Upload file
|
||||||
in: body
|
in: formData
|
||||||
name: payload
|
name: file
|
||||||
required: true
|
type: file
|
||||||
schema:
|
- description: SalesAgent name
|
||||||
$ref: '#/definitions/request.SalesAgentsUpdateRequest'
|
in: formData
|
||||||
|
name: name
|
||||||
|
type: string
|
||||||
|
- description: SalesAgent job title
|
||||||
|
in: formData
|
||||||
|
name: job_title
|
||||||
|
type: string
|
||||||
|
- description: SalesAgent phone
|
||||||
|
in: formData
|
||||||
|
name: phone
|
||||||
|
type: string
|
||||||
|
- description: SalesAgent agent type (JSON array)
|
||||||
|
in: formData
|
||||||
|
name: agent_type
|
||||||
|
type: string
|
||||||
|
- description: SalesAgent is_active
|
||||||
|
in: formData
|
||||||
|
name: is_active
|
||||||
|
type: boolean
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue