chore: add lab5 files and merge env.example.

This commit is contained in:
Голиков Maximillian Антон
2026-11-14 16:12:32 +03:00
parent 470d9d6f1e
commit 0d1a4261f8
93 changed files with 7085 additions and 11 deletions
@@ -0,0 +1,60 @@
package dto
import (
"encoding/hex"
"high-loud-apps-labs/internal/domain"
)
type VariantResponse struct {
Name string `json:"name"`
ContentType string `json:"content_type"`
SizeBytes int64 `json:"size_bytes"`
Width int `json:"width"`
Height int `json:"height"`
SHA256 string `json:"sha256"`
}
type AttachmentResponse struct {
ID string `json:"id"`
ChatID string `json:"chat_id"`
OwnerID string `json:"owner_id"`
Filename string `json:"filename"`
ContentType string `json:"content_type"`
SizeBytes int64 `json:"size_bytes"`
SHA256 string `json:"sha256"`
Status string `json:"status"`
Variants []VariantResponse `json:"variants"`
ErrorCode *string `json:"error_code"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
func AttachmentFromDomain(a *domain.Attachment) AttachmentResponse {
variants := make([]VariantResponse, len(a.Variants))
for i, v := range a.Variants {
variants[i] = VariantResponse{
Name: v.Name,
ContentType: v.ContentType,
SizeBytes: v.SizeBytes,
Width: v.Width,
Height: v.Height,
SHA256: hex.EncodeToString(v.SHA256),
}
}
errCode := a.ErrorCode
return AttachmentResponse{
ID: a.ID,
ChatID: a.ChatID,
OwnerID: a.OwnerID,
Filename: a.Filename,
ContentType: a.ContentType,
SizeBytes: a.SizeBytes,
SHA256: hex.EncodeToString(a.SHA256),
Status: string(a.Status),
Variants: variants,
ErrorCode: errCode,
CreatedAt: a.CreatedAt.UTC().Format(timeFormat),
UpdatedAt: a.UpdatedAt.UTC().Format(timeFormat),
}
}