model

package
v0.0.0-...-45939f7 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FruitBodyStructLevelValidation

func FruitBodyStructLevelValidation(sl validator.StructLevel)

FruitBodyStructLevelValidation contains FruitBody custom struct level validations.

Types

type Common

type Common struct {
	ID        uint64     `xorm:"pk autoincr index(pk)" json:"id"`
	IsDeleted *bool      `xorm:"default false notnull" json:"-"`
	IsEnabled *bool      `xorm:"default true notnull" json:"-"`
	CreatedAt *time.Time `xorm:"created notnull" json:"-"`
	UpdatedAt *time.Time `xorm:"updated notnull" json:"-"`
}

Common テーブル共通項目を定義

func (*Common) SetDefault

func (m *Common) SetDefault()

SetDefault sets init data

func (Common) TableName

func (Common) TableName() string

TableName should not be called

type ErrorResponse

type ErrorResponse struct {
	Errors []*ErrorResponseInner `json:"errors"`
}

ErrorResponse の定義

func NewErrorResponse

func NewErrorResponse(code string, t ErrorType, messages ...interface{}) *ErrorResponse

NewErrorResponse APIエラー時の詳細レスポンスを生成

func (*ErrorResponse) Append

func (res *ErrorResponse) Append(code string, t ErrorType, messages ...interface{})

Append adds an error to ErrorResponse

func (ErrorResponse) String

func (res ErrorResponse) String() string

String is a stringer impl

type ErrorResponseInner

type ErrorResponseInner struct {
	Code     string    `json:"code"`
	Type     ErrorType `json:"type"`
	Messages []string  `json:"messages"`
}

ErrorResponseInner の定義

type ErrorType

type ErrorType string

ErrorType エラータイプ

const (
	// ErrorAuth authentication error
	ErrorAuth ErrorType = "AuthError"
	// ErrorUnknown unknown error
	ErrorUnknown ErrorType = "UnknownError"
	// ErrorParam parameter error
	ErrorParam ErrorType = "ParamError"
	// ErrorNotFound not found error
	ErrorNotFound ErrorType = "NotFoundError"
	// ErrorLimitExceeded throttling error
	ErrorLimitExceeded ErrorType = "LimitExceededError"
)

type Fruit

type Fruit struct {
	Common    `xorm:"extends"`
	FruitBody `xorm:"extends"`
}

Fruit is a model

func (Fruit) TableName

func (Fruit) TableName() string

TableName はテーブル名を返す

type FruitBody

type FruitBody struct {
	Name  *string `json:"name" binding:"required,min=1"`
	Price *int    `json:"price"`
}

FruitBody the main data

type StructValidator

type StructValidator struct {
	// contains filtered or unexported fields
}

StructValidator defines validations for models.

func (*StructValidator) Engine

func (v *StructValidator) Engine() interface{}

Engine returns validate engine.

func (*StructValidator) ValidateStruct

func (v *StructValidator) ValidateStruct(obj interface{}) error

ValidateStruct validates struct with tags.

type User

type User struct {
	Common         `xorm:"extends"`
	Email          string     `xorm:"VARCHAR(120) notnull index(email)" json:"email"`
	EmailVerified  *bool      `xorm:"notnull" json:"email_verified"`
	LastLoginAt    *time.Time `json:"last_login_at"`
	UserPublicData `xorm:"extends"`
}

User ユーザー情報を格納

func (*User) GetPublicData

func (u *User) GetPublicData() *UserPublicData

GetPublicData は公開用のユーザー情報を取得

func (User) TableName

func (User) TableName() string

TableName represents db table name

type UserCreateBody

type UserCreateBody struct {
	Email string `binding:"email" json:"email" `
	UserProfile
}

UserCreateBody contains new user data.

type UserProfile

type UserProfile struct {
	DisplayName *string `json:"display_name"`
	About       *string `json:"about"`
	AvatarURL   *string `json:"avatar_url"`
}

UserProfile has user's editable profile data

type UserPublicData

type UserPublicData struct {
	UserID      uint64 `xorm:"-" json:"user_id"`
	UserProfile `xorm:"extends"`
}

UserPublicData has public user data

func (UserPublicData) TableName

func (UserPublicData) TableName() string

TableName represents db table name

Jump to

Keyboard shortcuts

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