123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package edb_refresh
- import (
- "errors"
- "eta/eta_index_lib/global"
- "time"
- )
- type EdbRefreshDefaultConfig struct {
- Id int `gorm:"primaryKey;autoIncrement;column:id" description:"唯一ID"`
- Source int `gorm:"column:source" description:"来源"`
- SubSource int `gorm:"column:sub_source" description:"来源名称"`
- Frequency string `gorm:"column:frequency" description:"频度"`
- RefreshFrequency string `gorm:"column:refresh_frequency" description:"刷新频率"`
- RefreshFrequencyDay int `gorm:"column:refresh_frequency_day" description:"具体刷新的日期"`
- RefreshTime string `gorm:"column:refresh_time" description:"刷新时间"`
- RefreshAllData int `gorm:"column:refresh_all_data" description:"是否刷新所有数据,0:否,1:刷新所有数据"`
- RefreshDataNum int `gorm:"column:refresh_data_num" description:"刷新单元格数"`
- ModifyTime time.Time `gorm:"column:modify_time" description:"最晚一次的更新时间"`
- CreateTime time.Time `gorm:"column:create_time" description:"添加时间"`
- }
- func (m *EdbRefreshDefaultConfig) Add() (err error) {
- if m.Id > 0 {
- err = errors.New("该配置已存在")
- return
- }
- err = global.DEFAULT_DB.Create(m).Error
- return
- }
- func (m *EdbRefreshDefaultConfig) Update(cols []string) (err error) {
- err = global.DEFAULT_DB.Model(m).Select(cols).Updates(m).Error
- return
- }
- func (m *EdbRefreshDefaultConfig) Delete() (err error) {
- err = global.DEFAULT_DB.Delete(m).Error
- return
- }
- func GetListBySourceAndFrequency(source, subSource int, frequency string) (list []*EdbRefreshDefaultConfig, err error) {
- sql := `SELECT * FROM edb_refresh_default_config
- WHERE source = ? AND sub_source = ? AND frequency = ? ORDER BY id ASC `
- err = global.DEFAULT_DB.Raw(sql, source, subSource, frequency).Find(&list).Error
- return
- }
- func GetListByCondition(condition string, pars []interface{}) (list []*EdbRefreshDefaultConfig, err error) {
- sql := `SELECT * FROM edb_refresh_default_config
- WHERE 1 = 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` ORDER BY id ASC `
- err = global.DEFAULT_DB.Raw(sql, pars...).Find(&list).Error
- return
- }
- func GetDefaultRefreshEdbInfoListBySourceAndSubSource(source, subSource int, frequencyList []string) (list []*EdbInfoListAndRefreshConfig, err error) {
- num := len(frequencyList)
- if num <= 0 {
- return
- }
- sql := `SELECT a.* FROM edb_info a
- LEFT JOIN edb_refresh_mapping b ON a.edb_info_id = b.edb_info_id
- WHERE a.source = ? AND a.sub_source = ? AND a.frequency IN (?) AND b.edb_info_id is null`
- err = global.DEFAULT_DB.Raw(sql, source, subSource, frequencyList).Find(&list).Error
- return
- }
|