model

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 Activity added in v1.1.0

type Activity struct {
	gorm.Model
	Type        ActivityType `gorm:"size:50;not null;"`
	CampID      uint         `gorm:"not null"`
	Camp        *Camp        `gorm:"foreignKey:CampID;references:ID;constraint:OnDelete:CASCADE"`
	UserID      *string      `gorm:"size:32"` // payment_* のみ使用
	User        *User        `gorm:"foreignKey:UserID;references:ID"`
	ReferenceID uint         `gorm:"not null"` // RoomID / PaymentID / RollCallID / QuestionGroupID
	Amount      *int         // payment_* のみ使用
}

type ActivityType added in v1.1.0

type ActivityType string
const (
	ActivityTypeRoomCreated          ActivityType = "room_created"
	ActivityTypePaymentCreated       ActivityType = "payment_created"
	ActivityTypePaymentAmountChanged ActivityType = "payment_amount_changed"
	ActivityTypePaymentPaidChanged   ActivityType = "payment_paid_changed"
	ActivityTypeRollCallCreated      ActivityType = "roll_call_created"
	ActivityTypeQuestionCreated      ActivityType = "question_created"
)

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 `gorm:"uniqueIndex"`
	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 `gorm:"uniqueIndex:idx_user_id_roll_call_id"`

	RollCallID uint `gorm:"index;uniqueIndex:idx_user_id_roll_call_id"`
}

type Room

type Room struct {
	gorm.Model
	Name    string
	Members []User     `gorm:"many2many:room_members"`
	Status  RoomStatus `gorm:"constraint:OnDelete:CASCADE"`

	RoomGroupID uint
}

type RoomGroup

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

	CampID uint
}

type RoomStatus added in v1.1.0

type RoomStatus struct {
	gorm.Model
	RoomID uint    `gorm:"not null;uniqueIndex"`
	Room   *Room   `gorm:"foreignKey:RoomID;references:ID;constraint:OnDelete:CASCADE"`
	Type   *string `gorm:"size:8"`
	Topic  string  `gorm:"not null;size:64"`
}

type RoomStatusLog added in v1.1.0

type RoomStatusLog struct {
	gorm.Model
	RoomID     uint    `gorm:"not null"`
	Room       *Room   `gorm:"foreignKey:RoomID;references:ID;constraint:OnDelete:CASCADE"`
	Type       *string `gorm:"size:8"`
	Topic      string  `gorm:"not null;size:64"`
	OperatorID string  `gorm:"not null;size:32"`
	Operator   *User   `gorm:"foreignKey:OperatorID;references:ID;constraint:OnDelete:RESTRICT"`
}

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