categoryModel

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	ID             uint                   `gorm:"comment:'主键';primary_key;" `
	AccountId      uint                   `gorm:"comment:'账本ID';uniqueIndex:unique_name,priority:1"`
	FatherId       uint                   `gorm:"comment:'category_father表ID';index" `
	IncomeExpense  constant.IncomeExpense `gorm:"comment:'收支类型'"`
	Name           string                 `gorm:"comment:'名称';size:128;uniqueIndex:unique_name,priority:2"`
	Icon           string                 `gorm:"comment:'图标';size:64"`
	Previous       uint                   `gorm:"comment:'前一位'"`
	OrderUpdatedAt time.Time              `gorm:"comment:'顺序更新时间';not null;default:now();type:TIMESTAMP;"`
	CreatedAt      time.Time              `gorm:"type:TIMESTAMP"`
	UpdatedAt      time.Time              `gorm:"type:TIMESTAMP"`
	DeletedAt      gorm.DeletedAt         `gorm:"index;type:TIMESTAMP"`
	commonModel.BaseModel
}

func (*Category) CheckName

func (c *Category) CheckName(_ *gorm.DB) error

func (*Category) GetAccount

func (c *Category) GetAccount() (result accountModel.Account, err error)

func (*Category) GetFather

func (c *Category) GetFather() (father Father, err error)

func (*Category) SelectById

func (c *Category) SelectById(id uint) error

type CategoryDao

type CategoryDao struct {
	// contains filtered or unexported fields
}

func NewDao

func NewDao(db ...*gorm.DB) *CategoryDao

func (*CategoryDao) CreateMapping

func (cd *CategoryDao) CreateMapping(parent, child Category) (Mapping, error)

func (*CategoryDao) Exist

func (cd *CategoryDao) Exist(account accountModel.Account) (bool, error)

func (*CategoryDao) GetAll

func (cd *CategoryDao) GetAll(account accountModel.Account, incomeExpense *constant.IncomeExpense) ([]Category, error)

func (*CategoryDao) GetFatherList

func (cd *CategoryDao) GetFatherList(account accountModel.Account, incomeExpense *constant.IncomeExpense) (
	[]Father,
	error)

func (*CategoryDao) GetListByAccount

func (cd *CategoryDao) GetListByAccount(account accountModel.Account, ie *constant.IncomeExpense) (
	list []Category,
	err error)

func (*CategoryDao) GetListByFather

func (cd *CategoryDao) GetListByFather(father Father) ([]Category, error)

func (*CategoryDao) GetMappingByAccountMappingOrderByParentCategory

func (cd *CategoryDao) GetMappingByAccountMappingOrderByParentCategory(parentAccountId, childAccountId uint) (
	[]Mapping, error,
)

func (*CategoryDao) GetUnmappedList

func (cd *CategoryDao) GetUnmappedList(
	mainAccount, mappingAccount accountModel.Account,
	ie *constant.IncomeExpense) (list []Category, err error)

func (*CategoryDao) Order

func (cd *CategoryDao) Order(list []Category)

func (*CategoryDao) OrderFather

func (cd *CategoryDao) OrderFather(list []Father)

func (*CategoryDao) SelectById

func (cd *CategoryDao) SelectById(id uint) (category Category, err error)

func (*CategoryDao) SelectByName

func (cd *CategoryDao) SelectByName(accountId uint, name string) (category Category, err error)

func (*CategoryDao) SelectFatherById

func (cd *CategoryDao) SelectFatherById(id uint) (father Father, err error)

func (*CategoryDao) SelectFatherFirstChild

func (cd *CategoryDao) SelectFatherFirstChild(fatherId uint) (Father, error)

func (*CategoryDao) SelectFirstChild

func (cd *CategoryDao) SelectFirstChild(categoryId uint) (Category, error)

func (*CategoryDao) SelectMapping

func (cd *CategoryDao) SelectMapping(parentAccountId, childCategoryId uint) (Mapping, error)

func (*CategoryDao) SelectMappingByCAccountIdAndPCategoryId

func (cd *CategoryDao) SelectMappingByCAccountIdAndPCategoryId(childAccountId, parentCategoryId uint) (Mapping, error)

SelectMappingByCAccountIdAndPCategoryId 通过子账本这父交易类型查询关联交易类型

func (*CategoryDao) Update

func (cd *CategoryDao) Update(categoryId uint, data CategoryUpdateData) error

func (*CategoryDao) UpdateChildPrevious

func (cd *CategoryDao) UpdateChildPrevious(categoryId, newPrevious uint) error

func (*CategoryDao) UpdateFatherChildPrevious

func (cd *CategoryDao) UpdateFatherChildPrevious(categoryId, newPrevious uint) error

type CategoryUpdateData

type CategoryUpdateData struct {
	Name *string
	Icon *string
}

type Condition

type Condition struct {
	// contains filtered or unexported fields
}

type Father

type Father struct {
	ID             uint                   `gorm:"primary_key"`
	AccountId      uint                   `gorm:"index;comment:'账本ID'"`
	IncomeExpense  constant.IncomeExpense `gorm:"comment:'收支类型'"`
	Name           string                 `gorm:"size:128;comment:'名称'"`
	Previous       uint                   `gorm:"comment:'前一位'"`
	OrderUpdatedAt time.Time              `gorm:"type:TIMESTAMP"`
	CreatedAt      time.Time              `gorm:"type:TIMESTAMP"`
	commonModel.BaseModel
}

func (*Father) SelectById

func (f *Father) SelectById(id uint) error

func (*Father) TableName

func (f *Father) TableName() string

type Mapping

type Mapping struct {
	ID               uint           `gorm:"primarykey"`
	ParentAccountId  uint           `gorm:"comment:'父账本ID';uniqueIndex:idx_mapping,priority:2"`
	ChildAccountId   uint           `gorm:"comment:'子账本ID';" `
	ParentCategoryId uint           `gorm:"comment:'父收支类型ID';index"`
	ChildCategoryId  uint           `gorm:"comment:'子收支类型ID';uniqueIndex:idx_mapping,priority:1"`
	CreatedAt        time.Time      `gorm:"type:TIMESTAMP"`
	UpdatedAt        time.Time      `gorm:"type:TIMESTAMP"`
	DeletedAt        gorm.DeletedAt `gorm:"index;type:TIMESTAMP"`
	commonModel.BaseModel
}

Mapping ParentAccountId - ChildCategoryId unique ParentCategoryId - ChildCategoryId unique ChildAccountId - ParentCategoryId unique

func (*Mapping) TableName

func (p *Mapping) TableName() string

Jump to

Keyboard shortcuts

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