classify_menu.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ClassifyMenu 报告分类-子目录表
  7. type ClassifyMenu struct {
  8. MenuId int `orm:"column(menu_id);pk"`
  9. MenuName string `description:"子目录名称"`
  10. ClassifyId int `description:"一级分类ID"`
  11. Sort int `description:"排序"`
  12. CreateTime time.Time `description:"创建时间"`
  13. ModifyTime time.Time `description:"更新时间"`
  14. }
  15. // GetClassifyMenuById 主键获取子目录
  16. func GetClassifyMenuById(id int) (item *ClassifyMenu, err error) {
  17. o := orm.NewOrmUsingDB("rddp")
  18. sql := `SELECT * FROM classify_menu WHERE menu_id = ? LIMIT 1`
  19. err = o.Raw(sql, id).QueryRow(&item)
  20. return
  21. }
  22. // GetClassifyMenuList 获取子目录列表
  23. func GetClassifyMenuList(condition string, pars []interface{}) (list []*ClassifyMenu, err error) {
  24. o := orm.NewOrmUsingDB("rddp")
  25. sql := `SELECT * FROM classify_menu WHERE 1 = 1 `
  26. sql += condition
  27. sql += ` ORDER BY sort ASC, create_time ASC`
  28. _, err = o.Raw(sql, pars).QueryRows(&list)
  29. return
  30. }