model

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 12 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

View Source
const (
	// DirectMessageChannelRootID ダイレクトメッセージチャンネルの親チャンネルID
	DirectMessageChannelRootID = "aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaaaa"
	// MaxChannelDepth チャンネルの深さの最大
	MaxChannelDepth = 5
)
View Source
const (
	// FileTypeUserFile ユーザーアップロードファイルタイプ
	FileTypeUserFile = ""
	// FileTypeIcon ユーザーアイコンファイルタイプ
	FileTypeIcon = "icon"
	// FileTypeStamp スタンプファイルタイプ
	FileTypeStamp = "stamp"
	// FileTypeThumbnail サムネイルファイルタイプ
	FileTypeThumbnail = "thumbnail"
)

Variables

View Source
var (
	// Tables データベースのテーブルモデル
	// モデルを追加したら各自ここに追加しなければいけない
	// **順番注意**
	Tables = []interface{}{
		&Mute{},
		&MessageReport{},
		&WebhookBot{},
		&MessageStamp{},
		&Stamp{},
		&Clip{},
		&ClipFolder{},
		&UsersTag{},
		&Unread{},
		&Star{},
		&Device{},
		&Pin{},
		&FileACLEntry{},
		&File{},
		&UsersPrivateChannel{},
		&UserSubscribeChannel{},
		&Tag{},
		&ArchivedMessage{},
		&Message{},
		&Channel{},
		&UserGroupMember{},
		&UserGroup{},
		&User{},
	}

	// Constraints 外部キー制約
	Constraints = [][5]string{

		{"users_private_channels", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"users_private_channels", "channel_id", "channels(id)", "CASCADE", "CASCADE"},
		{"messages", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"messages", "channel_id", "channels(id)", "CASCADE", "CASCADE"},
		{"users_tags", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"users_tags", "tag_id", "tags(id)", "CASCADE", "CASCADE"},
		{"unreads", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"unreads", "message_id", "messages(id)", "CASCADE", "CASCADE"},
		{"devices", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"stars", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"stars", "channel_id", "channels(id)", "CASCADE", "CASCADE"},
		{"users_subscribe_channels", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"users_subscribe_channels", "channel_id", "channels(id)", "CASCADE", "CASCADE"},
		{"clips", "folder_id", "clip_folders(id)", "CASCADE", "CASCADE"},
		{"clips", "message_id", "messages(id)", "CASCADE", "CASCADE"},
		{"clips", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"clip_folders", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"pins", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"pins", "message_id", "messages(id)", "CASCADE", "CASCADE"},
		{"messages_stamps", "message_id", "messages(id)", "CASCADE", "CASCADE"},
		{"messages_stamps", "stamp_id", "stamps(id)", "CASCADE", "CASCADE"},
		{"messages_stamps", "user_id", "users(id)", "CASCADE", "CASCADE"},
		{"webhook_bots", "bot_user_id", "users(id)", "CASCADE", "CASCADE"},
	}
)
View Source
var (
	// ErrUserBotTryLogin : ユーザーエラー botユーザーでログインを試みました。botユーザーはログインできません。
	ErrUserBotTryLogin = errors.New("bot user is not allowed to login")
	// ErrUserWrongIDOrPassword : ユーザーエラー IDかパスワードが間違っています。
	ErrUserWrongIDOrPassword = errors.New("password or id is wrong")
)

Functions

func AuthenticateUser

func AuthenticateUser(user *User, password string) error

AuthenticateUser ユーザー構造体とパスワードを照合します

Types

type ArchivedMessage

type ArchivedMessage struct {
	ID        uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	MessageID uuid.UUID `gorm:"type:char(36);not null;index"`
	UserID    uuid.UUID `gorm:"type:char(36);not null"`
	Text      string    `gorm:"type:text;not null"`
	DateTime  time.Time `gorm:"precision:6"`
}

ArchivedMessage 編集前のアーカイブ化されたメッセージの構造体

func (*ArchivedMessage) TableName

func (am *ArchivedMessage) TableName() string

TableName ArchivedMessage構造体のテーブル名

type Channel

type Channel struct {
	ID        uuid.UUID  `gorm:"type:char(36);not null;primary_key"`
	Name      string     `gorm:"type:varchar(20);not null;unique_index:name_parent" validate:"channel,required"`
	ParentID  uuid.UUID  `gorm:"type:char(36);not null;unique_index:name_parent"`
	Topic     string     `gorm:"type:text;not null"`
	IsForced  bool       `gorm:"type:boolean;not null;default:false"`
	IsPublic  bool       `gorm:"type:boolean;not null;default:false"`
	IsVisible bool       `gorm:"type:boolean;not null;default:false"`
	CreatorID uuid.UUID  `gorm:"type:char(36);not null"`
	UpdaterID uuid.UUID  `gorm:"type:char(36);not null"`
	CreatedAt time.Time  `gorm:"precision:6"`
	UpdatedAt time.Time  `gorm:"precision:6"`
	DeletedAt *time.Time `gorm:"precision:6"`
}

Channel チャンネルの構造体

func (*Channel) IsDMChannel

func (ch *Channel) IsDMChannel() bool

IsDMChannel ダイレクトメッセージ用チャンネルかどうかを返します

func (*Channel) TableName

func (ch *Channel) TableName() string

TableName テーブル名を指定するメソッド

type Clip

type Clip struct {
	ID        uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	UserID    uuid.UUID `gorm:"type:char(36);not null;unique_index:user_message"`
	MessageID uuid.UUID `gorm:"type:char(36);not null;unique_index:user_message"`
	Message   Message   `gorm:"association_autoupdate:false;association_autocreate:false"`
	FolderID  uuid.UUID `gorm:"type:char(36);not null"`
	CreatedAt time.Time `gorm:"precision:6"`
	UpdatedAt time.Time `gorm:"precision:6"`
}

Clip clipの構造体

func (*Clip) TableName

func (clip *Clip) TableName() string

TableName Clipのテーブル名

type ClipFolder

type ClipFolder struct {
	ID        uuid.UUID `gorm:"type:char(36);not null;primary_key"                                            json:"id"`
	UserID    uuid.UUID `gorm:"type:char(36);not null;unique_index:user_folder"                               json:"-"`
	Name      string    `gorm:"type:varchar(30);not null;unique_index:user_folder" validate:"max=30,required" json:"name"`
	CreatedAt time.Time `gorm:"precision:6"                                                                   json:"createdAt"`
	UpdatedAt time.Time `gorm:"precision:6"                                                                   json:"-"`
}

ClipFolder クリップフォルダの構造体

func (*ClipFolder) TableName

func (*ClipFolder) TableName() string

TableName ClipFolderのテーブル名

func (*ClipFolder) Validate

func (f *ClipFolder) Validate() error

Validate 構造体を検証します

type Device

type Device struct {
	Token     string    `gorm:"type:varchar(190);not null;primary_key"`
	UserID    uuid.UUID `gorm:"type:char(36);not null;index"`
	CreatedAt time.Time `gorm:"precision:6"`
}

Device 通知デバイスの構造体

func (*Device) TableName

func (*Device) TableName() string

TableName Device構造体のテーブル名

type File

type File struct {
	ID              uuid.UUID  `gorm:"type:char(36);not null;primary_key"   json:"fileId"`
	Name            string     `gorm:"type:text;not null"                   json:"name"                  validate:"required"`
	Mime            string     `gorm:"type:text;not null"                   json:"mime"                  validate:"required"`
	Size            int64      `gorm:"type:bigint;not null"                 json:"size"                  validate:"min=0,required"`
	CreatorID       uuid.UUID  `gorm:"type:char(36);not null"               json:"-"`
	Hash            string     `gorm:"type:char(32);not null"               json:"md5"                   validate:"max=32"`
	Type            string     `gorm:"type:varchar(30);not null;default:''" json:"-"`
	HasThumbnail    bool       `gorm:"type:boolean;not null;default:false"  json:"hasThumb"`
	ThumbnailWidth  int        `gorm:"type:int;not null;default:0"          json:"thumbWidth,omitempty"  validate:"min=0"`
	ThumbnailHeight int        `gorm:"type:int;not null;default:0"          json:"thumbHeight,omitempty" validate:"min=0"`
	CreatedAt       time.Time  `gorm:"precision:6"                          json:"datetime"`
	DeletedAt       *time.Time `gorm:"precision:6"                          json:"-"`
}

File DBに格納するファイルの構造体

func (*File) GetKey

func (f *File) GetKey() string

GetKey ファイルのストレージに対するキーを返す

func (*File) GetThumbKey

func (f *File) GetThumbKey() string

GetThumbKey ファイルのサムネイルのストレージに対するキーを返す

func (*File) TableName

func (f *File) TableName() string

TableName dbのtableの名前を返します

func (*File) Validate

func (f *File) Validate() error

Validate 構造体を検証します

type FileACLEntry

type FileACLEntry struct {
	FileID uuid.UUID     `gorm:"type:char(36);primary_key;not null"`
	UserID uuid.NullUUID `gorm:"type:char(36);primary_key;not null"`
	Allow  sql.NullBool  `gorm:"not null"`
}

FileACLEntry ファイルアクセスコントロールリストエントリー構造体

func (*FileACLEntry) TableName

func (f *FileACLEntry) TableName() string

TableName FileACLEntry構造体のテーブル名

type HeartbeatStatus

type HeartbeatStatus struct {
	UserStatuses []*UserStatus `json:"userStatuses"`
	ChannelID    uuid.UUID     `json:"channelId"`
}

HeartbeatStatus Heartbeatの状態

type Message

type Message struct {
	ID        uuid.UUID  `gorm:"type:char(36);not null;primary_key"`
	UserID    uuid.UUID  `gorm:"type:char(36);not null;"`
	ChannelID uuid.UUID  `gorm:"type:char(36);not null;index"`
	Text      string     `gorm:"type:text;not null"                 validate:"required"`
	CreatedAt time.Time  `gorm:"precision:6;index"`
	UpdatedAt time.Time  `gorm:"precision:6"`
	DeletedAt *time.Time `gorm:"precision:6;index"`
}

Message データベースに格納するmessageの構造体

func (*Message) TableName

func (m *Message) TableName() string

TableName DBの名前を指定するメソッド

func (*Message) Validate

func (m *Message) Validate() error

Validate 構造体を検証します

type MessageReport

type MessageReport struct {
	ID        uuid.UUID  `gorm:"type:char(36);not null;primary_key"                   json:"id"`
	MessageID uuid.UUID  `gorm:"type:char(36);not null;unique_index:message_reporter" json:"messageId"`
	Reporter  uuid.UUID  `gorm:"type:char(36);not null;unique_index:message_reporter" json:"reporter"`
	Reason    string     `gorm:"type:text;not null"                                   json:"reason"`
	CreatedAt time.Time  `gorm:"precision:6;index"                                    json:"createdAt"`
	DeletedAt *time.Time `gorm:"precision:6"                                          json:"-"`
}

MessageReport メッセージレポート構造体

func (*MessageReport) TableName

func (*MessageReport) TableName() string

TableName MessageReport構造体のテーブル名

type MessageStamp

type MessageStamp struct {
	MessageID uuid.UUID `gorm:"type:char(36);not null;primary_key;index" json:"-"`
	StampID   uuid.UUID `gorm:"type:char(36);not null;primary_key"       json:"stampId"`
	UserID    uuid.UUID `gorm:"type:char(36);not null;primary_key"       json:"userId"`
	Count     int       `gorm:"type:int;not null"                        json:"count"`
	CreatedAt time.Time `gorm:"precision:6"                              json:"createdAt"`
	UpdatedAt time.Time `gorm:"precision:6;index"                        json:"updatedAt"`
}

MessageStamp メッセージスタンプ構造体

func (*MessageStamp) TableName

func (*MessageStamp) TableName() string

TableName メッセージスタンプのテーブル

type Mute

type Mute struct {
	UserID    uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	ChannelID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}

Mute ミュートチャンネルのレコード

func (*Mute) TableName

func (m *Mute) TableName() string

TableName Mute構造体のテーブル名

type Pin

type Pin struct {
	ID        uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	MessageID uuid.UUID `gorm:"type:char(36);not null;unique"`
	Message   Message   `gorm:"association_autoupdate:false;association_autocreate:false"`
	UserID    uuid.UUID `gorm:"type:char(36);not null"`
	CreatedAt time.Time `gorm:"precision:6"`
}

Pin ピン留めのレコード

func (*Pin) TableName

func (pin *Pin) TableName() string

TableName ピン留めテーブル名

type Stamp

type Stamp struct {
	ID        uuid.UUID  `gorm:"type:char(36);not null;primary_key" json:"id"`
	Name      string     `gorm:"type:varchar(32);not null;unique"   json:"name"      validate:"name,required"`
	CreatorID uuid.UUID  `gorm:"type:char(36);not null"             json:"creatorId"`
	FileID    uuid.UUID  `gorm:"type:char(36);not null"             json:"fileId"`
	CreatedAt time.Time  `gorm:"precision:6"                        json:"createdAt"`
	UpdatedAt time.Time  `gorm:"precision:6"                        json:"updatedAt"`
	DeletedAt *time.Time `gorm:"precision:6"                        json:"-"`
}

Stamp スタンプ構造体

func (*Stamp) TableName

func (*Stamp) TableName() string

TableName スタンプテーブル名を取得します

func (*Stamp) Validate

func (s *Stamp) Validate() error

Validate 構造体を検証します

type Star

type Star struct {
	UserID    uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	ChannelID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}

Star starの構造体

func (*Star) TableName

func (star *Star) TableName() string

TableName dbの名前を指定する

type Tag

type Tag struct {
	ID         uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	Name       string    `gorm:"type:varchar(30);not null;unique"   validate:"required,max=30"`
	Restricted bool      `gorm:"type:boolean;not null;default:false"`
	Type       string    `gorm:"type:varchar(30);not null;default:''"`
	CreatedAt  time.Time `gorm:"precision:6"`
	UpdatedAt  time.Time `gorm:"precision:6"`
}

Tag tag_idの管理をする構造体

func (*Tag) TableName

func (*Tag) TableName() string

TableName DBの名前を指定

func (*Tag) Validate

func (t *Tag) Validate() error

Validate 構造体を検証します

type Unread

type Unread struct {
	UserID    uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	MessageID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	CreatedAt time.Time `gorm:"precision:6"`
}

Unread 未読レコード

func (*Unread) TableName

func (unread *Unread) TableName() string

TableName テーブル名

type User

type User struct {
	ID          uuid.UUID         `gorm:"type:char(36);not null;primary_key"`
	Name        string            `gorm:"type:varchar(32);not null;unique"     validate:"required,name"`
	DisplayName string            `gorm:"type:varchar(64);not null;default:''" validate:"max=64"`
	Password    string            `gorm:"type:char(128);not null;default:''"   validate:"required,max=128"`
	Salt        string            `gorm:"type:char(128);not null;default:''"   validate:"required,max=128"`
	Icon        uuid.UUID         `gorm:"type:char(36);not null"`
	Status      UserAccountStatus `gorm:"type:tinyint;not null;default:0"`
	Bot         bool              `gorm:"type:boolean;not null;default:false"`
	Role        string            `gorm:"type:varchar(30);not null;default:'user'"    validate:"required"`
	TwitterID   string            `gorm:"type:varchar(15);not null;default:''" validate:"twitterid"`
	LastOnline  *time.Time        `gorm:"precision:6"`
	CreatedAt   time.Time         `gorm:"precision:6"`
	UpdatedAt   time.Time         `gorm:"precision:6"`
}

User userの構造体

func (*User) GetName

func (user *User) GetName() string

GetName ユーザー名を取得します

func (*User) GetUID

func (user *User) GetUID() uuid.UUID

GetUID ユーザーIDを取得します

func (*User) TableName

func (user *User) TableName() string

TableName dbの名前を指定する

func (*User) Validate

func (user *User) Validate() error

Validate 構造体を検証します

type UserAccountStatus

type UserAccountStatus int

UserAccountStatus ユーザーアカウント状態

const (
	// UserAccountStatusDeactivated ユーザーアカウント状態: 凍結
	UserAccountStatusDeactivated UserAccountStatus = 0
	// UserAccountStatusActive ユーザーアカウント状態: 有効
	UserAccountStatusActive UserAccountStatus = 1
	// UserAccountStatusSuspended ユーザーアカウント状態: 一時停止
	UserAccountStatusSuspended UserAccountStatus = 2
)

type UserGroup

type UserGroup struct {
	ID          uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	Name        string    `gorm:"type:varchar(30);not null;unique"   validate:"max=30,required"`
	Description string    `gorm:"type:text;not null"`
	Type        string    `gorm:"type:varchar(30);not null;default:''"`
	AdminUserID uuid.UUID `gorm:"type:char(36);not null"`
	CreatedAt   time.Time `gorm:"precision:6"`
	UpdatedAt   time.Time `gorm:"precision:6"`
}

UserGroup ユーザーグループ構造体

func (*UserGroup) TableName

func (*UserGroup) TableName() string

TableName UserGroup構造体のテーブル名

func (*UserGroup) Validate

func (g *UserGroup) Validate() error

Validate 構造体を検証します

type UserGroupMember

type UserGroupMember struct {
	GroupID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	UserID  uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}

UserGroupMember ユーザーグループメンバー構造体

func (*UserGroupMember) TableName

func (*UserGroupMember) TableName() string

TableName UserGroupMember構造体のテーブル名

type UserStampHistory

type UserStampHistory struct {
	StampID  uuid.UUID `json:"stampId"`
	Datetime time.Time `json:"datetime"`
}

UserStampHistory スタンプ履歴構造体

type UserStatus

type UserStatus struct {
	UserID   uuid.UUID `json:"userId"`
	Status   string    `json:"status"`
	LastTime time.Time `json:"-"`
}

UserStatus userの状態

type UserSubscribeChannel

type UserSubscribeChannel struct {
	UserID    uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	ChannelID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}

UserSubscribeChannel ユーザー・通知チャンネル対構造体

func (*UserSubscribeChannel) TableName

func (*UserSubscribeChannel) TableName() string

TableName UserNotifiedChannel構造体のテーブル名

type UsersPrivateChannel

type UsersPrivateChannel struct {
	UserID    uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	ChannelID uuid.UUID `gorm:"type:char(36);not null;primary_key"`
}

UsersPrivateChannel UsersPrivateChannelsの構造体

func (*UsersPrivateChannel) TableName

func (upc *UsersPrivateChannel) TableName() string

TableName テーブル名を指定するメソッド

type UsersTag

type UsersTag struct {
	UserID    uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	TagID     uuid.UUID `gorm:"type:char(36);not null;primary_key"`
	Tag       Tag       `gorm:"association_autoupdate:false;association_autocreate:false"`
	IsLocked  bool      `gorm:"type:boolean;not null;default:false"`
	CreatedAt time.Time `gorm:"precision:6;index"`
	UpdatedAt time.Time `gorm:"precision:6"`
}

UsersTag userTagの構造体

func (*UsersTag) TableName

func (*UsersTag) TableName() string

TableName DBの名前を指定

type Webhook

type Webhook interface {
	GetID() uuid.UUID
	GetBotUserID() uuid.UUID
	GetName() string
	GetDescription() string
	GetChannelID() uuid.UUID
	GetCreatorID() uuid.UUID
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
}

Webhook Webhook

type WebhookBot

type WebhookBot struct {
	ID          uuid.UUID  `gorm:"type:char(36);not null;primary_key"`
	BotUserID   uuid.UUID  `gorm:"type:char(36);not null;unique"`
	BotUser     User       `gorm:"foreignkey:BotUserID"`
	Description string     `gorm:"type:text;not null"`
	ChannelID   uuid.UUID  `gorm:"type:char(36);not null"`
	CreatorID   uuid.UUID  `gorm:"type:char(36);not null"`
	CreatedAt   time.Time  `gorm:"precision:6"`
	UpdatedAt   time.Time  `gorm:"precision:6"`
	DeletedAt   *time.Time `gorm:"precision:6"`
}

WebhookBot DB用WebhookBot構造体

func (*WebhookBot) GetBotUserID

func (w *WebhookBot) GetBotUserID() uuid.UUID

GetBotUserID WebhookUserのIDを返します

func (*WebhookBot) GetChannelID

func (w *WebhookBot) GetChannelID() uuid.UUID

GetChannelID Webhookのデフォルト投稿チャンネルのIDを返します

func (*WebhookBot) GetCreatedAt

func (w *WebhookBot) GetCreatedAt() time.Time

GetCreatedAt Webhookの作成日時を返します

func (*WebhookBot) GetCreatorID

func (w *WebhookBot) GetCreatorID() uuid.UUID

GetCreatorID Webhookの製作者IDを返します

func (*WebhookBot) GetDescription

func (w *WebhookBot) GetDescription() string

GetDescription Webhookの説明を返します

func (*WebhookBot) GetID

func (w *WebhookBot) GetID() uuid.UUID

GetID WebhookIDを返します

func (*WebhookBot) GetName

func (w *WebhookBot) GetName() string

GetName Webhookの名前を返します

func (*WebhookBot) GetUpdatedAt

func (w *WebhookBot) GetUpdatedAt() time.Time

GetUpdatedAt Webhookの更新日時を返します

func (*WebhookBot) TableName

func (*WebhookBot) TableName() string

TableName Webhookのテーブル名

Jump to

Keyboard shortcuts

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