base_from_ccf_classify.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package data_manage
  2. import (
  3. "eta/eta_api/utils"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. // BaseFromCCFClassify CCF原始数据分类表
  8. type BaseFromCCFClassify struct {
  9. BaseFromCcfClassifyId int `orm:"column(base_from_ccf_classify_id);pk"`
  10. ClassifyName string `description:"分类名称"`
  11. ParentId int `description:"父级id"`
  12. SysUserId int `description:"创建人id"`
  13. SysUserRealName string `description:"创建人姓名"`
  14. Level int `description:"层级"`
  15. Sort int `description:"排序字段,越小越靠前,默认值:10"`
  16. ModifyTime time.Time `description:"修改时间"`
  17. CreateTime time.Time `description:"创建时间"`
  18. }
  19. // GetBaseFromCCFClassify 获取所有分类
  20. func GetBaseFromCCFClassify() (items []*BaseFromCCFClassify, err error) {
  21. o := orm.NewOrmUsingDB("data")
  22. sql := ` SELECT * FROM base_from_ccf_classify ORDER BY parent_id ASC, sort ASC, base_from_ccf_classify_id ASC`
  23. _, err = o.Raw(sql).QueryRows(&items)
  24. return
  25. }
  26. // BaseFromCCFClassifyItem CCF数据分类信息
  27. type BaseFromCCFClassifyItem struct {
  28. ClassifyId int `description:"分类ID"`
  29. ClassifyName string `description:"分类名称"`
  30. ParentId int `description:"父级id"`
  31. Level int `description:"层级"`
  32. Sort int `description:"排序字段"`
  33. CreateTime string `description:"创建时间"`
  34. ModifyTime string `description:"修改时间"`
  35. Child []*BaseFromCCFClassifyItem `description:"子分类"`
  36. }
  37. func (y *BaseFromCCFClassify) Format2Item(origin *BaseFromCCFClassify) (item *BaseFromCCFClassifyItem) {
  38. if origin == nil {
  39. return
  40. }
  41. item = new(BaseFromCCFClassifyItem)
  42. item.ClassifyId = origin.BaseFromCcfClassifyId
  43. item.ClassifyName = origin.ClassifyName
  44. item.ParentId = origin.ParentId
  45. item.Level = origin.Level
  46. item.Sort = origin.Sort
  47. item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
  48. item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
  49. return
  50. }