variety_classify.go 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. package variety_classify
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // VarietyClassify 标签库分类表
  7. type VarietyClassify struct {
  8. VarietyClassifyId int `orm:"column(variety_classify_id);pk" description:"标签分类ID"`
  9. ClassifyName string `json:"classify_name" description:"标签分类名称"`
  10. Sort int `json:"sort" description:"排序"`
  11. State int `json:"state" description:"显示状态 0-禁用 1-启用"`
  12. CreateTime time.Time `json:"create_time" description:"创建时间"`
  13. ModifyTime time.Time `json:"modify_time" description:"更新时间"`
  14. }
  15. // GetVarietyClassifyList 获取标签分类列表
  16. func GetVarietyClassifyList() (list []*VarietyClassify, err error) {
  17. o := orm.NewOrm()
  18. sql := `SELECT * FROM variety_classify WHERE state = 1 ORDER BY sort`
  19. _, err = o.Raw(sql).QueryRows(&list)
  20. return
  21. }
  22. // GetVarietyClassifyById 主键获取分类
  23. func GetVarietyClassifyById(classifyId int) (item *VarietyClassify, err error) {
  24. o := orm.NewOrm()
  25. sql := `SELECT * FROM variety_classify WHERE variety_classify_id = ? LIMIT 1`
  26. err = o.Raw(sql, classifyId).QueryRow(&item)
  27. return
  28. }