models

package
v0.0.0-...-9b663ca Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationBorrow = iota
	OperationReturn
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	base.DefaultModel
	Isbn            string         `gorm:"size:32;NOT NULL;comment:isbn"`
	Name            string         `gorm:"size:100;NOT NULL;comment:书名"`
	Desc            string         `gorm:"size:1000;NOT NULL;comment:简介"`
	Cover           string         `gorm:"size:200;NOT NULL;comment:封面"`
	Author          pq.StringArray `gorm:"type:varchar(100)[];comment:作者"`
	Translator      pq.StringArray `gorm:"type:varchar(100)[];comment:译者"`
	PublishingHouse string         `gorm:"size:100;NOT NULL;comment:出版社"`
	Edition         string         `gorm:"size:32;NOT NULL;comment:版次"`
	PrintedTimes    string         `gorm:"size:32;NOT NULL;comment:印次"`
	PrintedSheets   string         `gorm:"size:32;NOT NULL;comment:印张"`
	Format          string         `gorm:"size:32;NOT NULL;comment:开本"`
	WordCount       float32        `gorm:"NOT NULL;comment:字数"`
	Pricing         float32        `gorm:"NOT NULL;comment:定价"`
	PurchasePrice   float32        `gorm:"NOT NULL;comment:购买价"`
	Packing         string         `gorm:"size:32;NOT NULL;comment:包装"`
	PageSize        int            `gorm:"comment:页数;NOT NULL;"`
	PurchaseTime    time.Time      `gorm:"comment:购买时间"`
	PurchaseSource  string         `gorm:"size:100;NOT NULL;comment:购买途径"`
	BookBorrowUID   uint           `gorm:"comment:借书人uid"`
}

Book 书

func NewBook

func NewBook() *Book

func NewBookFromPB

func NewBookFromPB(in *pb.CreateBookRequest) *Book

func (*Book) TableName

func (m *Book) TableName() string

TableName ..

func (*Book) ToBookIndexPBs

func (m *Book) ToBookIndexPBs(data []*Book) []*pb.BookIndex

ToBookIndexPBs ..

func (*Book) ToBookPBs

func (m *Book) ToBookPBs(data []*Book) []*pb.Book

ToBookPBs ..

type BookBorrowReturn

type BookBorrowReturn struct {
	base.Model
	ID        uint `gorm:"primarykey"`
	BookID    uint `gorm:"comment:书id"`
	Book      Book `gorm:"ForeignKey:BookID"`
	UID       uint `gorm:"comment:用户id"`
	Operation int8 `gorm:"comment:操作类型"` //0:借,1:还
	CreatedAt time.Time
}

BookBorrowReturn 书籍位置

func NewBookBorrowReturn

func NewBookBorrowReturn() *BookBorrowReturn

func (*BookBorrowReturn) TableName

func (m *BookBorrowReturn) TableName() string

TableName ..

func (*BookBorrowReturn) ToBookBorrowReturnPBs

func (m *BookBorrowReturn) ToBookBorrowReturnPBs(data []*BookBorrowReturn) []*pb.BookBorrowReturn

ToBookBorrowReturnPBs ..

type BookPosition

type BookPosition struct {
	base.DefaultModel
	BookID      uint      `gorm:"uniqueIndex:book_position_uix;comment:书id"`
	BookshelfID uint      `gorm:"comment:书架id"`
	Book        Book      `gorm:"ForeignKey:BookID"`
	Bookshelf   Bookshelf `gorm:"ForeignKey:BookshelfID"`
	Layer       int8      `gorm:"comment:层"`
	Partition   int8      `gorm:"comment:分区"`
	PrevID      uint      `gorm:"comment:左侧位置id"`
}

BookPosition 书籍位置

func NewBookPosition

func NewBookPosition() *BookPosition

func (*BookPosition) DeleteByID

func (m *BookPosition) DeleteByID(id int64) error

DeleteByID 获取某个书架某行某分区的最后一本书id

func (*BookPosition) GetLastBookPositionID

func (m *BookPosition) GetLastBookPositionID(bookshelfID, layer, partiton int) error

GetLastBookPosition 获取某个书架某行某分区的最后一本书id

func (*BookPosition) TableName

func (m *BookPosition) TableName() string

TableName ..

func (*BookPosition) ToBookPositionPBs

func (m *BookPosition) ToBookPositionPBs(data []*BookPosition) []*pb.BookPosition

ToBookPositionPBs ..

type Bookshelf

type Bookshelf struct {
	base.DefaultModel
	Name         string `gorm:"size:100;NOT NULL;comment:书架名"`
	Cover        string `gorm:"size:200;NOT NULL;comment:图片"`
	LayerNum     int8   `gorm:"comment:层数"`
	PartitionNum int8   `gorm:"comment:分区数"`
}

Bookshelf 书架

func NewBookshelf

func NewBookshelf() *Bookshelf

NewBookshelf ..

func NewBookshelfFromPB

func NewBookshelfFromPB(in *pb.CreateBookshelfRequest) *Bookshelf

func (*Bookshelf) TableName

func (m *Bookshelf) TableName() string

TableName ..

func (*Bookshelf) ToBookshelfPBs

func (m *Bookshelf) ToBookshelfPBs(data []*Bookshelf) []*pb.Bookshelf

ToBookshelfPBs ..

Jump to

Keyboard shortcuts

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