package dao

import "server/global"

type CommodityGenre struct {
	global.GVA_MODEL
	Name string `json:"name" form:"name" gorm:"comment:商品类目名称"`
}

func (CommodityGenre) TableName() string {
	return "commodity_genre"
}

func QueryAllCommodityGenres() (commodityGenres []CommodityGenre, err error) {
	err = global.GVA_DB.Find(&commodityGenres).Error
	return commodityGenres, err
}

func (cg CommodityGenre) CreateCommodityGenre() error {
	return global.GVA_DB.Create(&cg).Error
}

func (cg CommodityGenre) UpdateCommodityGenre() error {
	return global.GVA_DB.Select("*").Omit("created_at").Where("id = ?", cg.ID).Updates(&cg).Error
}

func (cg CommodityGenre) DeleteCommodityGenre() error {
	return global.GVA_DB.Unscoped().Delete(&cg).Error
}
