1234567891011121314151617181920212223242526272829303132333435 |
- package dao
- import "server/global"
- type DeviceGenre struct {
- global.GVA_MODEL
- Name string `json:"name" form:"name" gorm:"comment:类型名称"`
- Type string `json:"type" form:"type" gorm:"comment:硬件类型"`
- }
- func (DeviceGenre) TableName() string {
- return "device_genre"
- }
- func QueryAllDeviceGenres() (genres []DeviceGenre, err error) {
- err = global.GVA_DB.Model(DeviceGenre{}).Find(&genres).Error
- return
- }
- func QueryDeviceGenreByID(id int) (genre DeviceGenre, err error) {
- err = global.GVA_DB.Where("id = ?", id).First(&genre).Error
- return
- }
- func (d DeviceGenre) CreateDeviceGenre() error {
- return global.GVA_DB.Create(&d).Error
- }
- func (d DeviceGenre) UpdateDeviceGenre() error {
- return global.GVA_DB.Where("id = ?", d.ID).Updates(&d).Error
- }
- func DeleteDeviceGenre(id int) error {
- return global.GVA_DB.Unscoped().Where("id = ?", id).Delete(&DeviceGenre{}).Error
- }
|