85957ed5db
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 36s
CI / test-go-edu-search (push) Successful in 33s
CI / test-python-klausur (push) Failing after 2m45s
CI / test-python-agent-core (push) Successful in 23s
CI / test-nodejs-website (push) Successful in 27s
77 lines
2.8 KiB
Go
77 lines
2.8 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type ParentAccount struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
CreatedByUserID uuid.UUID `json:"created_by_user_id" db:"created_by_user_id"`
|
|
Email string `json:"email" db:"email"`
|
|
PreferredLanguage string `json:"preferred_language" db:"preferred_language"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
}
|
|
|
|
type ParentChild struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
ParentID uuid.UUID `json:"parent_id" db:"parent_id"`
|
|
TTClassID uuid.UUID `json:"tt_class_id" db:"tt_class_id"`
|
|
FirstName string `json:"first_name" db:"first_name"`
|
|
LastName string `json:"last_name" db:"last_name"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
// Joined for display
|
|
ClassName string `json:"class_name,omitempty"`
|
|
}
|
|
|
|
// Request DTOs
|
|
|
|
// InviteParentRequest is what the teacher posts to invite one parent for one
|
|
// child. The endpoint creates the account if it doesn't exist, the child
|
|
// row, and a fresh magic_link. Same parent can be invited for several
|
|
// children (re-using the account).
|
|
type InviteParentRequest struct {
|
|
Email string `json:"email" binding:"required,email"`
|
|
PreferredLanguage string `json:"preferred_language"`
|
|
ChildFirstName string `json:"child_first_name" binding:"required"`
|
|
ChildLastName string `json:"child_last_name" binding:"required"`
|
|
TTClassID string `json:"tt_class_id" binding:"required,uuid"`
|
|
}
|
|
|
|
// InviteParentResponse carries the freshly-minted magic-link path so the
|
|
// teacher can copy it into Matrix/Email manually (mass-send comes from the
|
|
// notification worker in Phase 9d).
|
|
type InviteParentResponse struct {
|
|
Parent ParentAccount `json:"parent"`
|
|
Child ParentChild `json:"child"`
|
|
MagicToken string `json:"magic_token"`
|
|
MagicURL string `json:"magic_url"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
}
|
|
|
|
// ParentInviteListItem is the teacher-facing list row — one entry per
|
|
// (parent, child) pair, with the joined class name.
|
|
type ParentInviteListItem struct {
|
|
ParentID uuid.UUID `json:"parent_id"`
|
|
Email string `json:"email"`
|
|
PreferredLanguage string `json:"preferred_language"`
|
|
ChildID uuid.UUID `json:"child_id"`
|
|
ChildFirstName string `json:"child_first_name"`
|
|
ChildLastName string `json:"child_last_name"`
|
|
ClassID uuid.UUID `json:"class_id"`
|
|
ClassName string `json:"class_name"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// RedeemMagicLinkRequest is what /parent/auth/redeem expects.
|
|
type RedeemMagicLinkRequest struct {
|
|
Token string `json:"token" binding:"required"`
|
|
}
|
|
|
|
// ParentMe is what /parent/me returns: the account + every linked child.
|
|
type ParentMe struct {
|
|
Parent ParentAccount `json:"parent"`
|
|
Children []ParentChild `json:"children"`
|
|
}
|