On branch main
modified: main_dc/yalarba/api_yal/internal/domain/rating/dto.go new file: main_dc/yalarba/api_yal/internal/domain/rating/handler.go new file: main_dc/yalarba/api_yal/internal/domain/rating/router.go new file: main_dc/yalarba/api_yal/internal/domain/rating/service.go modified: main_dc/yalarba/api_yal/internal/router/router.go add raing domain without test
This commit is contained in:
@@ -1,6 +1,87 @@
|
||||
package rating
|
||||
|
||||
import (
|
||||
|
||||
"api_yal/internal/models"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CreateRatingRequest запрос на создание рейтинга
|
||||
type CreateRatingRequest struct {
|
||||
ObjectID uint `json:"object_id" validate:"required"`
|
||||
Platform models.PlatformType `json:"platform" validate:"required,oneof=entrepreneur tourist"`
|
||||
}
|
||||
|
||||
// UpdateRatingRequest запрос на обновление рейтинга
|
||||
type UpdateRatingRequest struct {
|
||||
AverageScore *float64 `json:"average_score,omitempty"`
|
||||
TotalVotes *int `json:"total_votes,omitempty"`
|
||||
}
|
||||
|
||||
// VoteRequest запрос на голосование
|
||||
type VoteRequest struct {
|
||||
Score int `json:"score" validate:"required,min=1,max=5"`
|
||||
}
|
||||
|
||||
// RatingResponse ответ с данными рейтинга
|
||||
type RatingResponse struct {
|
||||
ID uint `json:"id"`
|
||||
OwnerID uint `json:"owner_id"`
|
||||
ObjectID uint `json:"object_id"`
|
||||
Platform models.PlatformType `json:"platform"`
|
||||
AverageScore float64 `json:"average_score"`
|
||||
TotalVotes int `json:"total_votes"`
|
||||
VoteBreakdown *VoteBreakdownResponse `json:"vote_breakdown,omitempty"`
|
||||
Object *ObjectBriefResponse `json:"object,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// VoteBreakdownResponse ответ с детализацией голосов
|
||||
type VoteBreakdownResponse struct {
|
||||
Score1 int `json:"score_1"`
|
||||
Score2 int `json:"score_2"`
|
||||
Score3 int `json:"score_3"`
|
||||
Score4 int `json:"score_4"`
|
||||
Score5 int `json:"score_5"`
|
||||
}
|
||||
|
||||
// ObjectBriefResponse краткая информация об объекте
|
||||
type ObjectBriefResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// RatingVoteResponse ответ с данными голоса
|
||||
type RatingVoteResponse struct {
|
||||
ID uint `json:"id"`
|
||||
Platform models.PlatformType `json:"platform"`
|
||||
TargetID uint `json:"target_id"`
|
||||
VoterID uint `json:"voter_id"`
|
||||
Score int `json:"score"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// ListRatingsRequest параметры для списка рейтингов
|
||||
type ListRatingsRequest struct {
|
||||
Page int `query:"page" default:"1"`
|
||||
PageSize int `query:"page_size" default:"20"`
|
||||
Platform string `query:"platform"`
|
||||
OwnerID uint `query:"owner_id"`
|
||||
ObjectID uint `query:"object_id"`
|
||||
}
|
||||
|
||||
// ListRatingsResponse ответ со списком рейтингов
|
||||
type ListRatingsResponse struct {
|
||||
Ratings []RatingResponse `json:"ratings"`
|
||||
Total int64 `json:"total"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
TotalPages int `json:"total_pages"`
|
||||
}
|
||||
|
||||
// UserRatingInfoResponse информация о голосе пользователя
|
||||
type UserRatingInfoResponse struct {
|
||||
HasVoted bool `json:"has_voted"`
|
||||
UserScore *int `json:"user_score,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user