model

package
v0.0.0-...-81f72a3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserStatusNormal int = iota + 1
	UserStatusClosed
)

Variables

This section is empty.

Functions

func NewDBEngine

func NewDBEngine(databaseSetting *setting.DatabaseSettingS) (*gorm.DB, error)

Types

type Attachment

type Attachment struct {
	*Model
	UserID    int64          `json:"user_id"`
	FileSize  int64          `json:"file_size"`
	ImgWidth  int            `json:"img_width"`
	ImgHeight int            `json:"img_height"`
	Type      AttachmentType `json:"type"`
	Content   string         `json:"content"`
}

func (*Attachment) Create

func (a *Attachment) Create(db *gorm.DB) (*Attachment, error)

type AttachmentType

type AttachmentType int
const (
	ATTACHMENT_TYPE_IMAGE AttachmentType = iota + 1
	ATTACHMENT_TYPE_VIDEO
	ATTACHMENT_TYPE_OTHER
)

type ConditionsT

type ConditionsT map[string]interface{}

type Model

type Model struct {
	ID         int64                 `gorm:"primary_key" json:"id"`
	CreatedOn  int64                 `json:"created_on"`
	ModifiedOn int64                 `json:"modified_on"`
	DeletedOn  int64                 `json:"deleted_on"`
	IsDel      soft_delete.DeletedAt `gorm:"softDelete:flag" json:"is_del"`
}

公共Model

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(tx *gorm.DB) (err error)

func (*Model) BeforeUpdate

func (m *Model) BeforeUpdate(tx *gorm.DB) (err error)

type User

type User struct {
	*Model
	Nickname string `json:"nickname"`
	Username string `json:"username"`
	Phone    string `json:"phone"`
	Password string `json:"password"`
	Salt     string `json:"salt"`
	Status   int    `json:"status"`
	Avatar   string `json:"avatar"`
	IsAdmin  bool   `json:"is_admin"`
}

func (*User) Create

func (u *User) Create(db *gorm.DB) (*User, error)

func (*User) Format

func (u *User) Format() *UserFormated

func (*User) Get

func (u *User) Get(db *gorm.DB) (*User, error)

func (*User) List

func (u *User) List(db *gorm.DB, conditions *ConditionsT, offset, limit int) ([]*User, error)

func (*User) Update

func (u *User) Update(db *gorm.DB) error

type UserFormated

type UserFormated struct {
	ID       int64  `json:"id"`
	Nickname string `json:"nickname"`
	Username string `json:"username"`
	Status   int    `json:"status"`
	Avatar   string `json:"avatar"`
	IsAdmin  bool   `json:"is_admin"`
}

Jump to

Keyboard shortcuts

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