package data_manage

import (
	"github.com/beego/beego/v2/client/orm"
)

type ChartType struct {
	ChartTypeId     int    `orm:"column(chart_type_id);pk"`
	ChartTypeName   string `description:"图表类型名称"`
	ChartTypeNameEn string `description:"英文图表类型名称"`
	ParentId        int    `description:"父级ID"`
	Sort            int    `description:"排序"`
	CreateTime      string `description:"创建时间"`
}

type ChartTypeList struct {
	ChartTypeId     int
	ChartTypeName   string `description:"图表类型名称"`
	ChartTypeNameEn string `description:"英文图表类型名称"`
	ParentId        int    `description:"父级ID"`
	Child           []ChartType
}

type ChartTypeListResp struct {
	List []ChartTypeList
}

func (c *ChartType) TableName() string {
	return "chart_type"
}

// 查询所有图表类型
func GetChartTypeList() (items []ChartType, err error) {
	o := orm.NewOrmUsingDB("data")
	sql := `SELECT * FROM chart_type order by sort asc`
	_, err = o.Raw(sql).QueryRows(&items)
	return
}
