63d486f48d
modified: main_dc/yalarba/api_yal/internal/domain/appeal/router.go modified: main_dc/yalarba/api_yal/internal/domain/feetback/dto.go modified: main_dc/yalarba/api_yal/internal/domain/feetback/handler.go modified: main_dc/yalarba/api_yal/internal/domain/feetback/router.go modified: main_dc/yalarba/api_yal/internal/domain/feetback/service.go modified: main_dc/yalarba/api_yal/internal/models/feedback.go modified: main_dc/yalarba/api_yal/internal/repository/comment_repository.go modified: main_dc/yalarba/api_yal/internal/repository/feedback_repository.go modified: main_dc/yalarba/api_yal/internal/repository/feedback_repository_impl.go modified: main_dc/yalarba/api_yal/internal/router/router.go craete routerRegister, service, hander, dto for feedback
107 lines
4.1 KiB
Go
107 lines
4.1 KiB
Go
package feetback
|
|
|
|
import (
|
|
"api_yal/internal/models"
|
|
"time"
|
|
)
|
|
|
|
// CreateFeedbackRequest DTO для создания отзыва
|
|
type CreateFeedbackRequest struct {
|
|
ObjectID uint `json:"object_id" binding:"required"`
|
|
Rating int `json:"rating" binding:"required,min=1,max=5"`
|
|
Text string `json:"text" binding:"required,min=1,max=2000"`
|
|
Platform models.PlatformType `json:"platform" binding:"required"`
|
|
MediaURLs []string `json:"media_urls"`
|
|
}
|
|
|
|
// UpdateFeedbackRequest DTO для обновления отзыва
|
|
type UpdateFeedbackRequest struct {
|
|
Rating *int `json:"rating,omitempty" binding:"omitempty,min=1,max=5"`
|
|
Text *string `json:"text,omitempty" binding:"omitempty,min=1,max=2000"`
|
|
Platform *models.PlatformType `json:"platform,omitempty"`
|
|
MediaURLs []string `json:"media_urls"`
|
|
}
|
|
|
|
// FeedbackResponse DTO для ответа
|
|
type FeedbackResponse struct {
|
|
ID uint `json:"id"`
|
|
OwnerID uint `json:"owner_id"`
|
|
Owner *AccountBriefResponse `json:"owner,omitempty"`
|
|
ObjectID uint `json:"object_id"`
|
|
Object *ObjectBriefResponse `json:"object,omitempty"`
|
|
Rating int `json:"rating"`
|
|
Text string `json:"text"`
|
|
Platform models.PlatformType `json:"platform"`
|
|
MediaURLs []string `json:"media_urls"`
|
|
CommentCount int `json:"comment_count"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// AccountBriefResponse краткая информация о пользователе
|
|
type AccountBriefResponse struct {
|
|
ID uint `json:"id"`
|
|
Username string `json:"username"`
|
|
AvatarURL string `json:"avatar_url"`
|
|
}
|
|
|
|
// ObjectBriefResponse краткая информация об объекте
|
|
type ObjectBriefResponse struct {
|
|
ID uint `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
}
|
|
|
|
// FeedbackListResponse ответ со списком отзывов
|
|
type FeedbackListResponse struct {
|
|
Data []FeedbackResponse `json:"data"`
|
|
Total int64 `json:"total"`
|
|
Offset int `json:"offset"`
|
|
Limit int `json:"limit"`
|
|
NextOffset *int `json:"next_offset,omitempty"`
|
|
}
|
|
|
|
// CreateCommentRequest DTO для создания комментария
|
|
type CreateCommentRequest struct {
|
|
Text string `json:"text" binding:"required,min=1,max=1000"`
|
|
}
|
|
|
|
// UpdateCommentRequest DTO для обновления комментария
|
|
type UpdateCommentRequest struct {
|
|
Text string `json:"text" binding:"required,min=1,max=1000"`
|
|
}
|
|
|
|
// CommentResponse DTO для ответа с комментарием
|
|
type CommentResponse struct {
|
|
ID uint `json:"id"`
|
|
FeedbackID uint `json:"feedback_id"`
|
|
AccountID uint `json:"account_id"`
|
|
Account *AccountBriefResponse `json:"account,omitempty"`
|
|
Text string `json:"text"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// CommentListResponse ответ со списком комментариев
|
|
type CommentListResponse struct {
|
|
Data []CommentResponse `json:"data"`
|
|
Total int `json:"total"`
|
|
Offset int `json:"offset"`
|
|
Limit int `json:"limit"`
|
|
NextOffset *int `json:"next_offset,omitempty"`
|
|
}
|
|
|
|
// FeedbackStatsResponse статистика по отзывам
|
|
type FeedbackStatsResponse struct {
|
|
TotalFeedbacks int64 `json:"total_feedbacks"`
|
|
AverageRating float64 `json:"average_rating"`
|
|
RatingDistribution map[int]int64 `json:"rating_distribution"`
|
|
PlatformStats map[models.PlatformType]int64 `json:"platform_stats"`
|
|
}
|
|
|
|
// ErrorResponse ответ с ошибкой
|
|
type ErrorResponse struct {
|
|
Error string `json:"error"`
|
|
Message string `json:"message"`
|
|
Code int `json:"code"`
|
|
} |