model

package
v0.0.0-...-263fddb Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BCryptPassword

func BCryptPassword(pwdWithSalt string) string

BCryptPassword encode Password

func GenerateJwtAuthToken

func GenerateJwtAuthToken(claims *PayloadClaims) (string, error)

GenerateJwtAuthToken generate a new jwtAuthToken

func RandomString

func RandomString(strLen int) string

RandomString returns the String

func ValidateParams

func ValidateParams(c *gin.Context, params ...string) []gin.H

ValidateParams 校验参数from c.Param 不能为空

func ValidatePostFromParams

func ValidatePostFromParams(c *gin.Context, params ...string) []gin.H

ValidatePostFromParams 校验参数from c.PostForm不能为空

func VerifyingPassword

func VerifyingPassword(crypt, pwdWithSalt string) bool

VerifyingPassword Verifying Password

Types

type Channel

type Channel struct {
	Model
	Name string `gorm:"not null" json:"name"`
	Slug string `gorm:"not null"`
}

Channel mode

type Model

type Model struct {
	ID        uint      `gorm:"primary_key" json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Model rewrite gorm model

type Payload

type Payload struct {
	UserID uint   `json:"user_id"`
	Name   string `json:"name"`
}

Payload data

func CheckWebSocketToken

func CheckWebSocketToken(r *http.Request) (*Payload, error)

CheckWebSocketToken validate user jwtToken from websocket

func ValidateAuthToken

func ValidateAuthToken(tokenString string) (*Payload, error)

ValidateAuthToken validate user jwtToken

type PayloadClaims

type PayloadClaims struct {
	Data Payload `json:"data"`
	jwt.StandardClaims
}

PayloadClaims data

type Reply

type Reply struct {
	Model
	ThreadID uint
	UserID   uint `gorm:"not null" json:"user_id"`
	User     User
	Body     string
}

Reply model

func (*Reply) With

func (r *Reply) With(DB *gorm.DB, with ...interface{}) *Reply

With load data

type Thread

type Thread struct {
	Model
	UserID       uint `gorm:"not null" json:"user_id"`
	User         User
	Replies      []Reply
	ChannelID    uint   `gorm:"not null" json:"channel_id"`
	RepliesCount uint   `json:"replies_count"`
	Title        string `gorm:"not null" json:"title"`
	Body         string `gorm:"not null;type:text" json:"body"`
}

Thread model

func (*Thread) ThreadPath

func (t *Thread) ThreadPath() string

ThreadPath return a path

func (*Thread) With

func (t *Thread) With(DB *gorm.DB, with ...interface{}) *Thread

With load data

type User

type User struct {
	Model
	Name          string `gorm:"not null" json:"name" json:"name"`
	Email         string `gorm:"not null;unique_index:users_email_unique" json:"email"`
	Password      string `gorm:"not null" json:"-"`
	RememberToken string `gorm:"size:100" json:"-"`
}

User model

func (*User) Username

func (u *User) Username() string

Username user login name

Jump to

Keyboard shortcuts

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