repository

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAmbiguousEmailIdentity = errors.New("ambiguous email identity")
View Source
var ErrInvalidEmailIdentity = errors.New("invalid email identity")

Functions

This section is empty.

Types

type AdsRepo added in v1.3.9

type AdsRepo interface {
	Insert(ctx context.Context, data *ads.Ads) error
	FindOne(ctx context.Context, id int64) (*ads.Ads, error)
	Update(ctx context.Context, data *ads.Ads) error
	Delete(ctx context.Context, id int64) error
	GetAdsListByPage(ctx context.Context, page, size int, filter ads.Filter) (int64, []*ads.Ads, error)
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
}

AdsRepo ads 数据访问接口

type AnnouncementRepo added in v1.3.9

type AnnouncementRepo interface {
	Insert(ctx context.Context, data *announcement.Announcement) error
	FindOne(ctx context.Context, id int64) (*announcement.Announcement, error)
	Update(ctx context.Context, data *announcement.Announcement) error
	Delete(ctx context.Context, id int64) error
	GetAnnouncementListByPage(ctx context.Context, page, size int, filter announcement.Filter) (int64, []*announcement.Announcement, error)
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
}

AnnouncementRepo announcement 数据访问接口

type AuthRepo added in v1.3.9

type AuthRepo interface {
	Insert(ctx context.Context, data *auth.Auth) error
	FindOne(ctx context.Context, id int64) (*auth.Auth, error)
	Update(ctx context.Context, data *auth.Auth) error
	Delete(ctx context.Context, id int64) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	GetAuthListByPage(ctx context.Context) ([]*auth.Auth, error)
	FindOneByMethod(ctx context.Context, platform string) (*auth.Auth, error)
	FindAll(ctx context.Context) ([]*auth.Auth, error)
}

AuthRepo auth 数据访问接口

type ClientRepo added in v1.3.9

type ClientRepo interface {
	Insert(ctx context.Context, data *client.SubscribeApplication) error
	FindOne(ctx context.Context, id int64) (*client.SubscribeApplication, error)
	Update(ctx context.Context, data *client.SubscribeApplication) error
	Delete(ctx context.Context, id int64) error
	List(ctx context.Context) ([]*client.SubscribeApplication, error)
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
}

ClientRepo subscribe application 数据访问接口

type CouponRepo added in v1.3.9

type CouponRepo interface {
	Insert(ctx context.Context, data *coupon.Coupon) error
	FindOne(ctx context.Context, id int64) (*coupon.Coupon, error)
	FindOneByCode(ctx context.Context, code string) (*coupon.Coupon, error)
	Update(ctx context.Context, data *coupon.Coupon) error
	Delete(ctx context.Context, id int64) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	UpdateCount(ctx context.Context, code string) error
	QueryCouponListByPage(ctx context.Context, page, size int, subscribe int64, search string) (total int64, list []*coupon.Coupon, err error)
	BatchDelete(ctx context.Context, ids []int64) error
}

CouponRepo coupon 数据访问接口

type DocumentRepo added in v1.3.9

type DocumentRepo interface {
	Insert(ctx context.Context, data *document.Document) error
	FindOne(ctx context.Context, id int64) (*document.Document, error)
	Update(ctx context.Context, data *document.Document) error
	Delete(ctx context.Context, id int64) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	QueryDocumentDetail(ctx context.Context, id int64) (*document.Document, error)
	QueryDocumentList(ctx context.Context, page, size int, tag string, search string) (int64, []*document.Document, error)
	GetDocumentListByAll(ctx context.Context) (int64, []*document.Document, error)
}

DocumentRepo document 数据访问接口

type GormStore

type GormStore struct {
	// contains filtered or unexported fields
}

GormStore is the Store implementation backed by GORM + Redis.

func NewGormStore

func NewGormStore(db *gorm.DB, rds *redis.Client) *GormStore

NewGormStore creates a new GormStore with all domain repositories initialized.

func (*GormStore) Ads

func (s *GormStore) Ads() AdsRepo

func (*GormStore) Announcement

func (s *GormStore) Announcement() AnnouncementRepo

func (*GormStore) Auth

func (s *GormStore) Auth() AuthRepo

func (*GormStore) Client

func (s *GormStore) Client() ClientRepo

func (*GormStore) Coupon

func (s *GormStore) Coupon() CouponRepo

func (*GormStore) DB added in v1.3.7

func (s *GormStore) DB() *gorm.DB

DB returns the underlying *gorm.DB (used internally by plugins etc.).

func (*GormStore) Document

func (s *GormStore) Document() DocumentRepo

func (*GormStore) InTx

func (s *GormStore) InTx(ctx context.Context, fn func(store Store) error) error

InTx runs fn within a database transaction. A new GormStore backed by the transaction is passed to fn, so all repository operations inside fn share the same transaction.

func (*GormStore) Log

func (s *GormStore) Log() LogRepo

func (*GormStore) Node

func (s *GormStore) Node() NodeRepo

func (*GormStore) Order

func (s *GormStore) Order() OrderRepo

func (*GormStore) Payment

func (s *GormStore) Payment() PaymentRepo

func (*GormStore) Subscribe

func (s *GormStore) Subscribe() SubscribeRepo

func (*GormStore) System

func (s *GormStore) System() SystemRepo

func (*GormStore) Task

func (s *GormStore) Task() TaskRepo

func (*GormStore) Ticket

func (s *GormStore) Ticket() TicketRepo

func (*GormStore) TrafficLog

func (s *GormStore) TrafficLog() TrafficRepo

func (*GormStore) User

func (s *GormStore) User() UserRepo

type LogRepo added in v1.3.9

type LogRepo interface {
	Insert(ctx context.Context, data *log.SystemLog) error
	FindOne(ctx context.Context, id int64) (*log.SystemLog, error)
	Update(ctx context.Context, data *log.SystemLog) error
	Delete(ctx context.Context, id int64) error
	FilterSystemLog(ctx context.Context, filter *log.FilterParams) ([]*log.SystemLog, int64, error)
	FindFirstByDateType(ctx context.Context, date string, typ uint8) (*log.SystemLog, error)
	FindByDatesType(ctx context.Context, dates []string, typ uint8) ([]*log.SystemLog, error)
	DeleteBefore(ctx context.Context, end time.Time) error
	SumAmountByTypeAndObjectID(ctx context.Context, typ uint8, objectID int64) (int64, error)
}

LogRepo log 数据访问接口

type NodeRepo added in v1.3.9

type NodeRepo interface {
	// server
	InsertServer(ctx context.Context, data *node.Server, tx ...*gorm.DB) error
	FindOneServer(ctx context.Context, id int64) (*node.Server, error)
	UpdateServer(ctx context.Context, data *node.Server, tx ...*gorm.DB) error
	BatchUpdateServerLastReportedAt(ctx context.Context, reports map[int64]time.Time, tx ...*gorm.DB) error
	DeleteServer(ctx context.Context, id int64, tx ...*gorm.DB) error
	FindServerConfigOverride(ctx context.Context, serverId int64) (*node.ServerConfigOverride, error)
	SaveServerConfigOverride(ctx context.Context, data *node.ServerConfigOverride, tx ...*gorm.DB) error
	DeleteServerConfigOverride(ctx context.Context, serverId int64, tx ...*gorm.DB) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	QueryServerList(ctx context.Context, ids []int64) (servers []*node.Server, err error)
	// node
	InsertNode(ctx context.Context, data *node.Node, tx ...*gorm.DB) error
	FindOneNode(ctx context.Context, id int64) (*node.Node, error)
	UpdateNode(ctx context.Context, data *node.Node, tx ...*gorm.DB) error
	DeleteNode(ctx context.Context, id int64, tx ...*gorm.DB) error
	// cache
	StatusCache(ctx context.Context, serverId int64) (node.Status, error)
	UpdateStatusCache(ctx context.Context, serverId int64, status *node.Status) error
	OnlineUserSubscribe(ctx context.Context, serverId int64, protocol string) (node.OnlineUserSubscribe, error)
	UpdateOnlineUserSubscribe(ctx context.Context, serverId int64, protocol string, subscribe node.OnlineUserSubscribe) error
	OnlineUserSubscribeGlobal(ctx context.Context) (int64, error)
	UpdateOnlineUserSubscribeGlobal(ctx context.Context, subscribe node.OnlineUserSubscribe) error
	// query
	FilterServerList(ctx context.Context, params *node.FilterParams) (int64, []*node.Server, error)
	FilterNodeList(ctx context.Context, params *node.FilterNodeParams) (int64, []*node.Node, error)
	QueryNodeSorts(ctx context.Context) ([]node.SortItem, error)
	QueryServerSorts(ctx context.Context) ([]node.SortItem, error)
	UpdateNodeSort(ctx context.Context, id int64, sort int64) error
	UpdateServerSort(ctx context.Context, id int64, sort int64) error
	QueryNodeTags(ctx context.Context) ([]string, error)
	CountEnabledNodes(ctx context.Context) (int64, error)
	CountServersByReportStatus(ctx context.Context, cutoff time.Time) (int64, int64, error)
	QueryServerAddresses(ctx context.Context) ([]string, error)
	QueryEnabledNodeProtocols(ctx context.Context) ([]string, error)
	ClearNodeCache(ctx context.Context, params *node.FilterNodeParams) error
}

NodeRepo node/server 数据访问接口

type OrderRepo added in v1.3.9

type OrderRepo interface {
	Insert(ctx context.Context, data *order.Order, tx ...*gorm.DB) error
	FindOne(ctx context.Context, id int64) (*order.Order, error)
	FindOneByOrderNo(ctx context.Context, orderNo string) (*order.Order, error)
	Update(ctx context.Context, data *order.Order, tx ...*gorm.DB) error
	Delete(ctx context.Context, id int64, tx ...*gorm.DB) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	UpdateOrderStatus(ctx context.Context, orderNo string, status uint8, tx ...*gorm.DB) error
	UpdatePaymentExpectation(ctx context.Context, orderNo string, amount int64, currency string, tx ...*gorm.DB) (bool, error)
	MarkOrderPaid(ctx context.Context, orderNo, tradeNo string, tx ...*gorm.DB) (bool, error)
	QueryOrdersByStatusAfterID(ctx context.Context, status uint8, afterID int64, limit int) ([]*order.Order, error)
	CountUserCouponUsage(ctx context.Context, userID int64, coupon string) (int64, error)
	QueryOrderListByPage(ctx context.Context, page, size int, status uint8, user, subscribe int64, search string) (int64, []*order.Details, error)
	FindOneDetails(ctx context.Context, id int64) (*order.Details, error)
	FindOneDetailsByOrderNo(ctx context.Context, orderNo string) (*order.Details, error)
	QueryMonthlyOrders(ctx context.Context, date time.Time) (order.OrdersTotal, error)
	QueryDateOrders(ctx context.Context, date time.Time) (order.OrdersTotal, error)
	QueryTotalOrders(ctx context.Context) (order.OrdersTotal, error)
	QueryMonthlyUserCounts(ctx context.Context, date time.Time) (int64, int64, error)
	QueryDateUserCounts(ctx context.Context, date time.Time) (int64, int64, error)
	QueryTotalUserCounts(ctx context.Context) (int64, int64, error)
	IsUserEligibleForNewOrder(ctx context.Context, userID int64) (bool, error)
	QueryDailyOrdersList(ctx context.Context, date time.Time) ([]order.OrdersTotalWithDate, error)
	QueryMonthlyOrdersList(ctx context.Context, date time.Time) ([]order.OrdersTotalWithDate, error)
}

OrderRepo order 数据访问接口

type PaymentRepo added in v1.3.9

type PaymentRepo interface {
	Insert(ctx context.Context, data *payment.Payment, tx ...*gorm.DB) error
	FindOne(ctx context.Context, id int64) (*payment.Payment, error)
	Update(ctx context.Context, data *payment.Payment, tx ...*gorm.DB) error
	Delete(ctx context.Context, id int64, tx ...*gorm.DB) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	FindOneByPaymentToken(ctx context.Context, token string) (*payment.Payment, error)
	FindAll(ctx context.Context) ([]*payment.Payment, error)
	FindListByPage(ctx context.Context, page, size int, req *payment.Filter) (int64, []*payment.Payment, error)
	FindAvailableMethods(ctx context.Context) ([]*payment.Payment, error)
}

PaymentRepo payment 数据访问接口

type Store

type Store interface {
	Ads() AdsRepo
	Announcement() AnnouncementRepo
	Auth() AuthRepo
	Client() ClientRepo
	Coupon() CouponRepo
	Document() DocumentRepo
	Log() LogRepo
	Node() NodeRepo
	Order() OrderRepo
	Payment() PaymentRepo
	Subscribe() SubscribeRepo
	System() SystemRepo
	Task() TaskRepo
	Ticket() TicketRepo
	TrafficLog() TrafficRepo
	User() UserRepo

	// DB returns the underlying *gorm.DB, used internally by plugins etc.
	DB() *gorm.DB

	InTx(ctx context.Context, fn func(store Store) error) error
}

Store is the central data access facade, providing access to all domain repositories and transaction support.

type SubscribeRepo added in v1.3.9

type SubscribeRepo interface {
	Insert(ctx context.Context, data *subscribe.Subscribe, tx ...*gorm.DB) error
	FindOne(ctx context.Context, id int64) (*subscribe.Subscribe, error)
	Update(ctx context.Context, data *subscribe.Subscribe, tx ...*gorm.DB) error
	Delete(ctx context.Context, id int64, tx ...*gorm.DB) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	FilterList(ctx context.Context, params *subscribe.FilterParams) (int64, []*subscribe.Subscribe, error)
	ClearCache(ctx context.Context, id ...int64) error
	QuerySubscribeMinSortByIds(ctx context.Context, ids []int64) (int64, error)
	QueryResetCycleSubscribeIds(ctx context.Context, resetCycle int) ([]int64, error)
	UpdateSort(ctx context.Context, data []*subscribe.Subscribe) error
	QueryGroupList(ctx context.Context) (int64, []*subscribe.Group, error)
	CreateGroup(ctx context.Context, data *subscribe.Group) error
	UpdateGroup(ctx context.Context, data *subscribe.Group) error
	DeleteGroup(ctx context.Context, id int64) error
	BatchDeleteGroup(ctx context.Context, ids []int64) error
}

SubscribeRepo subscribe 数据访问接口

type SystemRepo added in v1.3.9

type SystemRepo interface {
	Insert(ctx context.Context, data *system.System) error
	FindOne(ctx context.Context, id int64) (*system.System, error)
	FindOneByKey(ctx context.Context, email string) (*system.System, error)
	Update(ctx context.Context, data *system.System) error
	Delete(ctx context.Context, id int64) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	GetSmsConfig(ctx context.Context) ([]*system.System, error)
	GetSiteConfig(ctx context.Context) ([]*system.System, error)
	GetEmailConfig(ctx context.Context) ([]*system.System, error)
	GetSubscribeConfig(ctx context.Context) ([]*system.System, error)
	GetRegisterConfig(ctx context.Context) ([]*system.System, error)
	GetVerifyConfig(ctx context.Context) ([]*system.System, error)
	GetNodeConfig(ctx context.Context) ([]*system.System, error)
	GetInviteConfig(ctx context.Context) ([]*system.System, error)
	GetTelegramConfig(ctx context.Context) ([]*system.System, error)
	GetTosConfig(ctx context.Context) ([]*system.System, error)
	GetCurrencyConfig(ctx context.Context) ([]*system.System, error)
	GetVerifyCodeConfig(ctx context.Context) ([]*system.System, error)
	GetLogConfig(ctx context.Context) ([]*system.System, error)
	UpdateValueByCategoryKey(ctx context.Context, category, key, value string) error
	UpdateNodeMultiplierConfig(ctx context.Context, config string) error
	FindNodeMultiplierConfig(ctx context.Context) (*system.System, error)
}

SystemRepo system 数据访问接口

type TaskRepo added in v1.3.9

type TaskRepo interface {
	Insert(ctx context.Context, data *task.Task) error
	FindOne(ctx context.Context, id int64) (*task.Task, error)
	FindOneByType(ctx context.Context, id int64, typ task.Type) (*task.Task, error)
	QueryTaskList(ctx context.Context, filter *task.Filter) (int64, []*task.Task, error)
	Update(ctx context.Context, data *task.Task) error
	UpdateStatus(ctx context.Context, id int64, status int8) error
}

TaskRepo task 数据访问接口

type TicketRepo added in v1.3.9

type TicketRepo interface {
	Insert(ctx context.Context, data *ticket.Ticket) error
	FindOne(ctx context.Context, id int64) (*ticket.Ticket, error)
	Update(ctx context.Context, data *ticket.Ticket) error
	Delete(ctx context.Context, id int64) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	QueryTicketDetail(ctx context.Context, id int64) (*ticket.Details, error)
	InsertTicketFollow(ctx context.Context, data *ticket.Follow) error
	QueryTicketList(ctx context.Context, page, size int, userId int64, status *uint8, search string) (int64, []*ticket.Ticket, error)
	UpdateTicketStatus(ctx context.Context, id, userId int64, status uint8) error
	QueryWaitReplyTotal(ctx context.Context) (int64, error)
}

TicketRepo ticket 数据访问接口

type TrafficRepo added in v1.3.9

type TrafficRepo interface {
	Insert(ctx context.Context, data *traffic.TrafficLog) error
	InsertBatch(ctx context.Context, data []*traffic.TrafficLog, batchSize int, tx ...*gorm.DB) error
	FindOne(ctx context.Context, id int64) (*traffic.TrafficLog, error)
	Update(ctx context.Context, data *traffic.TrafficLog) error
	Delete(ctx context.Context, id int64) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	QueryServerTrafficByDay(ctx context.Context, serverId int64, date time.Time) (*traffic.TotalTraffic, error)
	QueryTrafficByDay(ctx context.Context, date time.Time) (*traffic.TotalTraffic, error)
	QueryTrafficByMonthly(ctx context.Context, date time.Time) (*traffic.TotalTraffic, error)
	QueryTrafficSummary(ctx context.Context, start, end time.Time) (*traffic.TotalTraffic, error)
	TopServersTrafficByDay(ctx context.Context, date time.Time, limit int) ([]traffic.ServerTrafficRanking, error)
	TopServersTrafficByMonthly(ctx context.Context, date time.Time, limit int) ([]traffic.ServerTrafficRanking, error)
	TopUsersTrafficByDay(ctx context.Context, date time.Time, limit int) ([]traffic.UserTrafficRanking, error)
	TopUsersTrafficByMonthly(ctx context.Context, date time.Time, limit int) ([]traffic.UserTrafficRanking, error)
	QueryServerTrafficRanking(ctx context.Context, start, end time.Time) ([]traffic.ServerTrafficRanking, error)
	QueryUserTrafficRanking(ctx context.Context, start, end time.Time) ([]traffic.UserTrafficRanking, error)
	QueryTrafficLogPageList(ctx context.Context, userId, subscribeId int64, page, size int) ([]*traffic.TrafficLog, int64, error)
	QueryTrafficLogDetails(ctx context.Context, filter *traffic.TrafficLogDetailsFilter) ([]*traffic.TrafficLog, int64, error)
	DeleteBefore(ctx context.Context, end time.Time) error
}

TrafficRepo traffic 数据访问接口

type UserRepo added in v1.3.9

type UserRepo interface {
	// user
	Insert(ctx context.Context, data *user.User, tx ...*gorm.DB) error
	FindOne(ctx context.Context, id int64) (*user.User, error)
	FindOneByEmail(ctx context.Context, email string) (*user.User, error)
	FindOneByReferCode(ctx context.Context, referCode string) (*user.User, error)
	Update(ctx context.Context, data *user.User, tx ...*gorm.DB) error
	Delete(ctx context.Context, id int64, tx ...*gorm.DB) error
	Transaction(ctx context.Context, fn func(db *gorm.DB) error) error
	BatchDeleteUser(ctx context.Context, ids []int64, tx ...*gorm.DB) error
	QueryPageList(ctx context.Context, page, size int, filter *user.UserFilterParams) ([]*user.User, int64, error)
	FindUsersByIds(ctx context.Context, ids []int64) ([]*user.User, error)
	CountAffiliates(ctx context.Context, refererId int64) (int64, error)
	QueryAffiliateList(ctx context.Context, refererId int64, page, size int) ([]*user.User, int64, error)
	QueryAdminUsers(ctx context.Context) ([]*user.User, error)
	CountEnabledUsers(ctx context.Context) (int64, error)
	QueryResisterUserTotal(ctx context.Context) (int64, error)
	QueryResisterUserTotalByDate(ctx context.Context, date time.Time) (int64, error)
	QueryResisterUserTotalByMonthly(ctx context.Context, date time.Time) (int64, error)
	QueryEmailRecipients(ctx context.Context, filter *user.EmailRecipientFilter) ([]string, error)
	CountEmailRecipients(ctx context.Context, filter *user.EmailRecipientFilter) (int64, error)
	QueryDailyUserStatisticsList(ctx context.Context, date time.Time) ([]user.UserStatisticsWithDate, error)
	QueryMonthlyUserStatisticsList(ctx context.Context, date time.Time) ([]user.UserStatisticsWithDate, error)

	// auth methods
	FindUserAuthMethods(ctx context.Context, userId int64) ([]*user.AuthMethods, error)
	FindUserAuthMethodByOpenID(ctx context.Context, method, openID string) (*user.AuthMethods, error)
	ValidateEmailIdentityUniqueness(ctx context.Context) error
	FindUserAuthMethodByPlatform(ctx context.Context, userId int64, platform string) (*user.AuthMethods, error)
	FindUserAuthMethodByUserId(ctx context.Context, method string, userId int64) (*user.AuthMethods, error)
	InsertUserAuthMethods(ctx context.Context, data *user.AuthMethods, tx ...*gorm.DB) error
	UpdateUserAuthMethods(ctx context.Context, data *user.AuthMethods, tx ...*gorm.DB) error
	DeleteUserAuthMethods(ctx context.Context, userId int64, platform string, tx ...*gorm.DB) error
	UpdateUserAuthMethodOwner(ctx context.Context, authType, identifier string, userId int64, tx ...*gorm.DB) error
	DeleteUserAuthMethodByIdentifier(ctx context.Context, authType, identifier string, tx ...*gorm.DB) error
	UpsertUserAuthMethod(ctx context.Context, data *user.AuthMethods) error

	// subscribe
	InsertSubscribe(ctx context.Context, data *user.Subscribe, tx ...*gorm.DB) error
	FindOneSubscribe(ctx context.Context, id int64) (*user.Subscribe, error)
	FindOneSubscribeByOrderId(ctx context.Context, orderId int64) (*user.Subscribe, error)
	FindOneSubscribeByToken(ctx context.Context, token string) (*user.Subscribe, error)
	UpdateSubscribe(ctx context.Context, data *user.Subscribe, tx ...*gorm.DB) error
	DeleteSubscribe(ctx context.Context, token string, tx ...*gorm.DB) error
	DeleteSubscribeById(ctx context.Context, id int64, tx ...*gorm.DB) error
	UpdateUserSubscribeWithTraffic(ctx context.Context, id, download, upload int64, tx ...*gorm.DB) error
	BatchUpdateUserSubscribeWithTraffic(ctx context.Context, deltas []trafficEntity.SubscribeTrafficDelta, tx ...*gorm.DB) error
	FindUsersSubscribeBySubscribeId(ctx context.Context, subscribeId int64) ([]*user.Subscribe, error)
	FindUserSubscribesByStatus(ctx context.Context, status ...int64) ([]*user.Subscribe, error)
	FindSubscribesByIds(ctx context.Context, ids []int64) ([]*user.Subscribe, error)
	ActivatePendingSubscribesBySubscribeId(ctx context.Context, subscribeId int64) error
	CountUserSubscribesByUserAndSubscribe(ctx context.Context, userId, subscribeId int64) (int64, error)
	CountUserSubscribesBySubscribeIdAndStatus(ctx context.Context, subscribeId int64, status ...int64) (int64, error)
	QueryActiveSubscriptions(ctx context.Context, subscribeId ...int64) (map[int64]int64, error)
	QueryUserSubscribe(ctx context.Context, userId int64, status ...int64) ([]*user.SubscribeDetails, error)
	FindOneSubscribeDetailsById(ctx context.Context, id int64) (*user.SubscribeDetails, error)
	FindOneUserSubscribe(ctx context.Context, id int64) (*user.SubscribeDetails, error)
	FindTrafficExceededSubscribes(ctx context.Context) ([]*user.Subscribe, error)
	FindExpiredSubscribes(ctx context.Context, now time.Time) ([]*user.Subscribe, error)
	MarkSubscribesFinished(ctx context.Context, ids []int64, status uint8, finishedAt time.Time, tx ...*gorm.DB) error
	QuerySubscribeIdsByFilter(ctx context.Context, filter *user.SubscribeFilter) ([]int64, error)
	CountSubscribesByFilter(ctx context.Context, filter *user.SubscribeFilter) (int64, error)

	// device
	InsertDevice(ctx context.Context, data *user.Device, tx ...*gorm.DB) error
	FindOneDevice(ctx context.Context, id int64) (*user.Device, error)
	FindOneDeviceByIdentifier(ctx context.Context, id string) (*user.Device, error)
	UpdateDevice(ctx context.Context, data *user.Device, tx ...*gorm.DB) error
	DeleteDevice(ctx context.Context, id int64, tx ...*gorm.DB) error
	QueryDeviceList(ctx context.Context, userid int64) ([]*user.Device, int64, error)
	QueryDevicePageList(ctx context.Context, userid, subscribeId int64, page, size int) ([]*user.Device, int64, error)
	FindDeviceOnlineRecord(ctx context.Context, userId int64, startTime, endTime string) (*user.DeviceOnlineRecord, error)
	InsertDeviceOnlineRecord(ctx context.Context, data *user.DeviceOnlineRecord, tx ...*gorm.DB) error

	// withdrawal
	InsertWithdrawal(ctx context.Context, data *user.Withdrawal, tx ...*gorm.DB) error

	// reset traffic
	QueryMonthlyResetSubscribeIds(ctx context.Context, subscribeIds []int64, now time.Time) ([]int64, error)
	QueryFirstResetSubscribeIds(ctx context.Context, subscribeIds []int64, now time.Time) ([]int64, error)
	QueryYearlyResetSubscribeIds(ctx context.Context, subscribeIds []int64, now time.Time) ([]int64, error)
	ResetSubscribeTrafficByIds(ctx context.Context, ids []int64, tx ...*gorm.DB) error

	// cache
	ClearUserCache(ctx context.Context, data ...*user.User) error
	ClearSubscribeCache(ctx context.Context, data ...*user.Subscribe) error
	ClearDeviceCache(ctx context.Context, data ...*user.Device) error
	ClearAuthMethodCache(ctx context.Context, data ...*user.AuthMethods) error
	BatchClearRelatedCache(ctx context.Context, data *user.User) error
	UpdateUserCache(ctx context.Context, data *user.User) error
	UpdateUserSubscribeCache(ctx context.Context, data *user.Subscribe) error
}

UserRepo user 数据访问接口

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL