66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package domain
|
|
|
|
import "time"
|
|
|
|
type Family struct {
|
|
ID int64
|
|
Name string
|
|
OwnerID int64
|
|
TelegramChatID *int64
|
|
TelegramChatName *string
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type FamilyRole string
|
|
|
|
const (
|
|
FamilyRoleOwner FamilyRole = "owner"
|
|
FamilyRoleAdmin FamilyRole = "admin"
|
|
FamilyRoleMember FamilyRole = "member"
|
|
FamilyRoleChild FamilyRole = "child"
|
|
)
|
|
|
|
type FamilyMember struct {
|
|
ID int64
|
|
FamilyID int64
|
|
UserID int64
|
|
Role FamilyRole
|
|
JoinedAt time.Time
|
|
}
|
|
|
|
type CreateFamilyRequest struct {
|
|
Name string `json:"name"`
|
|
OwnerID int64 `json:"owner_id"`
|
|
TelegramChatID *int64 `json:"telegram_chat_id"`
|
|
TelegramChatName *string `json:"telegram_chat_name"`
|
|
}
|
|
|
|
type UpdateFamilyRequest struct {
|
|
Name *string `json:"name"`
|
|
TelegramChatID *int64 `json:"telegram_chat_id"`
|
|
TelegramChatName *string `json:"telegram_chat_name"`
|
|
}
|
|
|
|
type FamilyResponse struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
OwnerID int64 `json:"owner_id"`
|
|
TelegramChatID *int64 `json:"telegram_chat_id"`
|
|
TelegramChatName *string `json:"telegram_chat_name"`
|
|
CreatedAt string `json:"created_at"`
|
|
UpdatedAt string `json:"updated_at"`
|
|
}
|
|
|
|
func (response *FamilyResponse) ModelToResponse(f *Family) FamilyResponse {
|
|
return FamilyResponse{
|
|
ID: f.ID,
|
|
Name: f.Name,
|
|
OwnerID: f.OwnerID,
|
|
TelegramChatID: f.TelegramChatID,
|
|
TelegramChatName: f.TelegramChatName,
|
|
CreatedAt: f.CreatedAt.Format(time.RFC3339),
|
|
UpdatedAt: f.UpdatedAt.Format(time.RFC3339),
|
|
}
|
|
}
|