// Package data_manage @Author gmy 2024/10/21 9:26:00 package data_manage import ( "github.com/beego/beego/v2/client/orm" ) type BaseFromRzdClassify struct { BaseFromRzdClassifyId int `orm:"column(base_from_rzd_classify_id);pk"` CreateTime string `orm:"column(create_time)"` ModifyTime string `orm:"column(modify_time)"` ClassifyName string `orm:"column(classify_name)"` ParentId int `orm:"column(parent_id)"` Sort int `orm:"column(sort)"` ClassifyNameEn string `orm:"column(classify_name_en)"` } type BaseFromRzdClassifyResponse struct { BaseFromRzdClassifyId int `orm:"column(base_from_rzd_classify_id);pk"` CreateTime string `orm:"column(create_time)"` ModifyTime string `orm:"column(modify_time)"` ClassifyName string `orm:"column(classify_name)"` ParentId int `orm:"column(parent_id)"` Sort int `orm:"column(sort)"` ClassifyNameEn string `orm:"column(classify_name_en)"` IndexInfo []*BaseFromRzdIndex Child []*BaseFromRzdClassifyResponse } func init() { orm.RegisterModel(new(BaseFromRzdClassify)) } // GetAllRzdClassify 查询所有分类 func GetAllRzdClassify() (items []*BaseFromRzdClassify, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_rzd_classify ORDER BY sort asc` _, err = o.Raw(sql).QueryRows(&items) return } // GetRzdClassifyItemByClassifyId 根据分类id查询分类信息 func GetRzdClassifyItemByClassifyId(classifyId int) (item *BaseFromRzdClassify, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT * FROM base_from_rzd_classify WHERE base_from_rzd_classify_id = ?` err = o.Raw(sql, classifyId).QueryRow(&item) if err != nil { return } return item, nil } func GetRzdClassifyItemByParentId(parentId int) (items []*BaseFromRzdClassify, err error) { o := orm.NewOrmUsingDB("data") sql := ` SELECT * FROM base_from_rzd_classify WHERE parent_id = ?` _, err = o.Raw(sql, parentId).QueryRows(&items) return }