repository

package
v0.0.0-...-272f778 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(cfg *config.Config) *gorm.DB

func NewRedis

func NewRedis(conf *viper.Viper) *redis.Client

Types

type ApiKeyRepository

type ApiKeyRepository interface {
	InsertOne(ctx context.Context, apiKey *model.ApiKey) error
	DeleteOne(ctx context.Context, id uint64) error
	DeleteKey(ctx context.Context, key string) error
	DeleteKeyByUserId(ctx context.Context, userId uint64) error
	IsExist(ctx context.Context, apiKey string) (bool, error)
	QueryItemByApiKey(ctx context.Context, apiKey string) (*model.ApiKey, error)
	GetUserApiKey(ctx context.Context, userId uint64) (*model.ApiKey, error)
}

func NewApiKeyRepository

func NewApiKeyRepository(r *Repository) ApiKeyRepository

type ChannelModelRepository

type ChannelModelRepository interface {
	CreateChannelModel(ctx context.Context, channelModel *model.ChannelModel) error
	CreateChannelModelBatch(ctx context.Context, channelModels []*model.ChannelModel) error
	CreateChannelModelIfNotExists(ctx context.Context, channel *model.ChannelModel) error
	ExistsChannelModel(ctx context.Context, channelModel *model.ChannelModel) (*model.ChannelModel, error)

	FindChannelModelById(ctx context.Context, id uint64) (*model.ChannelModel, error)
	FindChannelModelByIdForUpdate(ctx context.Context, id uint64) (*model.ChannelModel, error)
	FindChannelModelByIdForShare(ctx context.Context, id uint64) (*model.ChannelModel, error)
	FindUsefulChannelModels(ctx context.Context, modelIds []string) ([]*model.ChannelModel, error)
	FindCheckChannelModels(ctx context.Context, modelIds []string) ([]*model.ChannelModel, error)
	FindAllChannelModels(ctx context.Context) ([]*model.ChannelModel, error)
	FindAllChannelModelIds(ctx context.Context) ([]string, error)

	InCrChannelModelWeight(ctx context.Context, id uint64) error
	DecrChannelModelWeight(ctx context.Context, id uint64) error
	RestoreChannelModel(ctx context.Context) error
	UpdateChannelModel(ctx context.Context, channelModel *model.ChannelModel) error
	ResetChannelModels(ctx context.Context, channelId uint64, channelModels []*model.ChannelModel) error
	UpdateChannelModelsHardStatus(ctx context.Context, channelId uint64, status int8) error

	DeleteChannelModelByID(ctx context.Context, id uint64) error
	DeleteChannelModelByChannelId(ctx context.Context, channelId uint64) error
	PermanentlyDeleteChannelModel(ctx context.Context, channelModel *model.ChannelModel) error
}

func NewChannelModelRepository

func NewChannelModelRepository(repo *Repository) ChannelModelRepository

type ChannelRepository

type ChannelRepository interface {
	CreateChannel(ctx context.Context, channel *model.Channel) error
	CreateChannelBatch(ctx context.Context, channels []*model.Channel) error
	CreateChannelIfNotExists(ctx context.Context, channel *model.Channel) error
	FindChannelById(ctx context.Context, id uint64) (*model.Channel, error)
	FindChannelByIdForUpdate(ctx context.Context, id uint64) (*model.Channel, error)
	FindChannelByIdForShare(ctx context.Context, id uint64) (*model.Channel, error)
	FindAllChannels(ctx context.Context) ([]*model.Channel, error)
	FindAllChannelsByCondition(ctx context.Context, req *query.ChannelQueryRequest) ([]*model.Channel, int64, error)
	ExistsChannel(ctx context.Context, channel *model.Channel) (bool, error)
	UpdateChannel(ctx context.Context, channel *model.Channel) error
	DeleteChannelByID(ctx context.Context, id uint64) error
	PermanentlyDeleteChannel(ctx context.Context, channel *model.Channel) error
}

func NewChannelRepository

func NewChannelRepository(repo *Repository) ChannelRepository

type QueryOption

type QueryOption func(*gorm.DB) *gorm.DB

func WithChannelId

func WithChannelId(id uint64) QueryOption

func WithChannelIds

func WithChannelIds(ids []uint64) QueryOption

func WithChannelName

func WithChannelName(name string) QueryOption

func WithChannelStatus

func WithChannelStatus(status string) QueryOption

func WithChannelStatuses

func WithChannelStatuses(statuses []string) QueryOption

func WithHashId

func WithHashId(hashId string) QueryOption

func WithPage

func WithPage(page, pageSize int) QueryOption

type Repository

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

func NewRepository

func NewRepository(
	logger *log.Logger,
	db *gorm.DB,

) *Repository

func (*Repository) DB

func (r *Repository) DB(ctx context.Context) *gorm.DB

DB 会返回一个新的DB,如果ctx中存在事务,则返回事务的DB,事务链 If you need to create a Transaction, you must call DB(ctx) and Transaction(ctx,fn)

func (*Repository) Transaction

func (r *Repository) Transaction(ctx context.Context, fn func(ctx context.Context) error) error

type RequestLogRepository

type RequestLogRepository interface {
	CreateRequestLog(ctx context.Context, log *model.RequestLog) error
	FindRequestLogs(ctx context.Context, req *apiV1.RequestLogsQuery) ([]*model.RequestLog, int64, error)
	FindRequestLogsModelRanking(ctx context.Context, req *apiV1.RequestLogsRankingRequest) ([]*apiV1.RequestLogsModelRanking, error)
	FindRequestLogsUserRanking(ctx context.Context, req *apiV1.RequestLogsRankingRequest) ([]*apiV1.RequestLogsUserRanking, error)
}

func NewRequestLogRepository

func NewRequestLogRepository(repo *Repository) RequestLogRepository

type RequestLogStatisticsQuery

type RequestLogStatisticsQuery struct {
	StartTime string
	EndTime   string
}

type SystemRepository

type SystemRepository interface {
	SetEmailConfig(ctx context.Context, cfg *dto.EmailConfig) error
	GetEmailConfig(ctx context.Context) (*dto.EmailConfig, error)
	IsEmailServiceAvailable(ctx context.Context) (bool, error)
	SetLinuxDoOAuthConfig(ctx context.Context, cfg *dto.LinuxDoOAuthConfig) error
	GetLinuxDoOAuthConfig(ctx context.Context) (*dto.LinuxDoOAuthConfig, error)
	IsLinuxDoOAuthAvailable(ctx context.Context) (bool, error)
	SetGithubOAuthConfig(ctx context.Context, cfg *dto.GithubOAuthConfig) error
	GetGithubOAuthConfig(ctx context.Context) (*dto.GithubOAuthConfig, error)
	IsGithubOAuthAvailable(ctx context.Context) (bool, error)
	SetModelConfig(ctx context.Context, cfg *dto.ModelConfig) error
	GetModelConfig(ctx context.Context) (*dto.ModelConfig, error)
	SetRegisterConfig(ctx context.Context, cfg *dto.RegisterConfig) error
	GetRegisterConfig(ctx context.Context) (*dto.RegisterConfig, error)
}

func NewSystemRepository

func NewSystemRepository(r *Repository) SystemRepository

type Transaction

type Transaction interface {
	Transaction(ctx context.Context, fn func(ctx context.Context) error) error
}

func NewTransaction

func NewTransaction(r *Repository) Transaction

type UserAuthProviderRepository

type UserAuthProviderRepository interface {
	CreateUserAuthProvider(ctx context.Context, p *model.UserAuthProvider) error
	FindUserAuthProvider(ctx context.Context, provider, providerUserId string) (*model.UserAuthProvider, error)
	UpdateUserAuthProviderById(ctx context.Context, p *model.UserAuthProvider) error
}

func NewUserAuthProviderRepository

func NewUserAuthProviderRepository(r *Repository) UserAuthProviderRepository

type UserCallCount

type UserCallCount struct {
	UserId    uint64 `json:"userId"`
	Username  string `json:"username"`
	Email     string `json:"email"`
	CallCount int    `json:"callCount"`
}

type UserRepository

type UserRepository interface {
	CreateUser(ctx context.Context, user *model.User) error
	FindUserByEmail(ctx context.Context, email string) (*model.User, error)
	FindUserByUsername(ctx context.Context, username string) (*model.User, error)
	FindUserById(ctx context.Context, id uint64) (*model.User, error)
	FindOneForUpdate(ctx context.Context, id uint64) (*model.User, error)
	UpdateOne(ctx context.Context, user *model.User) error
}

func NewUserRepository

func NewUserRepository(repo *Repository) UserRepository

Jump to

Keyboard shortcuts

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