model

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	GORMBase
	Content          string      `json:"content" gorm:"type:varchar(4000)"`
	Type             int         `json:"type"`
	Question         Question    `json:"question" gorm:"ForeignKey:QuestionID"`
	QuestionID       int         `json:"questionID"`
	AnswerProfile    Profile     `json:"answerProfile" gorm:"ForeignKey:AnswerProfileID"`
	AnswerProfileID  int         `json:"answerProfileID"`
	Comments         []Comment   `json:"-"`
	CommentsCounts   int         `json:"commentsCounts"`
	Supporters       []Supporter `json:"-"`
	SupportersCounts int         `json:"supportersCounts"`
	Supported        bool        `json:"supported" gorm:"-"`
}

Answer struct

func (*Answer) AfterCreate

func (a *Answer) AfterCreate(tx *gorm.DB) (err error)

AfterCreate func

func (*Answer) AfterDelete

func (a *Answer) AfterDelete(tx *gorm.DB) (err error)

AfterDelete func

func (*Answer) Create

func (a *Answer) Create() (ra int64, err error)

Create func

func (*Answer) Delete

func (a *Answer) Delete() (ra int64, err error)

Delete func

func (*Answer) Get

func (a *Answer) Get() (answer Answer, err error)

Get func

func (*Answer) GetCounts

func (a *Answer) GetCounts() (counts int, err error)

GetCounts func

func (*Answer) GetList

func (a *Answer) GetList(limit int, offset int) (answers []Answer, err error)

GetList func

func (*Answer) GetOrderList

func (a *Answer) GetOrderList(limit int, offset int, order string) (answers []Answer, err error)

GetOrderList func

func (*Answer) Update

func (a *Answer) Update() (ra int64, err error)

Update func

type Comment

type Comment struct {
	GORMBase
	Content          string  `json:"content"`
	Type             int     `json:"type"`
	Answer           Answer  `json:"-" gorm:"ForeignKey:AnswerID"`
	AnswerID         int     `json:"answerID"`
	CommentProfile   Profile `json:"commentProfile" gorm:"ForeignKey:CommentProfileID"`
	CommentProfileID int     `json:"commentProfileID"`
	Replies          []Reply `json:"-"`
	RepliesCounts    int     `json:"repliesCounts"`
}

Comment struct

func (*Comment) AfterCreate

func (co *Comment) AfterCreate(tx *gorm.DB) (err error)

AfterCreate func

func (*Comment) AfterDelete

func (co *Comment) AfterDelete(tx *gorm.DB) (err error)

AfterDelete func

func (*Comment) Create

func (co *Comment) Create() (ra int64, err error)

Create func

func (*Comment) Delete

func (co *Comment) Delete() (ra int64, err error)

Delete func

func (*Comment) Get

func (co *Comment) Get() (comment Comment, err error)

Get func

func (*Comment) GetCounts

func (co *Comment) GetCounts() (counts int, err error)

GetCounts func

func (*Comment) GetList

func (co *Comment) GetList(limit int, offset int) (comments []Comment, err error)

GetList func

func (*Comment) Update

func (co *Comment) Update() (ra int64, err error)

Update func

type GORMBase

type GORMBase struct {
	ID        int   `json:"id" gorm:"AUTO_INCREMENT"`
	CreatedAt int64 `json:"createAt"`
	UpdatedAt int64 `json:"updateAt"`
}

GORMBase struct

func (*GORMBase) BeforeCreate

func (m *GORMBase) BeforeCreate(scope *gorm.Scope) error

BeforeCreate func

func (*GORMBase) BeforeUpdate

func (m *GORMBase) BeforeUpdate(scope *gorm.Scope) error

BeforeUpdate func

type Profile

type Profile struct {
	GORMBase
	Name string `json:"name"`
	Desc string `json:"desc"`
}

Profile struct

func (*Profile) Create

func (p *Profile) Create() (ra int64, err error)

Create func

func (*Profile) Delete

func (p *Profile) Delete() (ra int64, err error)

Delete func

func (*Profile) Get

func (p *Profile) Get() (profile Profile, err error)

Get func

func (*Profile) GetCounts

func (p *Profile) GetCounts() (counts int, err error)

GetCounts func

func (*Profile) GetList

func (p *Profile) GetList(limit int, offset int) (profiles []Profile, err error)

GetList func

func (*Profile) Update

func (p *Profile) Update() (ra int64, err error)

Update func

type Question

type Question struct {
	GORMBase
	Title             string   `json:"title"`
	Desc              string   `json:"desc" gorm:"type:varchar(4000)"`
	Type              int      `json:"type"`
	QuestionProfile   Profile  `json:"questionProfile" gorm:"ForeignKey:QuestionProfileID"`
	QuestionProfileID int      `json:"questionProfileID" gorm:"index"`
	Answers           []Answer `json:"-"`
	AnswersCounts     int      `json:"answersCounts"`
}

Question struct

func (*Question) AfterDelete

func (q *Question) AfterDelete(tx *gorm.DB) (err error)

AfterDelete func

func (*Question) Create

func (q *Question) Create() (ra int64, err error)

Create func

func (*Question) Delete

func (q *Question) Delete() (ra int64, err error)

Delete func

func (*Question) Get

func (q *Question) Get() (question Question, err error)

Get func

func (*Question) GetCounts

func (q *Question) GetCounts() (counts int, err error)

GetCounts func

func (*Question) GetList

func (q *Question) GetList(limit int, offset int) (questions []Question, err error)

GetList func

func (*Question) GetOrderList

func (q *Question) GetOrderList(limit int, offset int, order string) (questions []Question, err error)

GetOrderList func

func (*Question) Update

func (q *Question) Update() (ra int64, err error)

Update func

type Reply

type Reply struct {
	GORMBase
	Content            string  `json:"content"`
	Type               int     `json:"type"`
	Comment            Comment `json:"-" gorm:"ForeignKey:CommentID"`
	CommentID          int     `json:"commentID"`
	ReplyFromProfile   Profile `json:"replyFromProfile" gorm:"ForeignKey:ReplyFromProfileID"`
	ReplyFromProfileID int     `json:"replyFromProfileID"`
	ReplyToProfile     Profile `json:"replyToProfile" gorm:"ForeignKey:ReplyToProfileID"`
	ReplyToProfileID   int     `json:"replyToProfileID"`
}

Reply struct

func (*Reply) AfterCreate

func (r *Reply) AfterCreate(tx *gorm.DB) (err error)

AfterCreate func

func (*Reply) AfterDelete

func (r *Reply) AfterDelete(tx *gorm.DB) (err error)

AfterDelete func

func (*Reply) Create

func (r *Reply) Create() (ra int64, err error)

Create func

func (*Reply) Delete

func (r *Reply) Delete() (ra int64, err error)

Delete func

func (*Reply) Get

func (r *Reply) Get() (reply Reply, err error)

Get func

func (*Reply) GetCounts

func (r *Reply) GetCounts() (counts int, err error)

GetCounts func

func (*Reply) GetList

func (r *Reply) GetList(limit int, offset int) (replies []Reply, err error)

GetList func

func (*Reply) Update

func (r *Reply) Update() (ra int64, err error)

Update func

type Supporter

type Supporter struct {
	GORMBase
	Answer    Answer  `json:"-" gorm:"ForeignKey:AnswerID"`
	AnswerID  int     `json:"answerID"`
	Profile   Profile `json:"profile" gorm:"ForeignKey:ProfileID"`
	ProfileID int     `json:"profileID"`
}

Supporter struct

func (*Supporter) AfterCreate

func (su *Supporter) AfterCreate(tx *gorm.DB) (err error)

AfterCreate func

func (*Supporter) AfterDelete

func (su *Supporter) AfterDelete(tx *gorm.DB) (err error)

AfterDelete func

func (*Supporter) Create

func (su *Supporter) Create() (ra int64, err error)

Create func

func (*Supporter) Delete

func (su *Supporter) Delete() (ra int64, err error)

Delete func

type User

type User struct {
	GORMBase
	Mail       string  `json:"mail" gorm:"type:varchar(100);unique_index"`
	Password   string  `json:"password"`
	Authorized int     `json:"authorized"`
	Type       int     `json:"type"`
	Profile    Profile `json:"profile" gorm:"ForeignKey:ProfileID"`
	ProfileID  int     `json:"profileID"`
}

User struct

func (*User) AfterCreate

func (u *User) AfterCreate(tx *gorm.DB) (err error)

AfterCreate func

func (*User) BeforeDelete

func (u *User) BeforeDelete(tx *gorm.DB) (err error)

BeforeDelete func

func (*User) Create

func (u *User) Create() (ra int64, err error)

Create func

func (*User) Delete

func (u *User) Delete() (ra int64, err error)

Delete func

func (*User) Get

func (u *User) Get() (user User, err error)

Get func

func (*User) GetCounts

func (u *User) GetCounts() (counts int, err error)

GetCounts func

func (*User) GetList

func (u *User) GetList(limit int, offset int) (users []User, err error)

GetList func

func (*User) Update

func (u *User) Update() (ra int64, err error)

Update func

Jump to

Keyboard shortcuts

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