user

package
v0.0.0-...-7efc56f Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserRole      int = iota // ユーザー
	AdminRole                // 管理者
	DeveloperRole            // 開発者
	OperatorRole             // 運用者
)

ユーザ権限

View Source
const (
	UnkownGender        int = iota // 未選択
	MaleGender                     // 男性
	FemaleGender                   // 女性
	NotApplicableGender            // 適用不能
)

ユーザ性別

Variables

This section is empty.

Functions

This section is empty.

Types

type Follow

type Follow struct {
	FollowID         string `gorm:"<-:false"`
	Username         string `gorm:"<-:false"`
	ThumbnailURL     string `gorm:"<-:false"`
	SelfIntroduction string `gorm:"<-:false"`
	IsFollowing      bool   `gorm:"-"`
	IsFollowed       bool   `gorm:"-"`
	FollowCount      int    `gorm:"-"`
	FollowerCount    int    `gorm:"-"`
}

Follow - フォローしているUserのエンティティ

func (*Follow) Proto

func (f *Follow) Proto() *user.Follow

type Follower

type Follower struct {
	FollowerID       string `gorm:"<-:false"`
	Username         string `gorm:"<-:false"`
	ThumbnailURL     string `gorm:"<-:false"`
	SelfIntroduction string `gorm:"<-:false"`
	IsFollowing      bool   `gorm:"-"`
	IsFollowed       bool   `gorm:"-"`
	FollowCount      int    `gorm:"-"`
	FollowerCount    int    `gorm:"-"`
}

Follower - フォローされているUserのエンティティ

func (*Follower) Proto

func (f *Follower) Proto() *user.Follower

type Followers

type Followers []*Follower

func (Followers) Proto

func (fs Followers) Proto() []*user.Follower

type Follows

type Follows []*Follow

func (Follows) Proto

func (fs Follows) Proto() []*user.Follow

type Relationship

type Relationship struct {
	ID         int       `gorm:"default:null;primaryKey;autoIncrement;<-:create"`
	FollowID   string    `gorm:"default:null"`
	FollowerID string    `gorm:"default:null"`
	CreatedAt  time.Time `gorm:"default:null"`
	UpdatedAt  time.Time `gorm:"default:null"`
}

Relationship - Relationshipエンティティ (中間テーブル)

type Repository

type Repository interface {
	Authentication(ctx context.Context) (string, error)
	List(ctx context.Context, q *database.ListQuery) (Users, error)
	ListFollow(ctx context.Context, q *database.ListQuery) (Follows, error)
	ListFollower(ctx context.Context, q *database.ListQuery) (Followers, error)
	ListInstanceID(ctx context.Context, q *database.ListQuery) ([]string, error)
	ListFollowID(ctx context.Context, userID string, userIDs ...string) ([]string, error)
	ListFollowerID(ctx context.Context, userID string, userIDs ...string) ([]string, error)
	Count(ctx context.Context, q *database.ListQuery) (int, error)
	CountRelationship(ctx context.Context, q *database.ListQuery) (int, error)
	MultiGet(ctx context.Context, userIDs []string) (Users, error)
	Get(ctx context.Context, userID string) (*User, error)
	GetAdmin(ctx context.Context, userID string) (*User, error)
	GetRelationship(ctx context.Context, followID string, followerID string) (*Relationship, error)
	GetUserIDByEmail(ctx context.Context, email string) (string, error)
	GetRelationshipIDByUserID(ctx context.Context, followID string, followerID string) (int, error)
	Create(ctx context.Context, u *User) error
	CreateWithOAuth(ctx context.Context, u *User) error
	CreateRelationship(ctx context.Context, r *Relationship) error
	Update(ctx context.Context, u *User) error
	UpdatePassword(ctx context.Context, userID string, password string) error
	Delete(ctx context.Context, userID string) error
	DeleteRelationship(ctx context.Context, relationshipID int) error
}

Repository - Userレポジトリ

type Uploader

type Uploader interface {
	Thumbnail(ctx context.Context, userID string, data []byte) (string, error)
}

Uploader - Userアップローダ

type User

type User struct {
	ID               string         `gorm:"default:null;primaryKey;<-:create"`
	Username         string         `gorm:"default:null"`
	Gender           int            `gorm:"default:null"`
	Email            string         `gorm:"default:null"`
	PhoneNumber      string         `gorm:"default:null"`
	Role             int            `gorm:"default:null"`
	Password         string         `gorm:"-"`
	ThumbnailURL     string         `gorm:"default:null"`
	SelfIntroduction string         `gorm:"default:null"`
	LastName         string         `gorm:"default:null"`
	FirstName        string         `gorm:"default:null"`
	LastNameKana     string         `gorm:"default:null"`
	FirstNameKana    string         `gorm:"default:null"`
	PostalCode       string         `gorm:"default:null"`
	Prefecture       string         `gorm:"default:null"`
	City             string         `gorm:"default:null"`
	AddressLine1     string         `gorm:"default:null"`
	AddressLine2     string         `gorm:"default:null"`
	InstanceID       string         `gorm:"default:null"`
	CreatedAt        time.Time      `gorm:"default:null;<-:create"`
	UpdatedAt        time.Time      `gorm:"default:null"`
	DeletedAt        gorm.DeletedAt `gorm:"default:null"`
	Follows          []*Follow      `gorm:"foreignKey:FollowID"`
	Followers        []*Follower    `gorm:"foreignKey:FollowerID"`
	IsFollowing      bool           `gorm:"-"`
	IsFollowed       bool           `gorm:"-"`
	FollowCount      int            `gorm:"-"`
	FollowerCount    int            `gorm:"-"`
}

User - Userエンティティ

func (*User) Admin

func (u *User) Admin() *user.Admin

func (*User) Auth

func (u *User) Auth() *user.Auth

func (*User) Profile

func (u *User) Profile() *user.UserProfile

func (*User) Proto

func (u *User) Proto() *user.User

type Users

type Users []*User

func (Users) Admin

func (us Users) Admin() []*user.Admin

func (Users) Proto

func (us Users) Proto() []*user.User

type Validation

type Validation interface {
	User(ctx context.Context, u *User) error
	Relationship(ctx context.Context, r *Relationship) error
}

Validation - Userドメインバリデーション

Jump to

Keyboard shortcuts

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