package data_manage import ( "eta/eta_api/utils" "github.com/beego/beego/v2/client/orm" "time" ) // BaseFromCCFClassify CCF原始数据分类表 type BaseFromCCFClassify struct { BaseFromCcfClassifyId int `orm:"column(base_from_ccf_classify_id);pk"` ClassifyName string `description:"分类名称"` ParentId int `description:"父级id"` SysUserId int `description:"创建人id"` SysUserRealName string `description:"创建人姓名"` Level int `description:"层级"` Sort int `description:"排序字段,越小越靠前,默认值:10"` ModifyTime time.Time `description:"修改时间"` CreateTime time.Time `description:"创建时间"` } // GetBaseFromCCFClassify 获取所有分类 func GetBaseFromCCFClassify() (items []*BaseFromCCFClassify, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT * FROM base_from_ccf_classify ORDER BY parent_id ASC, sort ASC, base_from_ccf_classify_id ASC` _, err = o.Raw(sql).QueryRows(&items) return } // BaseFromCCFClassifyItem CCF数据分类信息 type BaseFromCCFClassifyItem struct { ClassifyId int `description:"分类ID"` ClassifyName string `description:"分类名称"` ParentId int `description:"父级id"` Level int `description:"层级"` Sort int `description:"排序字段"` CreateTime string `description:"创建时间"` ModifyTime string `description:"修改时间"` Child []*BaseFromCCFClassifyItem `description:"子分类"` } func (y *BaseFromCCFClassify) Format2Item(origin *BaseFromCCFClassify) (item *BaseFromCCFClassifyItem) { if origin == nil { return } item = new(BaseFromCCFClassifyItem) item.ClassifyId = origin.BaseFromCcfClassifyId item.ClassifyName = origin.ClassifyName item.ParentId = origin.ParentId item.Level = origin.Level item.Sort = origin.Sort item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime) item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime) return }