diff --git a/src/dao/playlet_total_dao.go b/src/dao/playlet_total_dao.go new file mode 100644 index 0000000..073c30d --- /dev/null +++ b/src/dao/playlet_total_dao.go @@ -0,0 +1,7 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type PlayletTotalDao interface { + GetPlayletTotal(uid, date string) (m *model.PlayletTotal, err error) +} diff --git a/src/dao/video_total_dao.go b/src/dao/video_total_dao.go new file mode 100644 index 0000000..29fccb6 --- /dev/null +++ b/src/dao/video_total_dao.go @@ -0,0 +1,7 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type VideoTotalDao interface { + GetVideoTotal(uid, date string) (m *model.VideoTotal, err error) +} diff --git a/src/implement/playlet_total_implement.go b/src/implement/playlet_total_implement.go new file mode 100644 index 0000000..7b7f565 --- /dev/null +++ b/src/implement/playlet_total_implement.go @@ -0,0 +1,28 @@ +package implement + +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "xorm.io/xorm" +) + +func NewPlayletTotalDb(engine *xorm.Engine) dao.PlayletTotalDao { + return &PlayletTotalDb{Db: engine} +} + +type PlayletTotalDb struct { + Db *xorm.Engine +} + +func (p PlayletTotalDb) GetPlayletTotal(uid, date string) (m *model.PlayletTotal, err error) { + m = new(model.PlayletTotal) + has, err := p.Db.Where("uid=? and date=?", uid, date).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} diff --git a/src/implement/video_total_implement.go b/src/implement/video_total_implement.go new file mode 100644 index 0000000..d1ba2ff --- /dev/null +++ b/src/implement/video_total_implement.go @@ -0,0 +1,28 @@ +package implement + +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "xorm.io/xorm" +) + +func NewVideoTotalDb(engine *xorm.Engine) dao.VideoTotalDao { + return &VideoTotalDb{Db: engine} +} + +type VideoTotalDb struct { + Db *xorm.Engine +} + +func (v VideoTotalDb) GetVideoTotal(uid, date string) (m *model.VideoTotal, err error) { + m = new(model.VideoTotal) + has, err := v.Db.Where("uid=? and date=?", uid, date).Get(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return m, nil +} diff --git a/src/model/playlet_total.go b/src/model/playlet_total.go new file mode 100644 index 0000000..ff12c66 --- /dev/null +++ b/src/model/playlet_total.go @@ -0,0 +1,13 @@ +package model + +import ( + "time" +) + +type PlayletTotal struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uid int `json:"uid" xorm:"INT(11)"` + Date int `json:"date" xorm:"default 0 INT(11)"` + Time time.Time `json:"time" xorm:"DATETIME"` + Total int `json:"total" xorm:"default 0 INT(11)"` +} diff --git a/src/model/video_total.go b/src/model/video_total.go new file mode 100644 index 0000000..adc30c8 --- /dev/null +++ b/src/model/video_total.go @@ -0,0 +1,13 @@ +package model + +import ( + "time" +) + +type VideoTotal struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uid int `json:"uid" xorm:"INT(11)"` + Date int `json:"date" xorm:"default 0 INT(11)"` + Time time.Time `json:"time" xorm:"DATETIME"` + Total int `json:"total" xorm:"default 0 INT(11)"` +}