light

package module
v0.0.0-...-f97ce34 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

README

go-light

fastest development framework

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllFields

func GetAllFields(tableName string, args ...string) ([]string, error)

func GetCountFields

func GetCountFields(tableName string) ([]string, error)

func GetCreateFields

func GetCreateFields(tableName string) ([]string, error)

func GetFields

func GetFields(entity Tabler, args ...string) ([]string, error)

func GetFieldsPointers

func GetFieldsPointers(u interface{}, args ...string) []interface{}

func GetTables

func GetTables() map[string]Table

func GetUpdateFields

func GetUpdateFields(tableName string) ([]string, error)

func RegisterEntities

func RegisterEntities(entities ...Tabler)

register entities

Types

type AuthService

type AuthService interface {
	SendCode(ctx context.Context, req *request.PhoneCodeRequest) bool
	CheckCode(ctx context.Context, req *request.CheckCodeRequest) (*request.AuthTokenData, error)
	EmailActivation(ctx context.Context, req *request.EmailActivationRequest) error
	EmailVerification(ctx context.Context, req *request.EmailVerificationRequest) (*request.AuthTokenData, error)
	SocialCallback(ctx context.Context, state string) (string, error)
	Oauth2Token(ctx context.Context, tokenRequest request.StateRequest) (*request.AuthTokenData, error)
	EmailLogin(ctx context.Context, req *request.EmailLoginRequest) (*request.AuthTokenData, error)
	RefreshToken(ctx context.Context, req *request.RefreshTokenRequest) (*request.AuthTokenData, error)
}

type Condition

type Condition struct {
	Equal       *sq.Eq
	In          *In
	NotIn       *In
	Other       *Other
	Order       *Order
	LimitOffset *LimitOffset
}

type Constraint

type Constraint struct {
	Index     bool
	Unique    bool
	FieldName string
}

type Constraints

type Constraints struct {
	Name string
	Type string
}

type Field

type Field struct {
	Name       string
	Type       string
	Default    string
	Constraint Constraint
	TableName  string
}

type In

type In struct {
	Field string
	Args  []interface{}
}

type LimitOffset

type LimitOffset struct {
	Offset int64
	Limit  int64
}

type Order

type Order struct {
	Field string
	Asc   bool
}

type Other

type Other struct {
	Condition string
	Args      []interface{}
}

type Repositories

type Repositories struct {
	Users UserRepository
}

type Table

type Table struct {
	Name        string
	Fields      []Field
	FieldsMap   map[string]Field
	Constraints []Constraint
	Entity      Tabler
}

func (Table) CreateQuery

func (t Table) CreateQuery() string

type Tabler

type Tabler interface {
	TableName() string
	OnCreate() string
}

type User

type User struct {
	UUID           types.NullUUID    `json:"user_id" db:"uuid" ops:"create" orm_type:"binary(16)" orm_default:"not null primary key"`
	Role           types.NullInt64   `json:"role" db:"role" orm_type:"int" orm_default:"null" ops:"update"`
	Phone          types.NullString  `json:"phone" db:"phone" ops:"update,create" orm_type:"varchar(34)" orm_index:"index,unique"`
	Email          types.NullString  `json:"email" db:"email" ops:"update,create" orm_type:"varchar(89)" orm_index:"index,unique"`
	Avatar         types.NullString  `json:"profile_image" db:"avatar" ops:"update" orm_type:"varchar(144)"`
	Password       types.NullString  `json:"password,omitempty" db:"password" ops:"create" orm_type:"varchar(60)"`
	Active         types.NullBool    `json:"active" db:"active" ops:"create,update" orm_type:"boolean"`
	Name           types.NullString  `json:"name" db:"name" ops:"update,create" orm_type:"varchar(55)"`
	SecondName     types.NullString  `json:"second_name" db:"second_name" ops:"update,create" orm_type:"varchar(55)"`
	EmailVerified  types.NullBool    `json:"email_verified" db:"email_verified" orm_type:"boolean"`
	Description    types.NullString  `json:"description" db:"description" ops:"update,create" orm_type:"varchar(233)"`
	NickName       types.NullString  `json:"nickname" db:"nickname" ops:"update,create" orm_type:"varchar(30)"`
	ShowSubs       types.NullBool    `json:"show_subs" db:"show_subs" ops:"update,create" orm_type:"boolean"`
	Cost           types.NullFloat64 `json:"cost" db:"cost" ops:"update,create" orm_type:"decimal(13,4)"`
	Trial          types.NullBool    `json:"trial" db:"trial" ops:"update,create" orm_type:"boolean"`
	Moderated      types.NullBool    `json:"moderated" db:"moderated" ops:"update,create" orm_type:"boolean" orm_default:"null"`
	NotifyEmail    types.NullBool    `json:"notify_email" db:"notify_email" ops:"update,create" orm_type:"boolean"`
	NotifyTelegram types.NullBool    `json:"notify_telegram" db:"notify_telegram" ops:"update,create" orm_type:"boolean"`
	NotifyPush     types.NullBool    `json:"notify_push" db:"notify_push" ops:"update,create" orm_type:"boolean"`
	Language       types.NullInt64   `json:"language" db:"language" ops:"update,create" orm_type:"int"`
	FacebookID     types.NullInt64   `json:"facebook_id" db:"facebook_id" ops:"update,create" orm_type:"bigint unsigned"`
	GoogleID       types.NullString  `json:"google_id" db:"google_id" ops:"update,create" orm_type:"varchar(21)"`
	Likes          types.NullUint64  `json:"likes_count" db:"likes" orm_type:"bigint unsigned" orm_default:"null" orm_index:"index" ops:"count"`
	Subscribes     types.NullUint64  `json:"subscribes_count" db:"subscribes" orm_type:"bigint unsigned" orm_default:"null" orm_index:"index" ops:"count"`
	Subscribers    types.NullUint64  `json:"subscribers_count" db:"subscribers" orm_type:"bigint unsigned" orm_default:"null" orm_index:"index" ops:"count"`
	CreatedAt      time.Time         `json:"created_at" db:"created_at" orm_type:"timestamp" orm_default:"default (now()) not null" orm_index:"index"`
	UpdatedAt      time.Time         `` /* 135-byte string literal not displayed */
	DeletedAt      types.NullTime    `json:"deleted_at" db:"deleted_at" orm_type:"timestamp" orm_default:"null" orm_index:"index"`
}

func (User) OnCreate

func (u User) OnCreate() string

func (User) TableName

func (u User) TableName() string

type UserRepository

type UserRepository interface {
	Update(ctx context.Context, user User) error
	SetPassword(ctx context.Context, user User) error

	Find(ctx context.Context, user User) (User, error)
	FindAll(ctx context.Context) ([]User, error)
	FindLimitOffset(ctx context.Context, limit, offset uint64) ([]User, error)
	FindByPhone(ctx context.Context, user User) (User, error)
	FindByEmail(ctx context.Context, user User) (User, error)
	FindByNickname(ctx context.Context, user User) (User, error)
	FindLikeNickname(ctx context.Context, nickname string) ([]User, error)
	FindByFacebook(ctx context.Context, user User) (User, error)
	FindByGoogle(ctx context.Context, user User) (User, error)
	Count(ctx context.Context, user User, field, ops string) (User, error)

	CreateUser(ctx context.Context, user User) error
	CreateUserByEmailPassword(ctx context.Context, user User) error

	Listx(ctx context.Context, condition Condition) ([]User, error)
}

Directories

Path Synopsis
cmd
Package classification light.
Package classification light.

Jump to

Keyboard shortcuts

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