models

package
v0.0.0-...-943e509 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Trains []string

	NewCategoryId int64
)
View Source
var (
	ErrNotFound = fmt.Errorf("not found")
)
View Source
var SmolGUFaculties = Faculties{
	{1, "Физико-математический факультет", "ФМФ"},
	{2, "Филологический факультет", "ФМФ"},
	{3, "Факультет истории и права", "ФИиП"},
	{4, "Естественно-географический факультет", "ЕГФ"},
	{5, "Социальный факультет", "СФ"},
	{6, "Психолого-педагогический факультет", "ППФ"},
	{7, "Художественно-графический факультет", "ППФ"},
	{8, "Факультет экономики и управления", "ФЭУ"},
	{9, "Другое", "Др"},
}
View Source
var Statuses = map[Status]string{
	Student:                  "Студент",
	Guru:                     "Преподаватель",
	Stuff:                    "Сотрудник",
	Librarian:                "Библиотекарь",
	ElectronicResources:      "Сотрудник ОЭР",
	ChiefElectronicResources: "Начальник ОЭР",
	ViceDirector:             "Заместитель директора",
	Director:                 "Директор",
}
View Source
var (
	UserService *users.Service
)

Functions

func Delete

func Delete(bean interface{}) (e error)
func DeleteLink(id int64) (e error)

func DeletePage

func DeletePage(id int64) error

func Get

func Get(key string) ([]byte, error)

func GetBookPage

func GetBookPage()

func GetMime

func GetMime(fName string) string

func GetTagItems

func GetTagItems(tagName string, bean interface{}) ([]int64, error)

func IncVersion

func IncVersion() error

func KatalogSave

func KatalogSave(k *Katalog) error

func LinkSave

func LinkSave(l *Link) (e error)
func MenuSetPosition(positions []int64) error

func Migrate

func Migrate() error

func NewEngine

func NewEngine()

func NewKVContext

func NewKVContext()

func NewTagsContext

func NewTagsContext()

func NewUserService

func NewUserService() error

func RemoveAllTags

func RemoveAllTags(bean interface{}) error

func RemoveTag

func RemoveTag(tagName string, bean interface{}) error

func RestorePage

func RestorePage(id int64) error

func RouterSave

func RouterSave(objectID int64, objectType ObjectType, slug string) error

func Save

func Save(bean interface{}) (e error)

func SavePage

func SavePage(p *Page) (e error)

func SaveTags

func SaveTags(bean interface{}) error

func SaveUser

func SaveUser(u *User) error

func Set

func Set(key string, value []byte) error

func TrainingDirectionYears

func TrainingDirectionYears(tdId int64) ([]int, error)

func ViewPage

func ViewPage(id int64, sessionId string) (e error)

func VkrDownload

func VkrDownload(id int64) (string, error)

func WriteBookPage

func WriteBookPage(w io.Writer, id int64, num int) (e error)

Types

type Album

type Album struct {
	Id    int64
	Title string
	Text  string

	Cat int64

	Photos []*Photo `xorm:"-"`

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
}

func AlbumCreate

func AlbumCreate(title string, text string, cat int64) (*Album, error)

func AlbumGet

func AlbumGet(id int64) (*Album, error)

func AlbumList

func AlbumList(cat int, limit int, offsets ...int) (res []*Album, err error)
type Banner struct {
	Id      int64
	ImgPath string
	Url     string
	Title   string

	Color string

	Enabled bool

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
	Deleted time.Time `xorm:"deleted"`
}

func BannerGet

func BannerGet(id int64) (*Banner, error)

func GetEnabledBanners

func GetEnabledBanners() ([]*Banner, error)

type Book

type Book struct {
	Id int64

	Title   string
	PdfPath string
	Pages   int
}

func BookGet

func BookGet(id int64) (*Book, error)

func CreateBook

func CreateBook(title, pp string) (_ *Book, e error)

func CreateBookFromReader

func CreateBookFromReader(title string, file io.Reader) (b *Book, e error)

type Bucket

type Bucket struct {
	Id    int64
	Title string

	Files []*File `xorm:"-"`

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
}

func BucketCreate

func BucketCreate(title string) (*Bucket, error)

func BucketGet

func BucketGet(id int64) (*Bucket, error)

func BucketList

func BucketList(limit int, offsets ...int) (res []*Bucket, err error)

type Category

type Category struct {
	Id   int64
	Name string
}

type Departament

type Departament struct {
	Id       int64
	ParentId int64

	Title string

	Phone    string
	Location string
}

type Engine

type Engine interface {
	Delete(interface{}) (int64, error)
	Exec(string, ...interface{}) (sql.Result, error)
	Find(interface{}, ...interface{}) error
	Get(interface{}) (bool, error)
	Insert(...interface{}) (int64, error)
	InsertOne(interface{}) (int64, error)
	Id(interface{}) *xorm.Session
	Sql(string, ...interface{}) *xorm.Session
	Where(string, ...interface{}) *xorm.Session
}

Engine represents a xorm engine or session.

type Faculties

type Faculties []Faculty

func (Faculties) Slice

func (f Faculties) Slice() (result []string)

type Faculty

type Faculty struct {
	Id    int64
	Title string
	Short string
}

type File

type File struct {
	Id       int64
	Type     int
	Title    string
	BlobID   int64 `xorm:"blob_id"`
	BucketID int64 `xorm:"bucket_id"`

	OriginalFileName string
	Mime             string

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
	Deleted time.Time `xorm:"deleted"`
}

func GetFile

func GetFile(id int64) (*File, error)

func Upload

func Upload(fileName string, data []byte, opts ...FileCreateOptions) (*File, error)

type FileCreateOptions

type FileCreateOptions struct {
	BucketID int64
	Title    string
}

type Katalog

type Katalog struct {
	Id       int64
	SourceId string `xorm:"index unique"`

	Title  string
	Author string

	BookId int64

	Updated time.Time
	Created time.Time
	Deleted time.Time
}

func KatalogGet

func KatalogGet(id int64) (k *Katalog, e error)

func KatalogGetByOldId

func KatalogGetByOldId(id string) (k *Katalog, e error)

func NewKatalogFromRuslanBook

func NewKatalogFromRuslanBook(b ruslanparser.Book) (*Katalog, error)
type Link struct {
	Id     int64
	Title  string
	URL    string `form:"url"`
	Target LinkTarget
	Tags   []string
	Img    string
}

func LinkGet

func LinkGet(id int64) (*Link, error)
func NewLink(href, title string) *Link

type LinkTarget

type LinkTarget string
const (
	LBlank LinkTarget = "_blank"
	LNone  LinkTarget = "_none"
	LTop   LinkTarget = "_top"
)
type Links []Link

func LinkFind

func LinkFind(limit, offset int) (Links, error)

func LinkFindByTag

func LinkFindByTag(tagName string, offset, limit int) (Links, error)

func (Links) ByTags

func (l Links) ByTags(otags ...string) (ls Links)
type Menu struct {
	Id    int64
	Title string
	Slug  string

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`

	Items MenuItems `xorm:"-"`
}
func MenuCreate(title string, slug string) (*Menu, error)
func MenuGet(id int64) (*Menu, error)
func MenuGetAll() ([]*Menu, error)
func MenuList() ([]*Menu, error)
type MenuItem struct {
	Id    int64
	Title string
	Link  string

	MenuId   int64
	ParentId int64

	Position int

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
}
func MenuItemCreate(title, link string, menuId int64, parent int64) (*MenuItem, error)
func MenuItemGet(id int64) (*MenuItem, error)
type MenuItems []MenuItem
func MenuItemsGet(menuId int64) (MenuItems, error)
func (m MenuItems) Childs(id int64) (res MenuItems)
func (m MenuItems) FirstLevel() (res MenuItems)
func (a MenuItems) Len() int
func (a MenuItems) Less(i, j int) bool
func (m MenuItems) Menu(id int64) (items MenuItems)
func (a MenuItems) Swap(i, j int)
type Menus struct {
	Menus []*Menu
	Items MenuItems
}
func MenusGet() (*Menus, error)
func (m *Menus) Menu(slug string) *Menu

type ObjectType

type ObjectType int
const (
	ObjectPage ObjectType = iota + 1
)

func RouterResolve

func RouterResolve(slug string) (objectID int64, typ ObjectType, err error)

type Page

type Page struct {
	Id       int64
	OldId    string `xorm:"unique"`
	Title    string
	Body     string `xorm:"TEXT"`
	Category int64

	BucketID int64 `xorm:"bucket_id"`

	Slug string

	Image  string
	Images []string

	Published bool

	Date      time.Time
	CreatedBy int64

	Views int64

	Tags []string

	Deleted time.Time `xorm:"deleted"`
	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
}

func GetAllPages

func GetAllPages() ([]*Page, error)

func GetNews

func GetNews(pages ...int) ([]Page, error)

func GetPage

func GetPage(id int64) (p *Page, e error)

func GetPageByOldId

func GetPageByOldId(id string) (p *Page, e error)

func GetPageBySlug

func GetPageBySlug(slug string) (*Page, error)

func GetPagesByIds

func GetPagesByIds(ids []int64, pages ...int) ([]*Page, error)

func GetPagesByTag

func GetPagesByTag(tagName string, pages ...int) ([]*Page, error)

func (Page) SanitazedBody

func (p Page) SanitazedBody() string

SanitazedBody return body text without html tags. Useful for external posting.

func (Page) Summary

func (p Page) Summary() (summary string)

Summary return cutted Body by 255 symbols

type Photo

type Photo struct {
	Id      int64
	AlbumId int64

	BlobId int64

	Caption string

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
}

func PhotoCreate

func PhotoCreate(albumId int64, blobId int64) (*Photo, error)

type Router

type Router struct {
	Slug     string `xorm:"unique index"`
	Type     ObjectType
	ObjectID int64
}

type Staff

type Staff struct {
	Id     int64
	UserId int64

	Order int

	JobFrom     string
	Education   string
	Position    string
	Departament int64

	Deleted time.Time
}

type Status

type Status users.Status
const (
	Student Status = 2 << (iota + 10)
	Guru
	Stuff
	Librarian
	ElectronicResources
	ChiefElectronicResources
	ViceDirector
	Director
)

func (Status) Add

func (s Status) Add(toAdd Status) Status

func (Status) Remove

func (s Status) Remove(toRemove Status) Status

func (Status) String

func (st Status) String() (s string)

type TrainingDirection

type TrainingDirection struct {
	Id int64

	Title    string
	SubTitle string

	FacultyId int64

	Code string

	CreatedBy int64

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
	Deleted time.Time `xorm:"deleted"`
}

func TrainingDirectionAllList

func TrainingDirectionAllList() ([]*TrainingDirection, error)

func TrainingDirectionById

func TrainingDirectionById(id int64) (*TrainingDirection, error)

func TrainingDirectionFacultyList

func TrainingDirectionFacultyList(facId int64) ([]*TrainingDirection, error)

type User

type User struct {
	*users.User
	Status Status
}

func CreateUser

func CreateUser(username, password string) (*User, error)

func GetByUserName

func GetByUserName(username string) (*User, error)

func GetUser

func GetUser(id int64) (*User, error)

func GetUserList

func GetUserList(offset int, limit int) (u []*User, e error)

func (User) IsAdmin

func (u User) IsAdmin() bool

type Version

type Version struct {
	Id      int64
	Version int
}

func GetVersion

func GetVersion() (*Version, error)

type Vkr

type Vkr struct {
	Id int64

	Title string

	FirstName  string
	LastName   string
	Patronymic string

	TrainingDirectionId int64

	Level     string
	FormStudy string

	BookId int64

	UploaderId int64

	Year int

	Created time.Time `xorm:"created"`
	Updated time.Time `xorm:"updated"`
	Deleted time.Time `xorm:"deleted"`
}

func DirectionYearList

func DirectionYearList(tdId int64, year int) ([]*Vkr, error)

func VkrGet

func VkrGet(id int64) (*Vkr, error)

Jump to

Keyboard shortcuts

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