models

package
v1.0.4-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EVENT_JOIN = iota
	EVENT_LEAVE
	EVENT_MESSAGE
)

Variables

This section is empty.

Functions

func NewArchive

func NewArchive(event Event)

NewArchive saves new event to archive list.

Types

type Article

type Article struct {
	Id             int       `orm:"column(id);auto"`
	User           *User     `orm:"rel(fk)"`
	Title          string    `orm:"column(title);size(255);"`
	Content        string    `orm:"column(content);size(128)"`
	CreateTime     time.Time `orm:"column(create_time);type(timestamp);auto_now_add"`
	Type           int
	Stars          int // we may need redis help with this
	AllowComments  bool
	Category       *Category         `orm:"rel(fk);null;default(null)"`
	ArticleComment []*ArticleComment `orm:"reverse(many)"`
	Likes          []*ArticleLike    `orm:"reverse(many)"`
}

Article model articles in db

type ArticleComment

type ArticleComment struct {
	Id      int            `orm:"column(id);auto"`
	User    *User          `orm:"rel(fk)"`
	Article *Article       `orm:"rel(fk)"`
	Likes   []*CommentLike `orm:"reverse(many)"`
}

ArticleComment model articles_comments in db

type ArticleForm

type ArticleForm struct {
	Id            int               `form:"-"`
	Title         string            `form:"title" valid:"Required;MinSize(4);MaxSize(300)"`
	Category      int               `form:"category"`
	Content       string            `form:"content" valid:"Required;MinSize(50);MaxSize(2000)"`
	TopicTags     string            `form:"topic-tags" valid:"MinSize(4);MaxSize(300)"`
	TaggedUsers   string            `form:"tagged-users" valid:"MinSize(4);MaxSize(300)"`
	AllowReviews  bool              `form:"allow-reviews" valid:"Required"`
	AllowComments bool              `form:"allow-comments" valid:"Required"`
	InvalidFields map[string]string `form:"-"`
}

ArticleForm ...

func (*ArticleForm) Validate

func (form *ArticleForm) Validate() bool

Validate ArticleForm data

type ArticleLike

type ArticleLike struct {
	Id         int       `orm:"column(id);auto"`
	User       *User     `orm:"rel(fk)"`
	CreateTime time.Time `orm:"column(create_time);type(timestamp);auto_now_add"`
	Article    *Article  `orm:"rel(fk)"`
}

ArticleLike model

type Block

type Block struct {
	Id         int       `orm:"column(id);auto"`
	Name       string    `orm:"column(title);size(255);"`
	Content    string    `orm:"column(content);size(128)"`
	CreateTime time.Time `orm:"column(create_time);type(timestamp);auto_now_add"`
	Type       string    `orm:"column(type);size(128)"`
	IsActive   bool
	Position   int
}

Block model blocks in db

type BlockConfig

type BlockConfig struct {
	Id         int            `orm:"column(id);auto"`
	Block      *Block         `orm:"rel(fk)"`
	Key        string         `orm:"column(title);size(255);"`
	Value      string         `orm:"column(title);size(255);"`
	Type       string         `orm:"column(title);size(255);"`
	CreateTime time.Time      `orm:"column(create_time);type(timestamp);auto_now_add"`
	Config     []*BlockConfig `orm:"reverse(many)"`
}

BlockConfig model

type Category

type Category struct {
	Id       int        `orm:"column(id);auto"`
	Name     string     `orm:"column(name);size(128)"`
	Articles []*Article `orm:"reverse(many)"`
}

Category model categories in db

type CommentLike

type CommentLike struct {
	Id         int             `orm:"column(id);auto"`
	User       *User           `orm:"rel(fk)"`
	CreateTime time.Time       `orm:"column(create_time);type(timestamp);auto_now_add"`
	Comment    *ArticleComment `orm:"rel(fk)"`
}

CommentLike model

type Event

type Event struct {
	Type      EventType // JOIN, LEAVE, MESSAGE
	User      string
	Timestamp int // Unix timestamp (secs)
	Content   string
}

func GetEvents

func GetEvents(lastReceived int) []Event

GetEvents returns all events after lastReceived.

type EventType

type EventType int

type Image

type Image struct {
	Id       int    `orm:"column(id);auto"`
	User     *User  `orm:"rel(fk)"`
	Title    string `orm:"column(title);size(255);"`
	Url      string `orm:"column(url);size(255);"`
	Type     int
	Category *Category `orm:"rel(fk);null;default(null)"`
}

Image model articles in db

type ImageForm

type ImageForm struct {
	Name          string            `form:"name" valid:"Required;"`
	User          int               `form:"user" valid:"Required;Numeric"`
	Targets       string            `form:"target" valid:"Required;"`
	PivoteX       int               `form:"pivotex" valid:"Required;Numeric"`
	PivoteY       int               `form:"pivotey" valid:"Required;Numeric"`
	ImageType     string            `form:"name" valid:"Required;"`
	Description   string            `form:"description" valid:"Required;AlphaNumeric;MinSize(4);MaxSize(300)"`
	File          []byte            `form:"-"`
	InvalidFields map[string]string `form:"-"`
}

ImageForm ...

func (*ImageForm) Validate

func (form *ImageForm) Validate() bool

Validate ImageForm data

type Profile

type Profile struct {
	Id          int
	User        *User `orm:"reverse(one)"`
	Name        string
	Avatar      string
	Age         int16
	Lema        string
	Description string
	Gender      bool
}

Profile model

func (*Profile) GetPermissions

func (*Profile) GetPermissions(user User) string

GetPermissions get user permissions data

type RegisterForm

type RegisterForm struct {
	Name          string            `form:"name" valid:"Required;"`
	Email         string            `form:"email" valid:"Required;"`
	Username      string            `form:"username" valid:"Required;AlphaNumeric;MinSize(4);MaxSize(300)"`
	Password      string            `form:"password" valid:"Required;MinSize(4);MaxSize(30)"`
	PasswordRe    string            `form:"passwordre" valid:"Required;MinSize(4);MaxSize(30)"`
	Gender        bool              `form:"gender" valid:"Required"`
	InvalidFields map[string]string `form:"-"`
}

RegisterForm ...

func (*RegisterForm) Validate

func (form *RegisterForm) Validate() bool

Validate RegisterForm data

type Style

type Style struct {
	Id         int       `orm:"column(id);auto"`
	Name       string    `orm:"column(name);size(50);unique"`
	Template   *Template `orm:"rel(fk)"`
	Active     bool      `orm:"column(active)"`
	CreateTime time.Time `orm:"column(create_time);type(timestamp);auto_now_add"`
}

Style model

type Template

type Template struct {
	Id         int       `orm:"column(id);auto"`
	Name       string    `orm:"column(name);size(50);unique"`
	Style      []*Style  `orm:"reverse(many)"`
	Active     bool      `orm:"column(active)"`
	CreateTime time.Time `orm:"column(create_time);type(timestamp);auto_now_add"`
}

Template model

type UploadResultJSON

type UploadResultJSON struct {
	Id  int    `json:"id"`
	Msg string `json:"message"`
	Url string `orm:"column(url);size(255);"`
}

UploadResultJSON model articles in db

type User

type User struct {
	Id          int        `orm:"column(id);auto"`
	Username    string     `orm:"column(username);size(50);unique"`
	Email       string     `orm:"column(email);size(255);"`
	Password    string     `orm:"column(password);size(128)"`
	CreateTime  time.Time  `orm:"column(create_time);type(timestamp);auto_now_add"`
	Admin       bool       `orm:"column(admin)"`
	Rands       string     `orm:"size(10)"`
	Profile     *Profile   `orm:"rel(one)"`
	Article     []*Article `orm:"reverse(many)"`
	Permissions string
}

User model

Jump to

Keyboard shortcuts

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