package data_manage import ( "github.com/rdlucklib/rdluck_tools/orm" "time" ) type TableInfo struct { TableInfoId int `orm:"column(table_info_id);pk"` TableName string `description:"表格名称"` UniqueCode string `description:"表格唯一编码"` TableClassifyId int `description:"表格分类id"` SysUserId int `description:"操作人id"` SysUserRealName string `description:"操作人真实姓名"` StartDate time.Time `description:"开始日期"` EdbInfoIds string `description:"指标id"` TableType int `description:"表格类型,1:指标+日期"` TableImage string `description:"图表图片"` Sort int `description:"排序字段,数字越小越排前面"` EdbEndDate time.Time `description:"指标最后更新日期"` ModifyTime time.Time CreateTime time.Time } type TableInfoItem struct { TableInfoId int `description:"图表id"` TableName string `description:"图表名称"` TableClassifyId int `description:"图表分类"` } //图表检索数据 type TableInfoSearch struct { EdbCode string `description:"图表编码"` StartDate string `description:"起始日期"` EndDate string `description:"终止日期"` DataList []*EdbInfoSearchData } // GetTableInfoById 根据id获取表格详情 func GetTableInfoById(tableInfoId int) (item *TableInfo, err error) { o := orm.NewOrm() o.Using("data") sql := ` SELECT * FROM table_info WHERE table_info_id=? ` err = o.Raw(sql, tableInfoId).QueryRow(&item) return } // GetAllTableInfoList 获取所有的 ETA表格信息 func GetAllTableInfoList() (items []*TableInfo, err error) { o := orm.NewOrm() o.Using("data") sql := ` select * from table_info order by table_info_id desc` _, err = o.Raw(sql).QueryRows(&items) return } func GetTableInfoByCondition(condition string, pars []interface{}) (item *TableInfo, err error) { o := orm.NewOrm() o.Using("data") sql := ` SELECT * FROM table_info WHERE 1=1 ` if condition != "" { sql += condition } err = o.Raw(sql, pars).QueryRow(&item) return } func ModifyTableInfoModifyTime(tableInfoId int64) (err error) { o := orm.NewOrm() o.Using("data") sql := ` UPDATE table_info SET modify_time = NOW() WHERE table_info_id = ? ` _, err = o.Raw(sql, tableInfoId).Exec() return } // TableDataList 表格数据 type TableDataList struct { Date string `description:"指标日期"` DataCol1 string `description:"第1个表格的数据"` DataCol2 string `description:"第2个表格的数据"` DataCol3 string `description:"第3个表格的数据"` DataCol4 string `description:"第4个表格的数据"` DataCol5 string `description:"第5个表格的数据"` DataCol6 string `description:"第6个表格的数据"` DataCol7 string `description:"第7个表格的数据"` DataCol8 string `description:"第8个表格的数据"` DataCol9 string `description:"第9个表格的数据"` DataCol10 string `description:"第10个表格的数据"` DataType int8 `description:"数据类型,默认的区间数据是 1;插入数据是 2"` Sort int `description:"排序字段,越小越靠前"` } // Update 更新图表基础信息 func (tableInfo *TableInfo) Update(cols []string) (err error) { o := orm.NewOrm() o.Using("data") _, err = o.Update(tableInfo, cols...) return } // GetTableInfoByClassifyIdAndName 根据分类id和图表名获取图表信息 func GetTableInfoByClassifyIdAndName(classifyId int, tableName string) (item *TableInfo, err error) { o := orm.NewOrm() o.Using("data") sql := ` SELECT * FROM table_info WHERE table_classify_id = ? and table_name=? ` err = o.Raw(sql, classifyId, tableName).QueryRow(&item) return }