|
@@ -0,0 +1,75 @@
|
|
|
+package data_manage
|
|
|
+
|
|
|
+import (
|
|
|
+ "errors"
|
|
|
+ "github.com/beego/beego/v2/client/orm"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+// EdbRefreshDefaultConfig
|
|
|
+// @Description: 指标的默认刷新时间配置表
|
|
|
+type EdbRefreshDefaultConfig struct {
|
|
|
+ Id int `orm:"column(id);pk"`
|
|
|
+ Source int `description:"来源"`
|
|
|
+ SubSource int `description:"来源名称"`
|
|
|
+ Frequency string `description:"频度"`
|
|
|
+ RefreshFrequency string `description:"刷新频率"`
|
|
|
+ RefreshFrequencyNum int `description:"具体刷新的日期"`
|
|
|
+ RefreshTime string `description:"刷新时间"`
|
|
|
+ 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 *EdbRefreshDefaultConfig) Add() (err error) {
|
|
|
+ if m.Id > 0 {
|
|
|
+ err = errors.New("该配置已存在")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ lastId, err := o.Insert(m)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ m.Id = int(lastId)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// Update
|
|
|
+// @Description: 更新
|
|
|
+// @author: Roc
|
|
|
+// @receiver m
|
|
|
+// @datetime 2023-12-14 16:11:10
|
|
|
+// @param cols []string
|
|
|
+// @return err error
|
|
|
+func (m *EdbRefreshDefaultConfig) Update(cols []string) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ _, err = o.Update(m, cols...)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetListBySourceAndFrequency
|
|
|
+// @Description: 根据来源和频度获取列表
|
|
|
+// @author: Roc
|
|
|
+// @datetime 2024-01-04 17:39:47
|
|
|
+// @param source int
|
|
|
+// @param subSource int
|
|
|
+// @param frequency string
|
|
|
+// @return list []*EdbRefreshDefaultConfig
|
|
|
+// @return err error
|
|
|
+func GetListBySourceAndFrequency(source, subSource int, frequency string) (list []*EdbRefreshDefaultConfig, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("data")
|
|
|
+ sql := `SELECT * FROM edb_refresh_default_config
|
|
|
+ WHERE source = ? AND sub_source = ? AND frequency = ? ORDER BY id ASC `
|
|
|
+ _, err = o.Raw(sql, source, subSource, frequency).QueryRows(&list)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|