models

package
v0.0.0-...-a4557ec Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NextPage

func NextPage(page, perPage, total int64) (int64, int64)

func Pagination

func Pagination(page, perPage int) (int, int)

func Random

func Random(db *xorm.Engine, data interface{}, n int, table string) (err error)

func Range

func Range(db *xorm.Session, data interface{}, page, perPage int, where string, a ...interface{}) (int64, error)

func SyncFileCreate

func SyncFileCreate(sf *SyncFile)

func SyncFileDelete

func SyncFileDelete(where string, a ...interface{})

func SyncFileEach

func SyncFileEach(fn func(sf SyncFile))

func SyncFileUpdate

func SyncFileUpdate(sf *SyncFile, where string, a ...interface{})

func SyncFileUpdateMap

func SyncFileUpdateMap(sf map[string]interface{}, where string, a ...interface{})

func TaskInsert

func TaskInsert(db *xorm.Engine, task *Task) error

func TaskPut

func TaskPut(db *xorm.Engine, id string, task map[string]interface{}) error

Types

type JsonTime

type JsonTime time.Time

func (JsonTime) MarshalJSON

func (j JsonTime) MarshalJSON() ([]byte, error)

type SyncFile

type SyncFile struct {
	Id        int64       `json:"id"`
	CreatedAt JsonTime    `json:"created" xorm:"created"`
	UpdatedAt JsonTime    `json:"updated" xorm:"updated"`
	Crc64ecma string      `json:"crc64_ecma" xorm:"varchar(100) notnull index 'crc64_ecma'"`
	Md5       string      `json:"md5"`
	Name      string      `json:"name"`
	Path      string      `json:"path" xorm:"varchar(100) notnull index 'path'"`
	PathHash  string      `json:"path_hash" xorm:"varchar(100) notnull unique 'path_hash'"`
	Changed   bool        `json:"changed"`
	Synced    bool        `json:"synced"`
	Size      int64       `json:"size"`
	Mode      os.FileMode `json:"mode"`
	ModTime   int64       `json:"mod_time"`
	IsDir     bool        `json:"-"`
}

func SyncFileFindOne

func SyncFileFindOne(where string, a ...interface{}) *SyncFile

func SyncFileRange

func SyncFileRange(page, perPage int, where string, a ...interface{}) ([]SyncFile, int64, error)

type Task

type Task struct {
	Id        int64             `json:"id"`
	CreatedAt JsonTime          `json:"created_at" xorm:"created"`
	UpdatedAt JsonTime          `json:"updated_at" xorm:"updated"`
	TaskID    string            `json:"task_id" xorm:"varchar(100) notnull unique 'task_id'"`
	Service   string            `json:"service"`
	Attempts  uint16            `json:"attempts"`
	Priority  uint8             `json:"priority"`
	Timestamp int64             `json:"timestamp"`
	Status    TaskStatus        `json:"status" xorm:"int notnull index 'status'"`
	Method    string            `json:"method"`
	Body      []byte            `json:"body"`
	Header    map[string]string `json:"header"`
}

func TaskGet

func TaskGet(db *xorm.Engine, id int) (Task, error)

func TaskRandom

func TaskRandom(db *xorm.Engine, n int) (tasks []Task, err error)

func TaskRange

func TaskRange(db *xorm.Engine, status, page, perPage int) ([]Task, int64, error)

type TaskStatus

type TaskStatus uint8
const (
	TaskStatusCreated TaskStatus = iota
	TaskStatusPending
	TaskStatusSuccess
	TaskStatusFailed
)

func (TaskStatus) String

func (t TaskStatus) String() string

Jump to

Keyboard shortcuts

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