同步历史版本代码
This commit is contained in:
@@ -99,6 +99,7 @@ type customUserLogicModel interface {
|
||||
FindOneByEmail(ctx context.Context, email string) (*User, error)
|
||||
FindOneDevice(ctx context.Context, id int64) (*Device, error)
|
||||
QueryDeviceList(ctx context.Context, userid int64) ([]*Device, int64, error)
|
||||
QueryDeviceListByUserIds(ctx context.Context, userIds []int64) ([]*Device, int64, error)
|
||||
QueryDevicePageList(ctx context.Context, userid, subscribeId int64, page, size int) ([]*Device, int64, error)
|
||||
UpdateDevice(ctx context.Context, data *Device, tx ...*gorm.DB) error
|
||||
FindOneDeviceByIdentifier(ctx context.Context, id string) (*Device, error)
|
||||
@@ -110,6 +111,13 @@ type customUserLogicModel interface {
|
||||
|
||||
QueryDailyUserStatisticsList(ctx context.Context, date time.Time) ([]UserStatisticsWithDate, error)
|
||||
QueryMonthlyUserStatisticsList(ctx context.Context, date time.Time) ([]UserStatisticsWithDate, error)
|
||||
FindActiveSubscribe(ctx context.Context, userId int64) (*Subscribe, error)
|
||||
FindActiveSubscribesByUserIds(ctx context.Context, userIds []int64) (map[int64]*UserStatusInfo, error)
|
||||
}
|
||||
|
||||
type UserStatusInfo struct {
|
||||
MemberStatus string
|
||||
LastTrafficAt *time.Time
|
||||
}
|
||||
|
||||
type UserStatisticsWithDate struct {
|
||||
@@ -334,3 +342,17 @@ func (m *customUserModel) QueryMonthlyUserStatisticsList(ctx context.Context, da
|
||||
|
||||
return results, err
|
||||
}
|
||||
|
||||
// FindActiveSubscribe finds the active subscription for a user
|
||||
func (m *customUserModel) FindActiveSubscribe(ctx context.Context, userId int64) (*Subscribe, error) {
|
||||
var subscribe Subscribe
|
||||
err := m.QueryNoCacheCtx(ctx, &subscribe, func(conn *gorm.DB, v interface{}) error {
|
||||
return conn.Where("user_id = ? AND status IN (0, 1) AND expire_time > ?", userId, time.Now()).
|
||||
Order("expire_time DESC").
|
||||
First(v).Error
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &subscribe, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user