2025-08-15 21:17:19 +07:00
|
|
|
package contract
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type CreateVoteEventRequest struct {
|
|
|
|
|
Title string `json:"title" validate:"required,min=1,max=255"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
StartDate time.Time `json:"start_date" validate:"required"`
|
|
|
|
|
EndDate time.Time `json:"end_date" validate:"required"`
|
|
|
|
|
ResultsOpen *bool `json:"results_open,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UpdateVoteEventRequest struct {
|
|
|
|
|
Title string `json:"title" validate:"required,min=1,max=255"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
StartDate time.Time `json:"start_date" validate:"required"`
|
|
|
|
|
EndDate time.Time `json:"end_date" validate:"required"`
|
|
|
|
|
IsActive bool `json:"is_active"`
|
|
|
|
|
ResultsOpen *bool `json:"results_open,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VoteEventResponse struct {
|
2025-08-16 01:51:37 +07:00
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
StartDate time.Time `json:"start_date"`
|
|
|
|
|
EndDate time.Time `json:"end_date"`
|
|
|
|
|
IsActive bool `json:"is_active"`
|
|
|
|
|
ResultsOpen bool `json:"results_open"`
|
|
|
|
|
IsVotingOpen bool `json:"is_voting_open"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
Candidates []CandidateResponse `json:"candidates,omitempty"`
|
2025-08-15 21:17:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ListVoteEventsRequest struct {
|
|
|
|
|
Page int `json:"page" validate:"min=1"`
|
|
|
|
|
Limit int `json:"limit" validate:"min=1,max=100"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ListVoteEventsResponse struct {
|
|
|
|
|
VoteEvents []VoteEventResponse `json:"vote_events"`
|
|
|
|
|
Pagination PaginationResponse `json:"pagination"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CreateCandidateRequest struct {
|
|
|
|
|
VoteEventID uuid.UUID `json:"vote_event_id" validate:"required"`
|
|
|
|
|
Name string `json:"name" validate:"required,min=1,max=255"`
|
|
|
|
|
ImageURL string `json:"image_url"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CandidateResponse struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
VoteEventID uuid.UUID `json:"vote_event_id"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
ImageURL string `json:"image_url"`
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
|
|
|
VoteCount int64 `json:"vote_count,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type SubmitVoteRequest struct {
|
|
|
|
|
VoteEventID uuid.UUID `json:"vote_event_id" validate:"required"`
|
|
|
|
|
CandidateID uuid.UUID `json:"candidate_id" validate:"required"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VoteResponse struct {
|
|
|
|
|
ID uuid.UUID `json:"id"`
|
|
|
|
|
VoteEventID uuid.UUID `json:"vote_event_id"`
|
|
|
|
|
CandidateID uuid.UUID `json:"candidate_id"`
|
|
|
|
|
UserID uuid.UUID `json:"user_id"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VoteResultsResponse struct {
|
|
|
|
|
VoteEventID uuid.UUID `json:"vote_event_id"`
|
|
|
|
|
Candidates []CandidateWithVotesResponse `json:"candidates"`
|
|
|
|
|
TotalVotes int64 `json:"total_votes"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CandidateWithVotesResponse struct {
|
|
|
|
|
CandidateResponse
|
|
|
|
|
VoteCount int64 `json:"vote_count"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CheckVoteStatusResponse struct {
|
2025-08-16 01:51:37 +07:00
|
|
|
HasVoted bool `json:"has_voted"`
|
2025-08-15 21:17:19 +07:00
|
|
|
VotedAt *time.Time `json:"voted_at,omitempty"`
|
|
|
|
|
CandidateID *uuid.UUID `json:"candidate_id,omitempty"`
|
2025-08-16 01:51:37 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VoteEventDetailsResponse struct {
|
|
|
|
|
VoteEvent VoteEventResponse `json:"vote_event"`
|
|
|
|
|
TotalParticipants int64 `json:"total_participants"`
|
|
|
|
|
TotalVoted int64 `json:"total_voted"`
|
|
|
|
|
TotalNotVoted int64 `json:"total_not_voted"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UserVoteInfo struct {
|
|
|
|
|
UserID uuid.UUID `json:"user_id"`
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
FullName string `json:"full_name"`
|
|
|
|
|
VotedAt time.Time `json:"voted_at"`
|
|
|
|
|
CandidateID uuid.UUID `json:"candidate_id"`
|
|
|
|
|
CandidateName string `json:"candidate_name"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UserBasicInfo struct {
|
|
|
|
|
UserID uuid.UUID `json:"user_id"`
|
|
|
|
|
Username string `json:"username"`
|
|
|
|
|
FullName string `json:"full_name"`
|
|
|
|
|
}
|