enterprise/common/dao/unify_ad_data.go

44 lines
769 B
Go

package dao
import (
"enterprise/common/model"
"gorm.io/gorm"
)
type UnifyAdData struct {
}
func NewUnifyAdData() *UnifyAdData {
return &UnifyAdData{}
}
func (d *UnifyAdData) TableName() string {
return "unify_ad_data"
}
func (d *UnifyAdData) QueryOwnerData(owner, startDay, endDay string) ([]*model.UnifyAdData, error) {
tx := unifyDB.Table(d.TableName())
var o []*model.UnifyAdData
tx = tx.Where("data_type = ?", "account_report")
tx = tx.Where("owner = ?", owner)
if startDay != "" {
tx = tx.Where("day >= ?", startDay)
}
if endDay != "" {
tx = tx.Where("day <= ?", endDay)
}
tx.Order("day DESC")
tx = tx.Find(&o)
if tx.Error == gorm.ErrRecordNotFound {
return o, nil
}
if tx.Error != nil {
return nil, tx.Error
}
return o, nil
}