12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package models
- import (
- "eta/eta_forum_task/utils"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // ChartThemeDefaultData
- // @Description: 图表默认数据
- type ChartThemeDefaultData struct {
- EdbDataId int `description:"指标数据ID" orm:"column(edb_data_id);pk"`
- EdbInfoId int `description:"指标ID"`
- EdbCode string `description:"指标编码"`
- DataTime string //`json:"-" description:"数据日期"`
- DataTimestamp int64 `description:"数据日期"`
- Value float64 `description:"数据值"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- // GetChartThemeDefaultDataList
- // @Description: 获取指标的数据(日期正序返回)
- // @author: Roc
- // @datetime 2023-12-13 16:40:14
- // @param endInfoId int
- // @return list []*ChartThemeDefaultData
- // @return err error
- func GetChartThemeDefaultDataList(endInfoId int) (list []*ChartThemeDefaultData, err error) {
- sql := `SELECT * FROM chart_theme_default_data WHERE edb_info_id=? `
- sql += ` ORDER BY data_time ASC `
- o := orm.NewOrmUsingDB("data")
- _, err = o.Raw(sql, endInfoId).QueryRows(&list)
- return
- }
- // Update
- // @Description: 更新
- // @author: Roc
- // @receiver m
- // @datetime 2023-12-13 16:40:04
- // @param cols []string
- // @return err error
- func (m *ChartThemeDefaultData) Update(cols []string) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.Update(m, cols...)
- return
- }
- // GetChartThemeDefaultDataItemList
- // @Description: 获取指标的数据(日期正序返回)
- // @author: Roc
- // @datetime 2023-12-13 16:40:22
- // @param endInfoId int
- // @return list []*ChartThemeDefaultDataItem
- // @return err error
- func GetChartThemeDefaultDataItemList(endInfoId int, startDate string) (list []*EdbDataList, err error) {
- sql := `SELECT edb_data_id,edb_info_id,data_time,value,data_timestamp FROM chart_theme_default_data WHERE edb_info_id=? `
- var pars []interface{}
- if startDate != "" {
- sql += ` AND data_time>=? `
- pars = append(pars, startDate)
- }
- sql += ` ORDER BY data_time ASC `
- o := orm.NewOrmUsingDB("data")
- _, err = o.Raw(sql, endInfoId, pars).QueryRows(&list)
- return
- }
- // GetChartEdbMappingListByEdbInfoId
- // @Description: 返回模拟的mapping假数据
- // @author: Roc
- // @datetime 2023-12-14 10:03:20
- // @param edbInfoIdList []int
- // @return list []*models.ChartEdbInfoMapping
- // @return err error
- func GetChartEdbMappingListByEdbInfoId(edbInfoIdList []int) (list []*ChartEdbInfoMapping, err error) {
- num := len(edbInfoIdList)
- if num <= 0 {
- return
- }
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT * FROM chart_theme_default_edb_info WHERE edb_info_id IN(` + utils.GetOrmInReplace(num) + `)
- `
- _, err = o.Raw(sql, edbInfoIdList).QueryRows(&list)
- return
- }
|