To gitea and beyond, let's go(-yco)

This commit is contained in:
2025-11-10 19:12:09 +01:00
parent 8f6133392d
commit 71a031342b
245 changed files with 83994 additions and 0 deletions

39
internal/dto/vote.go Normal file
View File

@@ -0,0 +1,39 @@
package dto
import (
"time"
"goyco/internal/database"
)
type VoteDTO struct {
ID uint `json:"id"`
UserID *uint `json:"user_id,omitempty"`
PostID uint `json:"post_id"`
Type string `json:"type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func ToVoteDTO(vote *database.Vote) VoteDTO {
if vote == nil {
return VoteDTO{}
}
return VoteDTO{
ID: vote.ID,
UserID: vote.UserID,
PostID: vote.PostID,
Type: string(vote.Type),
CreatedAt: vote.CreatedAt,
UpdatedAt: vote.UpdatedAt,
}
}
func ToVoteDTOs(votes []database.Vote) []VoteDTO {
dtos := make([]VoteDTO, len(votes))
for i := range votes {
dtos[i] = ToVoteDTO(&votes[i])
}
return dtos
}