models

package
v0.0.0-...-e394574 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: MIT Imports: 10 Imported by: 6

Documentation

Index

Constants

View Source
const (
	IS_LOCK_YES = 1
	IS_LOCK_NO  = -1
)

Variables

This section is empty.

Functions

func AnswerCreate

func AnswerCreate(user *Users, question *Questions, content string, orm *orm.Ormer) (int64, error)

func CreateQuestion

func CreateQuestion(categoryId int64, title string, description string, user *Users) (int64, error)

func CreateUser

func CreateUser(nickname string, email string, password string, lock string, avatar string) (int64, error)

func Init

func Init()

func UserEmailExists

func UserEmailExists(email string) bool

func UserNicknameExists

func UserNicknameExists(nickname string) bool

Types

type Answers

type Answers struct {
	User      *Users     `orm:"rel(fk)"`
	Question  *Questions `orm:"rel(fk)"`
	Id        int64      `json:"id"`
	Content   string     `json:"content"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
}

func AnswerPaginate

func AnswerPaginate(questionId string, page int64, pageSize int64) ([]Answers, *utils.BootstrapPaginator, error)

type Categories

type Categories struct {
	Id        int64        `json:"id"`
	Name      string       `json:"name"`
	CreatedAt time.Time    `json:"created_at"`
	Questions []*Questions `orm:"reverse(many)"`
}

func AllCategories

func AllCategories() ([]*Categories, error)

func FindCategoryById

func FindCategoryById(id int64) (*Categories, error)

type Questions

type Questions struct {
	User        *Users      `orm:"rel(fk)"`
	Category    *Categories `orm:"rel(fk)"`
	Id          int64       `json:"id"`
	Title       string      `json:"title"`
	Description string      `json:"description"`
	ViewNum     int         `json:"view_num"`
	IsBan       int8        `json:"is_ban"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
	AnswerAt    time.Time   `json:"answer_at"`
	AnswerCount int64       `json:"answer_count"`
	Answers     []*Answers  `orm:"reverse(many)"`
	AnswerUser  *Users      `orm:"null;rel(one)"`
}

func FindQuestionById

func FindQuestionById(id string) (*Questions, error)

func QuestionPaginate

func QuestionPaginate(page int64, pageSize int64) ([]Questions, *utils.BootstrapPaginator, error)

type Settings

type Settings struct {
	Id    int
	Name  string
	Value string
}

type Users

type Users struct {
	Id         int          `json:"id"`
	Nickname   string       `json:"nickname"`
	Avatar     string       `json:"avatar"`
	Email      string       `json:"email"`
	Password   string       `json:"-"`
	IsLock     int          `json:"is_lock"`
	Company    string       `json:"company"`
	Age        int64        `json:"age"`
	Profession string       `json:"profession"`
	Website    string       `json:"website"`
	Weibo      string       `json:"weibo"`
	Wechat     string       `json:"wechat"`
	CreatedAt  time.Time    `json:"created_at"`
	UpdatedAt  time.Time    `json:"updated_at"`
	Questions  []*Questions `orm:"reverse(many)" json:"questions"`
	Answers    []*Answers   `orm:"reverse(many)" json:"answers"`
}

func FindUserById

func FindUserById(id int) (*Users, error)

func UserExistsByEmailAndPassword

func UserExistsByEmailAndPassword(email string, password string) (*Users, error)

func (*Users) CheckHash

func (user *Users) CheckHash(giveHashed string, timeString string) bool

验证密码重置特征值

func (*Users) GenerateHashedUrl

func (user *Users) GenerateHashedUrl(baseUrl string) string

生成密码重置地址

Jump to

Keyboard shortcuts

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