@@ -16,8 +16,9 @@ import ( | |||||
var Db *xorm.Engine | var Db *xorm.Engine | ||||
//根据DB配置文件初始化数据库 | |||||
// 根据DB配置文件初始化数据库 | |||||
func InitDB(c *cfg.DBCfg) error { | func InitDB(c *cfg.DBCfg) error { | ||||
fmt.Println("db host::::", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4", c.User, c.Psw, c.Host, c.Name)) | |||||
var ( | var ( | ||||
err error | err error | ||||
f *os.File | f *os.File | ||||
@@ -10,4 +10,5 @@ type MasterDataStatisticsDao interface { | |||||
UpdateMasterDataStatistics(m *model.MasterDataStatistics, columns ...string) (int64, error) | UpdateMasterDataStatistics(m *model.MasterDataStatistics, columns ...string) (int64, error) | ||||
UpdateMasterDataStatisticsBySession(session *xorm.Session, m *model.MasterDataStatistics, columns ...string) (int64, error) | UpdateMasterDataStatisticsBySession(session *xorm.Session, m *model.MasterDataStatistics, columns ...string) (int64, error) | ||||
FindMasterDataStatisticsList(uuid, startDate, endDate string, page, limit int) (list []model.MasterDataStatistics, total int64, err error) | FindMasterDataStatisticsList(uuid, startDate, endDate string, page, limit int) (list []model.MasterDataStatistics, total int64, err error) | ||||
MasterDataStatisticsInsert(m *model.MasterDataStatistics) (int64, error) | |||||
} | } |
@@ -15,6 +15,14 @@ type MasterDataStatisticsDb struct { | |||||
Db *xorm.Engine | Db *xorm.Engine | ||||
} | } | ||||
func (m MasterDataStatisticsDb) MasterDataStatisticsInsert(mm *model.MasterDataStatistics) (int64, error) { | |||||
insertAffected, err := m.Db.InsertOne(m) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return insertAffected, nil | |||||
} | |||||
func (m MasterDataStatisticsDb) GetMasterDataStatistics(uuid int, date string) (data *model.MasterDataStatistics, err error) { | func (m MasterDataStatisticsDb) GetMasterDataStatistics(uuid int, date string) (data *model.MasterDataStatistics, err error) { | ||||
data = new(model.MasterDataStatistics) | data = new(model.MasterDataStatistics) | ||||
has, err := m.Db.Where("uuid =? and date =?", uuid, date).Get(data) | has, err := m.Db.Where("uuid =? and date =?", uuid, date).Get(data) | ||||
@@ -11,6 +11,10 @@ type MasterDataStatistics struct { | |||||
MediumSevenDayIncome int `json:"medium_seven_day_income" xorm:"not null default 0 comment('媒体七日收益(分)') INT(11)"` | MediumSevenDayIncome int `json:"medium_seven_day_income" xorm:"not null default 0 comment('媒体七日收益(分)') INT(11)"` | ||||
MediumThisMonthIncome int `json:"medium_this_month_income" xorm:"not null default 0 comment('媒体本月收益(分)') INT(11)"` | MediumThisMonthIncome int `json:"medium_this_month_income" xorm:"not null default 0 comment('媒体本月收益(分)') INT(11)"` | ||||
MediumLastMonthIncome int `json:"medium_last_month_income" xorm:"not null default 0 comment('媒体上月收益(分)') INT(11)"` | MediumLastMonthIncome int `json:"medium_last_month_income" xorm:"not null default 0 comment('媒体上月收益(分)') INT(11)"` | ||||
AgentTodayIncome int `json:"agent_today_income" xorm:"not null default 0 comment('代理今日收益(分)') INT(11)"` | |||||
AgentSevenDayIncome int `json:"agent_seven_day_income" xorm:"not null default 0 comment('代理七日收益(分)') INT(11)"` | |||||
AgentThisMonthIncome int `json:"agent_this_month_income" xorm:"not null default 0 comment('代理本月收益(分)') INT(11)"` | |||||
AgentLastMonthIncome int `json:"agent_last_month_income" xorm:"not null default 0 comment('代理上月收益(分)') INT(11)"` | |||||
MediumTodayExposureCount int `json:"medium_today_exposure_count" xorm:"not null default 0 comment('媒体今日曝光量') INT(11)"` | MediumTodayExposureCount int `json:"medium_today_exposure_count" xorm:"not null default 0 comment('媒体今日曝光量') INT(11)"` | ||||
MediumSevenDayExposureCount int `json:"medium_seven_day_exposure_count" xorm:"not null default 0 comment('媒体七日曝光量') INT(11)"` | MediumSevenDayExposureCount int `json:"medium_seven_day_exposure_count" xorm:"not null default 0 comment('媒体七日曝光量') INT(11)"` | ||||
MediumThisMonthExposureCount int `json:"medium_this_month_exposure_count" xorm:"not null default 0 comment('媒体本月曝光量') INT(11)"` | MediumThisMonthExposureCount int `json:"medium_this_month_exposure_count" xorm:"not null default 0 comment('媒体本月曝光量') INT(11)"` | ||||