package edb_refresh import ( "errors" "github.com/beego/beego/v2/client/orm" "time" ) // EdbRefreshConfig // @Description: 指标的刷新时间配置表 type EdbRefreshConfig struct { EdbRefreshConfigId int `orm:"column(edb_refresh_config_id);pk"` RefreshFrequency string `description:"刷新频率"` RefreshFrequencyDay int `description:"具体刷新的日期"` RefreshTime string `description:"刷新时间"` RefreshAllData int `description:"是否刷新所有数据,0:否,1:刷新所有数据"` RefreshDataNum int `description:"刷新单元格数"` ModifyTime time.Time `description:"最晚一次的更新时间"` CreateTime time.Time `description:"添加时间"` } // Add // @Description: 添加 // @author: Roc // @receiver m // @datetime 2023-12-14 16:11:10 // @param cols []string // @return err error func (m *EdbRefreshConfig) Add() (err error) { if m.EdbRefreshConfigId > 0 { err = errors.New("该配置已存在") return } o := orm.NewOrm() lastId, err := o.Insert(m) if err != nil { return } m.EdbRefreshConfigId = int(lastId) return } // Update // @Description: 更新 // @author: Roc // @receiver m // @datetime 2023-12-14 16:11:10 // @param cols []string // @return err error func (m *EdbRefreshConfig) Update(cols []string) (err error) { o := orm.NewOrm() _, err = o.Update(m, cols...) return } // Delete // @Description: 删除 // @author: Roc // @receiver m // @datetime 2023-12-14 16:11:10 // @return err error func (m *EdbRefreshConfig) Delete() (err error) { o := orm.NewOrm() _, err = o.Delete(m) return } // GetEdbRefreshConfigListByCondition // @Description: 根据条条件获取刷新配置列表 // @author: Roc // @datetime 2024-01-09 13:28:49 // @param condition string // @param pars []interface{} // @return list []*EdbRefreshDefaultConfig // @return err error func GetEdbRefreshConfigListByCondition(condition string, pars []interface{}) (list []*EdbRefreshConfig, err error) { o := orm.NewOrm() sql := `SELECT * FROM edb_refresh_config WHERE 1 = 1 ` if condition != "" { sql += condition } sql += ` ORDER BY edb_refresh_config_id ASC ` _, err = o.Raw(sql, pars).QueryRows(&list) return }