device_genre.go 749 B

123456789101112131415161718192021222324252627282930
  1. package dao
  2. import "server/global"
  3. type DeviceGenre struct {
  4. global.GVA_MODEL
  5. Name string `json:"name" form:"name" gorm:"comment:类型名称"`
  6. Type string `json:"type" form:"type" gorm:"comment:硬件类型"`
  7. }
  8. func (DeviceGenre) TableName() string {
  9. return "device_genre"
  10. }
  11. func QueryAllDeviceGenres() (genres []DeviceGenre, err error) {
  12. err = global.GVA_DB.Model(DeviceGenre{}).Find(&genres).Error
  13. return
  14. }
  15. func (d DeviceGenre) CreateDeviceGenre() error {
  16. return global.GVA_DB.Create(&d).Error
  17. }
  18. func (d DeviceGenre) UpdateDeviceGenre() error {
  19. return global.GVA_DB.Where("id = ?", d.ID).Updates(&d).Error
  20. }
  21. func DeleteDeviceGenre(id int) error {
  22. return global.GVA_DB.Unscoped().Where("id = ?", id).Delete(&DeviceGenre{}).Error
  23. }