|
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
@@ -12,3 +13,23 @@ func NewEggEnergyUserActivityDb(engine *xorm.Engine) dao.EggEnergyUserActivityDa |
|
|
|
type EggEnergyUserActivityDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (e EggEnergyUserActivityDb) EggEnergyUserActivityGetOneByTimeAndUserID(userID int64, date string) (*model.EggEnergyUserActivity, error) { |
|
|
|
var m model.EggEnergyUserActivity |
|
|
|
has, err := e.Db.Where("uid = ?", userID).And("date = ?", date).Get(&m) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
if !has { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (e EggEnergyUserActivityDb) EggEnergyUserActivityInsert(m *model.EggEnergyUserActivity) (int64, error) { |
|
|
|
_, err := e.Db.InsertOne(m) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return m.Id, nil |
|
|
|
} |