model

package
v0.0.0-...-19069b9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArticleKindDoc  = 1
	ArticleKindTech = 2
)

Variables

View Source
var (
	DbMap *gorp.DbMap
)

Functions

func DBMTransact

func DBMTransact(dbMap *gorp.DbMap, txFunc func(*gorp.Transaction) error) (err error)

func InitDB

func InitDB()

func InsertBatch

func InsertBatch(db gorp.SqlExecutor, list ...interface{}) error

func UpdateArticle

func UpdateArticle(db gorp.SqlExecutor, urlID, title, brief string, body template.HTML, updatedTime time.Time) error

Types

type Article

type Article struct {
	Id          int           `json:"id" db:"id"`
	UrlID       string        `json:"url_id" db:"url_id"`
	Title       string        `json:"title" db:"title"`
	Icon        string        `json:"icon" db:"icon"`
	Kind        int           `json:"kind" db:"kind"`
	Visited     int           `json:"visited" db:"visited"`
	Brief       string        `json:"brief" db:"brief"`
	Body        template.HTML `json:"body" db:"body"`
	CreateTime  time.Time     `json:"create_time" db:"create_time"`
	UpdatedTime time.Time     `json:"updated_time" db:"updated_time"`
}

func GetArticle

func GetArticle(db gorp.SqlExecutor, urlID string) (*Article, error)

func List

func List(db gorp.SqlExecutor) ([]*Article, error)

func ListArticles

func ListArticles(db gorp.SqlExecutor) ([]*Article, error)

func TopArticles

func TopArticles(db gorp.SqlExecutor, top, kind int) ([]*Article, error)

func (*Article) Insert

func (p *Article) Insert(db gorp.SqlExecutor) error

func (*Article) PreInsert

func (p *Article) PreInsert(gorp.SqlExecutor) error

type Auth

type Auth struct {
	ID          int       `json:"id" db:"id"`
	User        string    `json:"user" db:"user"`
	Password    string    `json:"password" db:"password"`
	CreatedTime time.Time `json:"created_time" db:"created_time"`
}

func GetAuth

func GetAuth(db gorp.SqlExecutor, user, password string) (*Auth, error)

func (*Auth) Insert

func (a *Auth) Insert(db gorp.SqlExecutor) error

type Validator

type Validator interface {
	Validate() bool
}

Jump to

Keyboard shortcuts

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