profile keyword manual update and recommended tenders
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package customer
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"tm/internal/user"
|
||||
"tm/pkg/authorization"
|
||||
"tm/pkg/logger"
|
||||
@@ -57,6 +58,9 @@ func (h *Handler) CreateCustomer(c echo.Context) error {
|
||||
err.Error() == "company with this tax ID already exists" {
|
||||
return response.Conflict(c, err.Error())
|
||||
}
|
||||
if strings.HasPrefix(err.Error(), "invalid company ID") || err.Error() == "invalid username format" {
|
||||
return response.BadRequest(c, err.Error(), "")
|
||||
}
|
||||
return response.InternalServerError(c, "Failed to create customer")
|
||||
}
|
||||
|
||||
@@ -397,6 +401,43 @@ func (h *Handler) GetProfile(c echo.Context) error {
|
||||
return response.Success(c, resp, "Profile retrieved successfully")
|
||||
}
|
||||
|
||||
// UpdateProfileKeywords updates customer profile keywords (Mobile)
|
||||
// @Summary Update customer profile keywords
|
||||
// @Description Update profile keywords manually and trigger asynchronous GLM enhancement based on customer company information (including country).
|
||||
// @Tags Authorization
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param request body UpdateProfileKeywordsForm true "Manual keywords"
|
||||
// @Success 200 {object} response.APIResponse{data=CustomerResponse} "Profile keywords update started"
|
||||
// @Failure 400 {object} response.APIResponse "Bad request - Invalid input data"
|
||||
// @Failure 401 {object} response.APIResponse "Unauthorized - Invalid or missing token"
|
||||
// @Failure 404 {object} response.APIResponse "Not found - Customer not found"
|
||||
// @Failure 422 {object} response.APIResponse "Validation error - Invalid request data"
|
||||
// @Failure 500 {object} response.APIResponse "Internal server error"
|
||||
// @Router /api/v1/profile/keywords [patch]
|
||||
func (h *Handler) UpdateProfileKeywords(c echo.Context) error {
|
||||
customerID, err := GetCustomerIDFromContext(c)
|
||||
if err != nil {
|
||||
return response.Unauthorized(c, "Customer not authenticated")
|
||||
}
|
||||
|
||||
form, err := response.Parse[UpdateProfileKeywordsForm](c)
|
||||
if err != nil {
|
||||
return response.ValidationError(c, "Invalid request data", err.Error())
|
||||
}
|
||||
|
||||
resp, err := h.service.UpdateProfileKeywords(c.Request().Context(), customerID, form.Keywords)
|
||||
if err != nil {
|
||||
if err.Error() == "customer not found" {
|
||||
return response.NotFound(c, "Customer not found")
|
||||
}
|
||||
return response.InternalServerError(c, "Failed to update profile keywords")
|
||||
}
|
||||
|
||||
return response.Success(c, resp, "Profile keywords update started")
|
||||
}
|
||||
|
||||
// Logout handles customer logout (Mobile)
|
||||
// @Summary Customer logout
|
||||
// @Description Logout customer and invalidate access token
|
||||
|
||||
Reference in New Issue
Block a user