excel_classify.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package excel
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ExcelClassify excel表格分类
  7. type ExcelClassify struct {
  8. ExcelClassifyId int `orm:"column(excel_classify_id);pk"`
  9. Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"`
  10. ExcelClassifyName string `description:"分类名称"`
  11. ParentId int `description:"父级id"`
  12. SysUserId int `description:"创建人id"`
  13. SysUserRealName string `description:"创建人姓名"`
  14. Level int `description:"层级"`
  15. UniqueCode string `description:"唯一编码"`
  16. Sort int `description:"排序字段,越小越靠前,默认值:10"`
  17. IsDelete int `description:"排序字段,越小越靠前,默认值:10"`
  18. CreateTime time.Time `description:"创建时间"`
  19. ModifyTime time.Time `description:"修改时间"`
  20. }
  21. // AddExcelClassify 添加excel分类
  22. func AddExcelClassify(item *ExcelClassify) (lastId int64, err error) {
  23. o := orm.NewOrm()
  24. lastId, err = o.Insert(item)
  25. if err != nil {
  26. return
  27. }
  28. item.ExcelClassifyId = int(lastId)
  29. return
  30. }
  31. type ExcelClassifyItems struct {
  32. ExcelClassifyId int `description:"分类id"`
  33. ExcelInfoId int `description:"表格id"`
  34. ExcelClassifyName string
  35. ParentId int
  36. Level int `description:"层级"`
  37. Sort int `description:"排序字段,越小越靠前,默认值:10"`
  38. UniqueCode string `description:"唯一编码"`
  39. SysUserId int `description:"创建人id"`
  40. SysUserRealName string `description:"创建人姓名"`
  41. StartDate string `description:"自定义开始日期"`
  42. Children []*ExcelClassifyItems
  43. }
  44. // GetExcelClassifyByParentId
  45. // @Description: 根据父级分类id获取指标下面的分类列表
  46. // @author: Roc
  47. // @datetime2023-10-30 13:46:35
  48. // @param parentId int
  49. // @param source int
  50. // @return items []*ExcelClassifyItems
  51. // @return err error
  52. func GetExcelClassifyByParentId(parentId, source int) (items []*ExcelClassifyItems, err error) {
  53. o := orm.NewOrm()
  54. sql := ` SELECT * FROM excel_classify WHERE parent_id=? AND source = ? AND is_delete=0 order by sort asc,excel_classify_id asc`
  55. _, err = o.Raw(sql, parentId, source).QueryRows(&items)
  56. return
  57. }