base_from_rzd_classify.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Package data_manage @Author gmy 2024/10/21 9:26:00
  2. package data_manage
  3. import (
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type BaseFromRzdClassify struct {
  7. BaseFromRzdClassifyId int `orm:"column(base_from_rzd_classify_id);pk"`
  8. CreateTime string `orm:"column(create_time)"`
  9. ModifyTime string `orm:"column(modify_time)"`
  10. ClassifyName string `orm:"column(classify_name)"`
  11. ParentId int `orm:"column(parent_id)"`
  12. Sort int `orm:"column(sort)"`
  13. ClassifyNameEn string `orm:"column(classify_name_en)"`
  14. }
  15. type BaseFromRzdClassifyResponse struct {
  16. BaseFromRzdClassifyId int `orm:"column(base_from_rzd_classify_id);pk"`
  17. CreateTime string `orm:"column(create_time)"`
  18. ModifyTime string `orm:"column(modify_time)"`
  19. ClassifyName string `orm:"column(classify_name)"`
  20. ParentId int `orm:"column(parent_id)"`
  21. Sort int `orm:"column(sort)"`
  22. ClassifyNameEn string `orm:"column(classify_name_en)"`
  23. IndexInfo []*BaseFromRzdIndex
  24. Child []*BaseFromRzdClassifyResponse
  25. }
  26. func init() {
  27. orm.RegisterModel(new(BaseFromRzdClassify))
  28. }
  29. // GetAllRzdClassify 查询所有分类
  30. func GetAllRzdClassify() (items []*BaseFromRzdClassify, err error) {
  31. o := orm.NewOrmUsingDB("data")
  32. sql := `SELECT * FROM base_from_rzd_classify ORDER BY sort asc`
  33. _, err = o.Raw(sql).QueryRows(&items)
  34. return
  35. }
  36. // GetRzdClassifyItemByClassifyId 根据分类id查询分类信息
  37. func GetRzdClassifyItemByClassifyId(classifyId int) (item *BaseFromRzdClassify, err error) {
  38. o := orm.NewOrmUsingDB("data")
  39. sql := ` SELECT * FROM base_from_rzd_classify WHERE base_from_rzd_classify_id = ?`
  40. err = o.Raw(sql, classifyId).QueryRow(&item)
  41. if err != nil {
  42. return
  43. }
  44. return item, nil
  45. }
  46. func GetRzdClassifyItemByParentId(parentId int) (items []*BaseFromRzdClassify, err error) {
  47. o := orm.NewOrmUsingDB("data")
  48. sql := ` SELECT * FROM base_from_rzd_classify WHERE parent_id = ?`
  49. _, err = o.Raw(sql, parentId).QueryRows(&items)
  50. return
  51. }