model

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists = errors.New("already exists")
	ErrForbidden     = errors.New("forbidden")
	ErrNotFound      = errors.New("not found")
)

Functions

func GetAllModels

func GetAllModels() []any

全モデルを書いておく

Types

type Answer

type Answer struct {
	gorm.Model
	QuestionID        uint         `gorm:"uniqueIndex:idx_question_id_user_id"`
	UserID            string       `gorm:"uniqueIndex:idx_question_id_user_id"`
	Type              QuestionType `gorm:"type:enum('free_text', 'free_number', 'single', 'multiple')"`
	FreeTextContent   *string
	FreeNumberContent *float64
	SelectedOptions   []Option `gorm:"many2many:answer_options;ForeignKey:id;References:id"`
}

type Camp

type Camp struct {
	gorm.Model
	DisplayID          string
	Name               string
	Guidebook          string
	IsDraft            bool
	IsPaymentOpen      bool
	IsRegistrationOpen bool
	DateStart          time.Time
	DateEnd            time.Time

	Participants   []User `gorm:"many2many:camp_participants;"`
	Payments       []Payment
	Events         []Event
	QuestionGroups []QuestionGroup
	RollCalls      []RollCall
	RoomGroups     []RoomGroup
	Images         []Image
}

type Event

type Event struct {
	gorm.Model
	Type         EventType `gorm:"type:enum('duration', 'moment', 'official')"`
	Name         string
	Description  string
	Location     string
	TimeStart    time.Time // MomentEventのtimeもTimeStartとして扱う
	TimeEnd      *time.Time
	OrganizerID  *string
	DisplayColor *string

	CampID uint
}

type EventType

type EventType string
const (
	EventTypeDuration EventType = "duration"
	EventTypeMoment   EventType = "moment"
	EventTypeOfficial EventType = "official"
)

type Image

type Image struct {
	gorm.Model

	CampID uint
}

type Message

type Message struct {
	gorm.Model
	TargetUserID string
	Content      string
	SendAt       time.Time
	SentAt       *time.Time // 送信時刻。nilの場合は未送信
}

type Option

type Option struct {
	gorm.Model
	QuestionID uint
	Content    string
}

type Payment

type Payment struct {
	gorm.Model
	Amount     int
	AmountPaid int
	UserID     string

	CampID uint
}

type Question

type Question struct {
	gorm.Model
	Type            QuestionType `gorm:"type:enum('free_text', 'free_number', 'single', 'multiple')"`
	QuestionGroupID uint
	Title           string
	Description     *string
	IsPublic        bool
	IsOpen          bool
	IsRequired      bool `gorm:"not null;default:false"`
	Options         []Option

	Answers []Answer
}

type QuestionGroup

type QuestionGroup struct {
	gorm.Model
	Name        string
	Description *string
	Due         time.Time
	Questions   []Question

	CampID uint
}

type QuestionType

type QuestionType string
const (
	FreeTextQuestion       QuestionType = "free_text"
	FreeNumberQuestion     QuestionType = "free_number"
	SingleChoiceQuestion   QuestionType = "single"
	MultipleChoiceQuestion QuestionType = "multiple"
)

type RollCall

type RollCall struct {
	gorm.Model
	Name        string
	Description string
	Options     []string `gorm:"serializer:json"`
	Subjects    []User   `gorm:"many2many:roll_call_subjects;"`

	Reactions []RollCallReaction

	CampID uint `gorm:"not null"`
}

type RollCallReaction

type RollCallReaction struct {
	gorm.Model
	Content string
	UserID  string

	RollCallID uint `gorm:"index"`
}

type Room

type Room struct {
	gorm.Model
	Name    string
	Members []User `gorm:"many2many:room_members"`

	RoomGroupID uint
}

type RoomGroup

type RoomGroup struct {
	gorm.Model
	Name  string
	Rooms []Room

	CampID uint
}

type User

type User struct {
	ID        string `gorm:"primaryKey;size:32"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	IsStaff   bool           `gorm:"index"`

	Answers         []Answer
	Payments        []Payment
	OrganizedEvents []Event   `gorm:"foreignKey:OrganizerID"`
	TargetMessages  []Message `gorm:"foreignKey:TargetUserID"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL