package excel import ( "github.com/beego/beego/v2/client/orm" "time" ) // ExcelClassify excel表格分类 type ExcelClassify struct { ExcelClassifyId int `orm:"column(excel_classify_id);pk"` Source int `description:"表格来源,1:excel插件的表格,2:自定义表格,3:混合表格,4:自定义分析,默认:1"` ExcelClassifyName string `description:"分类名称"` ParentId int `description:"父级id"` SysUserId int `description:"创建人id"` SysUserRealName string `description:"创建人姓名"` Level int `description:"层级"` UniqueCode string `description:"唯一编码"` Sort int `description:"排序字段,越小越靠前,默认值:10"` IsDelete int `description:"排序字段,越小越靠前,默认值:10"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` } // AddExcelClassify 添加excel分类 func AddExcelClassify(item *ExcelClassify) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) if err != nil { return } item.ExcelClassifyId = int(lastId) return } type ExcelClassifyItems struct { ExcelClassifyId int `description:"分类id"` ExcelInfoId int `description:"表格id"` ExcelClassifyName string ParentId int Level int `description:"层级"` Sort int `description:"排序字段,越小越靠前,默认值:10"` UniqueCode string `description:"唯一编码"` SysUserId int `description:"创建人id"` SysUserRealName string `description:"创建人姓名"` StartDate string `description:"自定义开始日期"` Children []*ExcelClassifyItems } // GetExcelClassifyByParentId // @Description: 根据父级分类id获取指标下面的分类列表 // @author: Roc // @datetime2023-10-30 13:46:35 // @param parentId int // @param source int // @return items []*ExcelClassifyItems // @return err error func GetExcelClassifyByParentId(parentId, source int) (items []*ExcelClassifyItems, err error) { o := orm.NewOrm() sql := ` SELECT * FROM excel_classify WHERE parent_id=? AND source = ? AND is_delete=0 order by sort asc,excel_classify_id asc` _, err = o.Raw(sql, parentId, source).QueryRows(&items) return }