classify_menu_relation.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import (
  3. "eta_gn/eta_api/global"
  4. "eta_gn/eta_api/utils"
  5. "time"
  6. )
  7. // ClassifyMenuRelation 报告分类-子目录关联表
  8. type ClassifyMenuRelation struct {
  9. Id int `gorm:"column:id;primaryKey"` //`orm:"column(id);pk" gorm:"primaryKey" `
  10. MenuId int `gorm:"column:menu_id"` //`description:"子目录ID"`
  11. ClassifyId int `gorm:"column:classify_id"` //`description:"二级分类ID"`
  12. CreateTime time.Time `gorm:"column:create_time"` //`description:"创建时间"`
  13. }
  14. func (item *ClassifyMenuRelation) TableName() string {
  15. return "classify_menu_relation"
  16. }
  17. func (item *ClassifyMenuRelation) Create() (err error) {
  18. err = global.DmSQL["rddp"].Create(item).Error
  19. return
  20. }
  21. func (item *ClassifyMenuRelation) Update(cols []string) (err error) {
  22. err = global.DmSQL["rddp"].Select(cols).Updates(item).Error
  23. return
  24. }
  25. func (item *ClassifyMenuRelation) InsertMulti(items []*ClassifyMenuRelation) (err error) {
  26. err = global.DmSQL["rddp"].CreateInBatches(items, utils.MultiAddNum).Error
  27. return
  28. }
  29. // GetClassifyMenuRelationList 获取子目录关联列表
  30. func GetClassifyMenuRelationList(condition string, pars []interface{}) (list []*ClassifyMenuRelation, err error) {
  31. sql := `SELECT * FROM classify_menu_relation WHERE 1 = 1 `
  32. sql += condition
  33. sql += ` ORDER BY create_time DESC`
  34. err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&list).Error
  35. return
  36. }