Quellcode durchsuchen

update

tags/v0.0.2
shenjiachi vor 1 Woche
Ursprung
Commit
62870bd0cf
2 geänderte Dateien mit 16 neuen und 11 gelöschten Zeilen
  1. +1
    -2
      src/dao/egg_energy_user_activity_dao.go
  2. +15
    -9
      src/implement/egg_energy_user_activity_implement.go

+ 1
- 2
src/dao/egg_energy_user_activity_dao.go Datei anzeigen

@@ -2,6 +2,5 @@

type EggEnergyUserActivityDao interface {
//TODO:: You can add specific method definitions here
UserDailyActivityAnalysisFindByUidAndTime(startDate string, endDate string, uid []int64) (int64, error)
UserDailyActivityAnalysisCountByUidAndTime(startDate string, endDate string, uid int64) (int64, error)
UserDailyActivityAnalysisCountByUidAndTime(startDate string, endDate string, uid ...int64) (int64, error)
}

+ 15
- 9
src/implement/egg_energy_user_activity_implement.go Datei anzeigen

@@ -4,6 +4,8 @@ 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"
"errors"
"fmt"
"xorm.io/xorm"
)

@@ -15,18 +17,22 @@ type EggEnergyUserActivityDb struct {
Db *xorm.Engine
}

func (e EggEnergyUserActivityDb) UserDailyActivityAnalysisFindByUidAndTime(startDate string, endDate string, uid []int64) (int64, error) {
func (e EggEnergyUserActivityDb) UserDailyActivityAnalysisCountByUidAndTime(startDate string, endDate string, uid ...int64) (int64, error) {
var m model.EggEnergyUserActivity
count, err := e.Db.Where("uid in ?", uid).And("date > ?", startDate).And("date < ?", endDate).Count(&m)
if err != nil {
return 0, zhios_order_relate_logx.Error(err)

var session *xorm.Session
query1 := fmt.Sprintf("uid = ?")
query2 := fmt.Sprintf("uid in ?")
if len(uid) == 1 {
session = e.Db.Where(query1, uid)
} else if len(uid) > 1 {
session = e.Db.Where(query2, uid)
}
if session == nil {
return 0, zhios_order_relate_logx.Error(errors.New("传入参数有误"))
}
return count, nil
}

func (e EggEnergyUserActivityDb) UserDailyActivityAnalysisCountByUidAndTime(startDate string, endDate string, uid int64) (int64, error) {
var m model.EggEnergyUserActivity
count, err := e.Db.Where("uid = ?", uid).And("date > ?", startDate).And("date < ?", endDate).Count(&m)
count, err := session.And("date > ?", startDate).And("date < ?", endDate).Count(&m)
if err != nil {
return 0, zhios_order_relate_logx.Error(err)
}


Laden…
Abbrechen
Speichern