123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- package chart_theme
- import (
- "errors"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // ChartTheme
- // @Description: 图表主题表
- type ChartTheme struct {
- ChartThemeId int `description:"图表主题类型ID" orm:"column(chart_theme_id);pk"`
- ChartThemeName string `description:"图表主题名称"`
- ChartThemeTypeId int `description:"图表主题类型ID"`
- ChartImage string `description:"缩略图"`
- Config string `description:"配置"`
- IsDelete int `description:"是否删除,0:未删除;1:已删除"`
- SysUserId int `description:"操作人"`
- SysUserRealName string `description:"操作人的真实名称"`
- IsSystemTheme int `description:"是否是系统主题,0:不是;1:是"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- // GetChartThemeId
- // @Description: 根据id获取主题
- // @author: Roc
- // @datetime 2023-12-14 16:05:36
- // @param chartThemeId int
- // @return item *ChartTheme
- // @return err error
- func GetChartThemeId(chartThemeId int) (item *ChartTheme, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM chart_theme where chart_theme_id = ? AND is_delete = 0`
- err = o.Raw(sql, chartThemeId).QueryRow(&item)
- return
- }
- // Add
- // @Description: 添加
- // @author: Roc
- // @receiver m
- // @datetime 2023-12-14 16:11:10
- // @param cols []string
- // @return err error
- func (m *ChartTheme) Add() (err error) {
- if m.ChartThemeId > 0 {
- err = errors.New("该配置已存在")
- return
- }
- o := orm.NewOrmUsingDB("data")
- lastId, err := o.Insert(m)
- if err != nil {
- return
- }
- m.ChartThemeId = int(lastId)
- return
- }
- // Update
- // @Description: 更新
- // @author: Roc
- // @receiver m
- // @datetime 2023-12-14 16:11:10
- // @param cols []string
- // @return err error
- func (m *ChartTheme) Update(cols []string) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.Update(m, cols...)
- return
- }
- // GetChartThemeListByTypeId
- // @Description: 根据图表类型获取关联的图表主题列表
- // @author: Roc
- // @datetime 2023-12-13 17:39:48
- // @return list []*ChartTheme
- // @return err error
- func GetChartThemeListByTypeId(chartThemeTypeId int) (list []*ChartTheme, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM chart_theme WHERE chart_theme_type_id = ? AND is_delete=0 ORDER BY chart_theme_id ASC `
- _, err = o.Raw(sql, chartThemeTypeId).QueryRows(&list)
- return
- }
- // GetAllChartThemeList
- // @Description: 获取所有图表主题列表
- // @author: Roc
- // @datetime 2023-12-13 17:39:48
- // @return list []*ChartTheme
- // @return err error
- func GetAllChartThemeList() (list []*ChartTheme, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT * FROM chart_theme WHERE is_delete=0 ORDER BY chart_theme_id ASC `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- // ChartThemeItem
- // @Description: 图表主题配置
- type ChartThemeItem struct {
- ChartThemeId int `description:"图表主题类型ID" orm:"column(chart_theme_id);pk"`
- ChartThemeName string `description:"图表主题名称"`
- ChartThemeTypeId int `description:"图表主题类型ID"`
- Config string `description:"配置"`
- ChartImage string `description:"缩略图"`
- //IsDelete int `description:"是否删除,0:未删除;1:已删除"`
- IsSystemTheme int `description:"是否是系统主题,0:不是;1:是"`
- SysUserId int `description:"操作人"`
- SysUserRealName string `description:"操作人的真实名称"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- DefaultChartThemeId int `description:"默认使用的图表主题ID"`
- }
- // GetChartThemeItemList
- // @Description: 根据图表类型id获取配置列表
- // @author: Roc
- // @datetime 2023-12-14 14:26:35
- // @param chartThemeTypeId int
- // @return list []*ChartThemeConfig
- // @return err error
- func GetChartThemeItemList(chartThemeTypeId int) (list []*ChartThemeItem, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT a.*,b.default_chart_theme_id FROM chart_theme a
- JOIN chart_theme_type b on a.chart_theme_type_id =b.chart_theme_type_id
- WHERE a.chart_theme_type_id = ? AND a.is_delete=0 ORDER BY a.chart_theme_id ASC `
- _, err = o.Raw(sql, chartThemeTypeId).QueryRows(&list)
- return
- }
- // GetSystemChartTheme
- // @Description: 根据图表类型id获取系统配置
- // @author: Roc
- // @datetime 2023-12-14 14:26:35
- // @param chartThemeTypeId int
- // @return item *ChartTheme
- // @return err error
- func GetSystemChartTheme(chartThemeTypeId int) (item *ChartTheme, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := `SELECT a.* FROM chart_theme a
- WHERE a.chart_theme_type_id = ? AND a.is_system_theme=1 ORDER BY a.chart_theme_id ASC `
- err = o.Raw(sql, chartThemeTypeId).QueryRow(&item)
- return
- }
- type ColorsOptions []string
- type LegendOptions struct {
- VerticalAlign string `json:"verticalAlign"`
- ItemStyle struct {
- Color string `json:"color"`
- FontSize int `json:"fontSize"`
- Cursor string `json:"cursor"`
- FontWeight string `json:"fontWeight"`
- TextOverflow string `json:"textOverflow"`
- } `json:"itemStyle"`
- }
- type TitleOptions struct {
- Align string `json:"align"`
- Style struct {
- Color string `json:"color"`
- FontSize int `json:"fontSize"`
- } `json:"style"`
- }
- type MarkerOptions struct {
- Style struct {
- Color string `json:"color"`
- FontSize int `json:"fontSize"`
- } `json:"style"`
- }
- type AxisOptions struct {
- Style struct {
- Color string `json:"color"`
- FontSize int `json:"fontSize"`
- } `json:"style"`
- }
- type DrawOption struct {
- PlotBackgroundColor string `json:"plotBackgroundColor"`
- }
- type LineOptions struct {
- DashStyle string `json:"dashStyle"`
- LineWidth float64 `json:"lineWidth"`
- LineType string `json:"lineType"`
- Radius float64 `json:"radius"`
- }
- type OldChartOptions struct {
- ColorsOptions []string `json:"colorsOptions"`
- LineOptions LineOptions `json:"lineOptions"`
- LegendOptions interface{} `json:"legendOptions"`
- TitleOptions interface{} `json:"titleOptions"`
- MarkerOptions interface{} `json:"markerOptions"`
- XAxisOptions interface{} `json:"xAxisOptions"`
- YAxisOptions interface{} `json:"yAxisOptions"`
- DrawOption interface{} `json:"drawOption"`
- LineOptionList []LineStyleOptions `json:"lineOptionList"`
- }
- type NewChartOptions struct {
- OldChartOptions
- LineOptionList []NewLineOptions `json:"lineOptionList"`
- }
- type NewLineOptions struct {
- LineOptions
- Color string `json:"color"`
- DataMark string `json:"dataMark"`
- MarkType string `json:"markType"`
- MarkSize int `json:"markSize"`
- MarkColor string `json:"markColor"`
- }
- type LineStyleOptions struct {
- DashStyle string `json:"dashStyle"`
- Color string `json:"color"`
- LineWidth float64 `json:"lineWidth"`
- LineType string `json:"lineType"`
- Radius int `json:"radius"`
- DataMark string `json:"dataMark"`
- MarkType string `json:"markType"`
- MarkSize int `json:"markSize"`
- MarkColor string `json:"markColor"`
- }
|