package data_manage import ( "github.com/rdlucklib/rdluck_tools/orm" "time" ) type BaseFromSmm struct { BaseFromSmmId int `orm:"column(base_from_smm_id);pk"` Aid int Name string Interface string ApiUpdate int ApiUpdateType string ApiType int ApiTypeAll string Type1 string `orm:"column(type_1)"` Type2 string `orm:"column(type_2)"` Type3 string `orm:"column(type_3)"` ApiStartTime string ApiUpdateTime string StartTime string FinishTime string AuthModule string AuthLang string ApiLabel string Enable string EditPerson string EditTime string AuthDur int AuthDurType string } func AddBaseFromSmm(item *BaseFromSmm) (lastId int64, err error) { o := orm.NewOrm() o.Using("data") lastId, err = o.Insert(item) return } func GetBaseFromSmmList() (list []*BaseFromSmm, err error) { o := orm.NewOrm() o.Using("data") sql := `SELECT * FROM base_from_smm ` _, err = o.Raw(sql).QueryRows(&list) return } func GetBaseFromSmmBySmmCode(smmCode string) (item *BaseFromSmm, err error) { o := orm.NewOrm() o.Using("data") sql := `SELECT * FROM base_from_smm WHERE interface=?` err = o.Raw(sql, smmCode).QueryRow(&item) return } type BaseFromSmmIndex struct { BaseFromSmmIndexId int `orm:"column(base_from_smm_index_id);pk"` Interface string Name string IndexCode string IndexName string Type1 string `orm:"column(type_1)"` Type2 string `orm:"column(type_2)"` Type3 string `orm:"column(type_3)"` Frequency string Unit string ApiStartTime string ApiUpdateTime string StartTime string FinishTime string CreateTime time.Time ModifyTime time.Time } func AddBaseFromSmmIndex(item *BaseFromSmmIndex) (lastId int64, err error) { o := orm.NewOrm() o.Using("data") lastId, err = o.Insert(item) return } func GetBaseFromSmmIndex() (list []*BaseFromSmmIndex, err error) { o := orm.NewOrm() o.Using("data") sql := `SELECT * FROM base_from_smm_index ` _, err = o.Raw(sql).QueryRows(&list) return } type BaseFromSmmData struct { SmmDataId int `orm:"column(smm_data_id);pk"` BaseFromSmmIndexId int IndexCode string DataTime string Value string CreateTime time.Time ModifyTime time.Time DataTimestamp int64 } func AddBaseFromSmmData(item *BaseFromSmmData) (lastId int64, err error) { o := orm.NewOrm() o.Using("data") lastId, err = o.Insert(item) return } func GetBaseFromSmmDataAll() (list []*BaseFromSmmData, err error) { o := orm.NewOrm() o.Using("data") sql := `SELECT * FROM base_from_smm_data ` _, err = o.Raw(sql).QueryRows(&list) return } func ModifyBaseFromSmmData(smmDataId int, value string) (err error) { o := orm.NewOrm() o.Using("data") sql := `UPDATE base_from_smm_data SET value=?,modify_time=NOW() WHERE smm_data_id=? ` _, err = o.Raw(sql, value, smmDataId).Exec() return } func GetBaseFromSmmIndexBySmmCode(smmCode string) (list []*BaseFromSmmIndex, err error) { o := orm.NewOrm() o.Using("data") sql := ` SELECT * FROM base_from_smm_index WHERE interface=? ` _, err = o.Raw(sql, smmCode).QueryRows(&list) return } func GetBaseFromSmmMaxOrMinDate(indexCode string) (min_date, max_date string, err error) { o := orm.NewOrm() o.Using("data") sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM base_from_smm_data WHERE index_code=? ` err = o.Raw(sql, indexCode).QueryRow(&min_date, &max_date) return } func ModifyBaseFromSmmMinDateAndMaxDate(baseFromSmmIndexId int, minDate, maxDate string) (err error) { o := orm.NewOrm() o.Using("data") sql := ` UPDATE base_from_smm_index SET start_date=?,end_date=?,modify_time=NOW() WHERE base_from_smm_index_id=? ` _, err = o.Raw(sql, minDate, maxDate, baseFromSmmIndexId).Exec() return } func GetBaseFromSmmDataAllByIndexCode(indexCode string) (list []*BaseFromSmmData, err error) { o := orm.NewOrm() o.Using("data") sql := `SELECT * FROM base_from_smm_data WHERE index_code=? ` _, err = o.Raw(sql, indexCode).QueryRows(&list) return } func GetBaseFromSmmIndexByIndexCode(indexCode string) (list *BaseFromSmmIndex, err error) { o := orm.NewOrm() o.Using("data") sql := ` SELECT * FROM base_from_smm_index WHERE index_code=? ` err = o.Raw(sql, indexCode).QueryRow(&list) return }