package dao

import "server/global"

type ExpensesGenre struct {
	global.GVA_MODEL
	Name string `json:"name" form:"name" gorm:"comment:费用类型名称"`
}

func (ExpensesGenre) TableName() string {
	return "expenses_genre"
}

// TODO:费用类型查询

// QueryExpensesGenre 查询费用类型
func QueryExpensesGenre() (expensesGenre []ExpensesGenre, err error) {
	err = global.GVA_DB.Model(&ExpensesGenre{}).Find(&expensesGenre).Error
	return expensesGenre, err
}

// TODO:费用类型新增

// CreateExpensesGenre 新增费用类型
func (eg ExpensesGenre) CreateExpensesGenre() error {
	return global.GVA_DB.Create(&eg).Error
}

// TODO:费用类型修改

// UpdateExpensesGenre 修改费用类型
func (eg ExpensesGenre) UpdateExpensesGenre() error {
	return global.GVA_DB.Model(&eg).Where("id = ?", eg.ID).Updates(&eg).Error
}

// TODO:费用类型删除

// DeleteExpensesGenre 删除费用类型
func (eg ExpensesGenre) DeleteExpensesGenre() error {
	return global.GVA_DB.Unscoped().Delete(&eg).Error
}
