base_from_ly_classify.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Package data_manage
  2. // @Author gmy 2024/8/7 9:26:00
  3. package data_manage
  4. import "github.com/beego/beego/v2/client/orm"
  5. type BaseFromLyClassify struct {
  6. BaseFromLyClassifyId int `orm:"column(base_from_ly_classify_id);pk" description:"分类ID"`
  7. CreateTime string `orm:"column(create_time)" description:"创建时间"`
  8. ModifyTime string `orm:"column(modify_time)" description:"修改时间"`
  9. ClassifyName string `orm:"column(classify_name)" description:"分类名称"`
  10. ParentId int `orm:"column(parent_id)" description:"上级id"`
  11. Sort int `orm:"column(sort)" description:"排序字段,越小越靠前"`
  12. ClassifyNameEn string `orm:"column(classify_name_en)" description:"英文分类名称"`
  13. }
  14. type BaseFromLyClassifyAndIndexInfo struct {
  15. BaseFromLyClassifyId int `orm:"column(base_from_ly_classify_id);pk" description:"分类ID"`
  16. CreateTime string `orm:"column(create_time)" description:"创建时间"`
  17. ModifyTime string `orm:"column(modify_time)" description:"修改时间"`
  18. ClassifyName string `orm:"column(classify_name)" description:"分类名称"`
  19. ParentId int `orm:"column(parent_id)" description:"上级id"`
  20. Sort int `orm:"column(sort)" description:"排序字段,越小越靠前"`
  21. ClassifyNameEn string `orm:"column(classify_name_en)" description:"英文分类名称"`
  22. IndexId int `orm:"column(base_from_ly_index_id)" description:"指标id"`
  23. IndexCode string `orm:"column(index_code)" description:"指标编码"`
  24. IndexName string `orm:"column(index_name)" description:"指标名称"`
  25. }
  26. func init() {
  27. orm.RegisterModel(new(BaseFromLyClassify))
  28. }
  29. // GetAllLyClassify 查询所有分类
  30. func GetAllLyClassify() (items []*BaseFromLyClassify, err error) {
  31. o := orm.NewOrmUsingDB("data")
  32. sql := `SELECT * FROM base_from_ly_classify ORDER BY sort asc`
  33. _, err = o.Raw(sql).QueryRows(&items)
  34. return
  35. }
  36. // GetLyClassifyById 根据分类id查询
  37. func GetLyClassifyById(classifyId int) (item *BaseFromLyClassify, err error) {
  38. o := orm.NewOrmUsingDB("data")
  39. sql := `SELECT * FROM base_from_ly_classify WHERE base_from_ly_classify_id=?`
  40. err = o.Raw(sql, classifyId).QueryRow(&item)
  41. return
  42. }