add service
All checks were successful
Deploy Smart Search Gateway Test / deploy (push) Successful in 4m45s
All checks were successful
Deploy Smart Search Gateway Test / deploy (push) Successful in 4m45s
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
type CreateTZRequest struct {
|
||||
RequestTxt string `json:"request_txt" form:"request_txt" validate:"required" example:"Нужны поставщики металлопроката в Москве"`
|
||||
FileName string `json:"file_name" form:"file_name" example:"requirements.pdf"`
|
||||
@@ -31,22 +29,18 @@ type Supplier struct {
|
||||
}
|
||||
|
||||
type MailingItem struct {
|
||||
RequestID string `json:"request_id" example:"req_abc123"`
|
||||
RequestTxt string `json:"request_txt" example:"Нужны поставщики металлопроката"`
|
||||
FinalTZ string `json:"final_tz" example:"Финальное ТЗ"`
|
||||
MailingStatus string `json:"mailing_status" example:"completed"`
|
||||
CreatedAt time.Time `json:"created_at" example:"2025-01-18T12:00:00Z"`
|
||||
SuppliersFound int32 `json:"suppliers_found" example:"15"`
|
||||
}
|
||||
|
||||
type GetMailingListResponse struct {
|
||||
Items []MailingItem `json:"items"`
|
||||
RequestID string `json:"request_id" example:"req_abc123"`
|
||||
Title string `json:"title" example:"Нужны поставщики металлопроката"`
|
||||
MailingStatus string `json:"mailing_status" example:"completed"`
|
||||
}
|
||||
|
||||
type GetMailingListByIDRequest struct {
|
||||
RequestID string `json:"request_id" validate:"required" example:"req_abc123"`
|
||||
}
|
||||
|
||||
type GetMailingListByIDResponse struct {
|
||||
Item MailingItem `json:"item"`
|
||||
type MailingInfo struct {
|
||||
RequestID string `json:"request_id" example:"req_abc123"`
|
||||
Title string `json:"title" example:"Нужны поставщики металлопроката"`
|
||||
Suppliers []Supplier `json:"suppliers"`
|
||||
MailText string `json:"mail_text" example:"Текст письма для рассылки"`
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func (h *RequestHandler) ApproveTZ(c *fiber.Ctx) error {
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} dto.GetMailingListResponse
|
||||
// @Success 200 {array} dto.MailingItem
|
||||
// @Failure 401 {object} dto.ErrorResponse "AUTH_INVALID_TOKEN"
|
||||
// @Failure 503 {object} dto.ErrorResponse "SERVICE_UNAVAILABLE"
|
||||
// @Router /request/mailing-list [post]
|
||||
@@ -194,18 +194,13 @@ func (h *RequestHandler) GetMailingList(c *fiber.Ctx) error {
|
||||
items := make([]dto.MailingItem, 0, len(resp.Items))
|
||||
for _, item := range resp.Items {
|
||||
items = append(items, dto.MailingItem{
|
||||
RequestID: item.RequestId,
|
||||
RequestTxt: item.RequestTxt,
|
||||
FinalTZ: item.FinalTz,
|
||||
MailingStatus: item.MailingStatus,
|
||||
CreatedAt: item.CreatedAt.AsTime(),
|
||||
SuppliersFound: item.SuppliersFound,
|
||||
RequestID: item.RequestId,
|
||||
Title: item.RequestTxt,
|
||||
MailingStatus: item.MailingStatus,
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(dto.GetMailingListResponse{
|
||||
Items: items,
|
||||
})
|
||||
return c.JSON(items)
|
||||
}
|
||||
|
||||
// GetMailingListByID godoc
|
||||
@@ -216,7 +211,7 @@ func (h *RequestHandler) GetMailingList(c *fiber.Ctx) error {
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param request body dto.GetMailingListByIDRequest true "ID запроса"
|
||||
// @Success 200 {object} dto.GetMailingListByIDResponse
|
||||
// @Success 200 {object} dto.MailingInfo
|
||||
// @Failure 400 {object} dto.ErrorResponse "INVALID_REQUEST"
|
||||
// @Failure 401 {object} dto.ErrorResponse "AUTH_INVALID_TOKEN"
|
||||
// @Failure 403 {object} dto.ErrorResponse "PERMISSION_DENIED"
|
||||
@@ -251,14 +246,10 @@ func (h *RequestHandler) GetMailingListByID(c *fiber.Ctx) error {
|
||||
return errors.ToHTTPResponse(c, errors.FromGRPCError(err))
|
||||
}
|
||||
|
||||
return c.JSON(dto.GetMailingListByIDResponse{
|
||||
Item: dto.MailingItem{
|
||||
RequestID: resp.Item.RequestId,
|
||||
RequestTxt: resp.Item.RequestTxt,
|
||||
FinalTZ: resp.Item.FinalTz,
|
||||
MailingStatus: resp.Item.MailingStatus,
|
||||
CreatedAt: resp.Item.CreatedAt.AsTime(),
|
||||
SuppliersFound: resp.Item.SuppliersFound,
|
||||
},
|
||||
return c.JSON(dto.MailingInfo{
|
||||
RequestID: resp.Item.RequestId,
|
||||
Title: resp.Item.RequestTxt,
|
||||
Suppliers: nil,
|
||||
MailText: resp.Item.FinalTz,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user