services

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Accounts = &AccountService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a account service singleton instance

View Source
var (
	ForgetPasswords = &ForgetPasswordService{
		ServiceUsingConfig: ServiceUsingConfig{
			container: settings.Container,
		},
		ServiceUsingMailer: ServiceUsingMailer{
			container: mail.Container,
		},
	}
)

Initialize a forget password service singleton instance

View Source
var (
	Tokens = &TokenService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingConfig: ServiceUsingConfig{
			container: settings.Container,
		},
	}
)

Initialize a user token service singleton instance

View Source
var (
	TransactionCategories = &TransactionCategoryService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a transaction category service singleton instance

View Source
var (
	TransactionPictures = &TransactionPictureService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
		ServiceUsingStorage: ServiceUsingStorage{
			container: storage.Container,
		},
	}
)

Initialize a transaction picture service singleton instance

View Source
var (
	TransactionTags = &TransactionTagService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a transaction tag service singleton instance

View Source
var (
	TransactionTemplates = &TransactionTemplateService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a transaction template service singleton instance

View Source
var (
	Transactions = &TransactionService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a transaction service singleton instance

View Source
var (
	TwoFactorAuthorizations = &TwoFactorAuthorizationService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingConfig: ServiceUsingConfig{
			container: settings.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
	}
)

Initialize a 2fa service singleton instance

View Source
var (
	Users = &UserService{
		ServiceUsingDB: ServiceUsingDB{
			container: datastore.Container,
		},
		ServiceUsingConfig: ServiceUsingConfig{
			container: settings.Container,
		},
		ServiceUsingMailer: ServiceUsingMailer{
			container: mail.Container,
		},
		ServiceUsingUuid: ServiceUsingUuid{
			container: uuid.Container,
		},
		ServiceUsingStorage: ServiceUsingStorage{
			container: storage.Container,
		},
	}
)

Initialize a user service singleton instance

Functions

This section is empty.

Types

type AccountService

type AccountService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

AccountService represents account service

func (*AccountService) CreateAccounts

func (s *AccountService) CreateAccounts(c core.Context, mainAccount *models.Account, mainAccountBalanceTime int64, childrenAccounts []*models.Account, childrenAccountBalanceTimes []int64, utcOffset int16) error

CreateAccounts saves a new account model to database

func (*AccountService) DeleteAccount

func (s *AccountService) DeleteAccount(c core.Context, uid int64, accountId int64) error

DeleteAccount deletes an existed account from database

func (*AccountService) GetAccountAndSubAccountsByAccountId

func (s *AccountService) GetAccountAndSubAccountsByAccountId(c core.Context, uid int64, accountId int64) ([]*models.Account, error)

GetAccountAndSubAccountsByAccountId returns account model and sub-account models according to account id

func (*AccountService) GetAccountMapByList

func (s *AccountService) GetAccountMapByList(accounts []*models.Account) map[int64]*models.Account

GetAccountMapByList returns an account map by a list

func (*AccountService) GetAccountNameMapByList added in v0.6.0

func (s *AccountService) GetAccountNameMapByList(accounts []*models.Account) map[string]*models.Account

GetAccountNameMapByList returns an account map by a list

func (*AccountService) GetAccountNames added in v0.6.0

func (s *AccountService) GetAccountNames(accounts []*models.Account) []string

GetAccountNames returns a list with account names from account models list

func (*AccountService) GetAccountsByAccountIds

func (s *AccountService) GetAccountsByAccountIds(c core.Context, uid int64, accountIds []int64) (map[int64]*models.Account, error)

GetAccountsByAccountIds returns account models according to account ids

func (*AccountService) GetAllAccountsByUid

func (s *AccountService) GetAllAccountsByUid(c core.Context, uid int64) ([]*models.Account, error)

GetAllAccountsByUid returns all account models of user

func (*AccountService) GetMaxDisplayOrder

func (s *AccountService) GetMaxDisplayOrder(c core.Context, uid int64, category models.AccountCategory) (int32, error)

GetMaxDisplayOrder returns the max display order according to account category

func (*AccountService) GetMaxSubAccountDisplayOrder

func (s *AccountService) GetMaxSubAccountDisplayOrder(c core.Context, uid int64, category models.AccountCategory, parentAccountId int64) (int32, error)

GetMaxSubAccountDisplayOrder returns the max display order of sub-account according to account category and parent account id

func (*AccountService) GetSubAccountsByAccountId added in v0.2.0

func (s *AccountService) GetSubAccountsByAccountId(c core.Context, uid int64, accountId int64) ([]*models.Account, error)

GetSubAccountsByAccountId returns sub-account models according to account id

func (*AccountService) GetSubAccountsByAccountIds added in v0.5.0

func (s *AccountService) GetSubAccountsByAccountIds(c core.Context, uid int64, accountIds []int64) ([]*models.Account, error)

GetSubAccountsByAccountIds returns sub-account models according to account ids

func (*AccountService) GetTotalAccountCountByUid added in v0.2.0

func (s *AccountService) GetTotalAccountCountByUid(c core.Context, uid int64) (int64, error)

GetTotalAccountCountByUid returns total account count of user

func (*AccountService) HideAccount

func (s *AccountService) HideAccount(c core.Context, uid int64, ids []int64, hidden bool) error

HideAccount updates hidden field of given accounts

func (*AccountService) ModifyAccountDisplayOrders

func (s *AccountService) ModifyAccountDisplayOrders(c core.Context, uid int64, accounts []*models.Account) error

ModifyAccountDisplayOrders updates display order of given accounts

func (*AccountService) ModifyAccounts

func (s *AccountService) ModifyAccounts(c core.Context, uid int64, accounts []*models.Account) error

ModifyAccounts saves an existed account model to database

type ForgetPasswordService added in v0.4.0

type ForgetPasswordService struct {
	ServiceUsingConfig
	ServiceUsingMailer
}

ForgetPasswordService represents forget password service

func (*ForgetPasswordService) SendPasswordResetEmail added in v0.4.0

func (s *ForgetPasswordService) SendPasswordResetEmail(c core.Context, user *models.User, passwordResetToken string, backupLocale string) error

SendPasswordResetEmail sends password reset email according to specified parameters

type ServiceUsingConfig

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

ServiceUsingConfig represents a service that need to use config

func (*ServiceUsingConfig) CurrentConfig

func (s *ServiceUsingConfig) CurrentConfig() *settings.Config

CurrentConfig returns the current config

type ServiceUsingDB

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

ServiceUsingDB represents a service that need to use db

func (*ServiceUsingDB) TokenDB

func (s *ServiceUsingDB) TokenDB(uid int64) *datastore.Database

TokenDB returns the datastore which contains user token

func (*ServiceUsingDB) TokenDBByIndex added in v0.6.0

func (s *ServiceUsingDB) TokenDBByIndex(index int) *datastore.Database

TokenDBByIndex returns the datastore which contains user token by index

func (*ServiceUsingDB) TokenDBCount added in v0.6.0

func (s *ServiceUsingDB) TokenDBCount() int

TokenDBCount returns the count of datastores which contains user token

func (*ServiceUsingDB) UserDB

func (s *ServiceUsingDB) UserDB() *datastore.Database

UserDB returns the datastore which contains user

func (*ServiceUsingDB) UserDataDB

func (s *ServiceUsingDB) UserDataDB(uid int64) *datastore.Database

UserDataDB returns the datastore which contains user data

func (*ServiceUsingDB) UserDataDBByIndex added in v0.6.0

func (s *ServiceUsingDB) UserDataDBByIndex(index int) *datastore.Database

UserDataDBByIndex returns the datastore which contains user data by index

func (*ServiceUsingDB) UserDataDBCount added in v0.6.0

func (s *ServiceUsingDB) UserDataDBCount() int

UserDataDBCount returns the count of datastores which contains user data

type ServiceUsingMailer added in v0.4.0

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

ServiceUsingMailer represents a service that need to use mailer

func (*ServiceUsingMailer) SendMail added in v0.4.0

func (s *ServiceUsingMailer) SendMail(message *mail.MailMessage) error

SendMail sends an email according to argument

type ServiceUsingStorage added in v0.6.0

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

ServiceUsingStorage represents a service that need to use storage

func (*ServiceUsingStorage) DeleteAvatar added in v0.6.0

func (s *ServiceUsingStorage) DeleteAvatar(uid int64, fileExtension string) error

DeleteAvatar returns whether delete the user avatar from the current avatar object storage successfully

func (*ServiceUsingStorage) DeleteTransactionPicture added in v0.6.0

func (s *ServiceUsingStorage) DeleteTransactionPicture(uid int64, pictureId int64, fileExtension string) error

DeleteTransactionPicture returns whether delete the transaction picture from the current transaction picture object storage successfully

func (*ServiceUsingStorage) ExistsAvatar added in v0.6.0

func (s *ServiceUsingStorage) ExistsAvatar(uid int64, fileExtension string) (bool, error)

ExistsAvatar returns whether the user avatar exists from the current avatar object storage

func (*ServiceUsingStorage) ExistsTransactionPicture added in v0.6.0

func (s *ServiceUsingStorage) ExistsTransactionPicture(uid int64, pictureId int64, fileExtension string) (bool, error)

ExistsTransactionPicture returns whether the transaction picture exists from the current transaction picture object storage

func (*ServiceUsingStorage) ReadAvatar added in v0.6.0

func (s *ServiceUsingStorage) ReadAvatar(uid int64, fileExtension string) (storage.ObjectInStorage, error)

ReadAvatar returns the user avatar from the current avatar object storage

func (*ServiceUsingStorage) ReadTransactionPicture added in v0.6.0

func (s *ServiceUsingStorage) ReadTransactionPicture(uid int64, pictureId int64, fileExtension string) (storage.ObjectInStorage, error)

ReadTransactionPicture returns the transaction picture from the current transaction picture object storage

func (*ServiceUsingStorage) SaveAvatar added in v0.6.0

func (s *ServiceUsingStorage) SaveAvatar(uid int64, object storage.ObjectInStorage, fileExtension string) error

SaveAvatar returns whether save the user avatar into the current avatar object storage successfully

func (*ServiceUsingStorage) SaveTransactionPicture added in v0.6.0

func (s *ServiceUsingStorage) SaveTransactionPicture(uid int64, pictureId int64, object storage.ObjectInStorage, fileExtension string) error

SaveTransactionPicture returns whether save the transaction picture into the current transaction picture object storage successfully

type ServiceUsingUuid

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

ServiceUsingUuid represents a service that need to use uuid

func (*ServiceUsingUuid) GenerateUuid

func (s *ServiceUsingUuid) GenerateUuid(uuidType uuid.UuidType) int64

GenerateUuid generates a new uuid according to given uuid type

func (*ServiceUsingUuid) GenerateUuids added in v0.2.0

func (s *ServiceUsingUuid) GenerateUuids(uuidType uuid.UuidType, count uint16) []int64

GenerateUuids generates new uuids according to given uuid type and count

type TokenService

type TokenService struct {
	ServiceUsingDB
	ServiceUsingConfig
}

TokenService represents user token service

func (*TokenService) CreateEmailVerifyToken added in v0.4.0

func (s *TokenService) CreateEmailVerifyToken(c *core.WebContext, user *models.User) (string, *core.UserTokenClaims, error)

CreateEmailVerifyToken generates a new email verify token and saves to database

func (*TokenService) CreateEmailVerifyTokenWithoutUserAgent added in v0.6.0

func (s *TokenService) CreateEmailVerifyTokenWithoutUserAgent(c core.Context, user *models.User) (string, *core.UserTokenClaims, error)

CreateEmailVerifyTokenWithoutUserAgent generates a new email verify token and saves to database

func (*TokenService) CreatePasswordResetToken added in v0.4.0

func (s *TokenService) CreatePasswordResetToken(c *core.WebContext, user *models.User) (string, *core.UserTokenClaims, error)

CreatePasswordResetToken generates a new password reset token and saves to database

func (*TokenService) CreatePasswordResetTokenWithoutUserAgent added in v0.6.0

func (s *TokenService) CreatePasswordResetTokenWithoutUserAgent(c core.Context, user *models.User) (string, *core.UserTokenClaims, error)

CreatePasswordResetTokenWithoutUserAgent generates a new password reset token and saves to database

func (*TokenService) CreateRequire2FAToken

func (s *TokenService) CreateRequire2FAToken(c *core.WebContext, user *models.User) (string, *core.UserTokenClaims, error)

CreateRequire2FAToken generates a new token requiring user to verify 2fa passcode and saves to database

func (*TokenService) CreateToken

func (s *TokenService) CreateToken(c *core.WebContext, user *models.User) (string, *core.UserTokenClaims, error)

CreateToken generates a new normal token and saves to database

func (*TokenService) CreateTokenViaCli added in v0.7.0

func (s *TokenService) CreateTokenViaCli(c *core.CliContext, user *models.User) (string, *models.TokenRecord, error)

CreateTokenViaCli generates a new normal token and saves to database

func (*TokenService) DeleteAllExpiredTokens added in v0.6.0

func (s *TokenService) DeleteAllExpiredTokens(c core.Context) error

DeleteAllExpiredTokens deletes all expired tokens

func (*TokenService) DeleteToken

func (s *TokenService) DeleteToken(c core.Context, tokenRecord *models.TokenRecord) error

DeleteToken deletes given token from database

func (*TokenService) DeleteTokenByClaims

func (s *TokenService) DeleteTokenByClaims(c core.Context, claims *core.UserTokenClaims) error

DeleteTokenByClaims deletes given token from database

func (*TokenService) DeleteTokens

func (s *TokenService) DeleteTokens(c core.Context, uid int64, tokenRecords []*models.TokenRecord) error

DeleteTokens deletes given tokens from database

func (*TokenService) DeleteTokensBeforeTime

func (s *TokenService) DeleteTokensBeforeTime(c core.Context, uid int64, createTime int64) error

DeleteTokensBeforeTime deletes tokens that is created before specific time

func (*TokenService) DeleteTokensByType added in v0.4.0

func (s *TokenService) DeleteTokensByType(c core.Context, uid int64, tokenType core.TokenType) error

DeleteTokensByType deletes specified type tokens

func (*TokenService) ExistsValidTokenByType added in v0.4.0

func (s *TokenService) ExistsValidTokenByType(c core.Context, uid int64, tokenType core.TokenType) (bool, error)

ExistsValidTokenByType returns whether the given token type exists

func (*TokenService) GenerateTokenId

func (s *TokenService) GenerateTokenId(tokenRecord *models.TokenRecord) string

GenerateTokenId generates token id according to token model

func (*TokenService) GetAllTokensByUid

func (s *TokenService) GetAllTokensByUid(c core.Context, uid int64) ([]*models.TokenRecord, error)

GetAllTokensByUid returns all token models of given user

func (*TokenService) GetAllUnexpiredNormalTokensByUid

func (s *TokenService) GetAllUnexpiredNormalTokensByUid(c core.Context, uid int64) ([]*models.TokenRecord, error)

GetAllUnexpiredNormalTokensByUid returns all available token models of given user

func (*TokenService) ParseFromTokenId

func (s *TokenService) ParseFromTokenId(tokenId string) (*models.TokenRecord, error)

ParseFromTokenId returns token model according to token id

func (*TokenService) ParseTokenByArgument added in v0.3.0

func (s *TokenService) ParseTokenByArgument(c *core.WebContext, tokenParameterName string) (*jwt.Token, *core.UserTokenClaims, error)

ParseTokenByArgument returns the token model according to request data

func (*TokenService) ParseTokenByCookie added in v0.4.0

func (s *TokenService) ParseTokenByCookie(c *core.WebContext, tokenCookieName string) (*jwt.Token, *core.UserTokenClaims, error)

ParseTokenByCookie returns the token model according to request data

func (*TokenService) ParseTokenByHeader added in v0.3.0

func (s *TokenService) ParseTokenByHeader(c *core.WebContext) (*jwt.Token, *core.UserTokenClaims, error)

ParseTokenByHeader returns the token model according to request data

func (*TokenService) UpdateTokenLastSeen added in v0.5.0

func (s *TokenService) UpdateTokenLastSeen(c core.Context, tokenRecord *models.TokenRecord) error

UpdateTokenLastSeen updates the last seen time of specified token

type TransactionCategoryService

type TransactionCategoryService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

TransactionCategoryService represents transaction category service

func (*TransactionCategoryService) CreateCategories

CreateCategories saves a few transaction category models to database

func (*TransactionCategoryService) CreateCategory

func (s *TransactionCategoryService) CreateCategory(c core.Context, category *models.TransactionCategory) error

CreateCategory saves a new transaction category model to database

func (*TransactionCategoryService) DeleteAllCategories

func (s *TransactionCategoryService) DeleteAllCategories(c core.Context, uid int64) error

DeleteAllCategories deletes all existed transaction categories from database

func (*TransactionCategoryService) DeleteCategory

func (s *TransactionCategoryService) DeleteCategory(c core.Context, uid int64, categoryId int64) error

DeleteCategory deletes an existed transaction category from database

func (*TransactionCategoryService) GetAllCategoriesByUid

func (s *TransactionCategoryService) GetAllCategoriesByUid(c core.Context, uid int64, categoryType models.TransactionCategoryType, parentCategoryId int64) ([]*models.TransactionCategory, error)

GetAllCategoriesByUid returns all transaction category models of user

func (*TransactionCategoryService) GetCategoriesByCategoryIds

func (s *TransactionCategoryService) GetCategoriesByCategoryIds(c core.Context, uid int64, categoryIds []int64) (map[int64]*models.TransactionCategory, error)

GetCategoriesByCategoryIds returns transaction category models according to transaction category ids

func (*TransactionCategoryService) GetCategoryByCategoryId

func (s *TransactionCategoryService) GetCategoryByCategoryId(c core.Context, uid int64, categoryId int64) (*models.TransactionCategory, error)

GetCategoryByCategoryId returns a transaction category model according to transaction category id

func (*TransactionCategoryService) GetCategoryMapByList

func (s *TransactionCategoryService) GetCategoryMapByList(categories []*models.TransactionCategory) map[int64]*models.TransactionCategory

GetCategoryMapByList returns a transaction category map by a list

func (*TransactionCategoryService) GetCategoryNameMapByList added in v0.6.0

func (s *TransactionCategoryService) GetCategoryNameMapByList(categories []*models.TransactionCategory) (expenseCategoryMap map[string]*models.TransactionCategory, incomeCategoryMap map[string]*models.TransactionCategory, transferCategoryMap map[string]*models.TransactionCategory)

GetCategoryNameMapByList returns a transaction category map by a list

func (*TransactionCategoryService) GetCategoryNames added in v0.6.0

func (s *TransactionCategoryService) GetCategoryNames(categories []*models.TransactionCategory) []string

GetCategoryNames returns a list with transaction category names from transaction category models list

func (*TransactionCategoryService) GetMaxDisplayOrder

func (s *TransactionCategoryService) GetMaxDisplayOrder(c core.Context, uid int64, categoryType models.TransactionCategoryType) (int32, error)

GetMaxDisplayOrder returns the max display order according to transaction category type

func (*TransactionCategoryService) GetMaxSubCategoryDisplayOrder

func (s *TransactionCategoryService) GetMaxSubCategoryDisplayOrder(c core.Context, uid int64, categoryType models.TransactionCategoryType, parentCategoryId int64) (int32, error)

GetMaxSubCategoryDisplayOrder returns the max display order of sub transaction category according to transaction category type and parent transaction category id

func (*TransactionCategoryService) GetSubCategoriesByCategoryIds added in v0.5.0

func (s *TransactionCategoryService) GetSubCategoriesByCategoryIds(c core.Context, uid int64, categoryIds []int64) ([]*models.TransactionCategory, error)

GetSubCategoriesByCategoryIds returns sub-category models according to category ids

func (*TransactionCategoryService) GetTotalCategoryCountByUid added in v0.2.0

func (s *TransactionCategoryService) GetTotalCategoryCountByUid(c core.Context, uid int64) (int64, error)

GetTotalCategoryCountByUid returns total category count of user

func (*TransactionCategoryService) HideCategory

func (s *TransactionCategoryService) HideCategory(c core.Context, uid int64, ids []int64, hidden bool) error

HideCategory updates hidden field of given transaction categories

func (*TransactionCategoryService) ModifyCategory

func (s *TransactionCategoryService) ModifyCategory(c core.Context, category *models.TransactionCategory) error

ModifyCategory saves an existed transaction category model to database

func (*TransactionCategoryService) ModifyCategoryDisplayOrders

func (s *TransactionCategoryService) ModifyCategoryDisplayOrders(c core.Context, uid int64, categories []*models.TransactionCategory) error

ModifyCategoryDisplayOrders updates display order of given transaction categories

type TransactionPictureService added in v0.6.0

type TransactionPictureService struct {
	ServiceUsingDB
	ServiceUsingUuid
	ServiceUsingStorage
}

TransactionPictureService represents transaction picture service

func (*TransactionPictureService) GetNewPictureInfosByPictureIds added in v0.6.0

func (s *TransactionPictureService) GetNewPictureInfosByPictureIds(c core.Context, uid int64, pictureIds []int64) ([]*models.TransactionPictureInfo, error)

GetNewPictureInfosByPictureIds returns new transaction picture info models according to transaction picture ids

func (*TransactionPictureService) GetPictureByPictureId added in v0.6.0

func (s *TransactionPictureService) GetPictureByPictureId(c core.Context, uid int64, pictureId int64, fileExtension string) ([]byte, error)

GetPictureByPictureId returns the transaction picture data according to transaction picture id

func (*TransactionPictureService) GetPictureInfoByPictureId added in v0.6.0

func (s *TransactionPictureService) GetPictureInfoByPictureId(c core.Context, uid int64, pictureId int64) (*models.TransactionPictureInfo, error)

GetPictureInfoByPictureId returns a transaction picture info model according to transaction picture id

func (*TransactionPictureService) GetPictureInfoListMapByList added in v0.6.0

func (s *TransactionPictureService) GetPictureInfoListMapByList(pictureInfos []*models.TransactionPictureInfo) map[int64][]*models.TransactionPictureInfo

GetPictureInfoListMapByList returns a transaction picture info list map by a list

func (*TransactionPictureService) GetPictureInfoMapByList added in v0.6.0

func (s *TransactionPictureService) GetPictureInfoMapByList(pictureInfos []*models.TransactionPictureInfo) map[int64]*models.TransactionPictureInfo

GetPictureInfoMapByList returns a transaction picture info list map by a list

func (*TransactionPictureService) GetPictureInfosByTransactionId added in v0.6.0

func (s *TransactionPictureService) GetPictureInfosByTransactionId(c core.Context, uid int64, transactionId int64) ([]*models.TransactionPictureInfo, error)

GetPictureInfosByTransactionId returns transaction picture info models according to transaction id

func (*TransactionPictureService) GetPictureInfosByTransactionIds added in v0.6.0

func (s *TransactionPictureService) GetPictureInfosByTransactionIds(c core.Context, uid int64, transactionIds []int64) (map[int64][]*models.TransactionPictureInfo, error)

GetPictureInfosByTransactionIds returns transaction picture info models according to transaction ids

func (*TransactionPictureService) GetTotalTransactionPicturesCountByUid added in v0.6.0

func (s *TransactionPictureService) GetTotalTransactionPicturesCountByUid(c core.Context, uid int64) (int64, error)

GetTotalTransactionPicturesCountByUid returns total transaction pictures count of user

func (*TransactionPictureService) GetTransactionPictureIds added in v0.6.0

func (s *TransactionPictureService) GetTransactionPictureIds(pictureInfos []*models.TransactionPictureInfo) []int64

GetTransactionPictureIds returns transaction picture ids list

func (*TransactionPictureService) RemoveUnusedTransactionPicture added in v0.6.0

func (s *TransactionPictureService) RemoveUnusedTransactionPicture(c core.Context, uid int64, pictureId int64) error

RemoveUnusedTransactionPicture removes the unused transaction picture of specified user

func (*TransactionPictureService) UploadPicture added in v0.6.0

func (s *TransactionPictureService) UploadPicture(c core.Context, pictureInfo *models.TransactionPictureInfo, pictureFile multipart.File) error

UploadPicture uploads the transaction picture for specified user

type TransactionService

type TransactionService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

TransactionService represents transaction service

func (*TransactionService) BatchCreateTransactions added in v0.6.0

func (s *TransactionService) BatchCreateTransactions(c core.Context, uid int64, transactions []*models.Transaction, allTagIds map[int][]int64) error

BatchCreateTransactions saves new transactions to database

func (*TransactionService) CreateScheduledTransactions added in v0.6.0

func (s *TransactionService) CreateScheduledTransactions(c core.Context, currentUnixTime int64, interval time.Duration) error

CreateScheduledTransactions saves all scheduled transactions that should be created now

func (*TransactionService) CreateTransaction

func (s *TransactionService) CreateTransaction(c core.Context, transaction *models.Transaction, tagIds []int64, pictureIds []int64) error

CreateTransaction saves a new transaction to database

func (*TransactionService) DeleteAllTransactions

func (s *TransactionService) DeleteAllTransactions(c core.Context, uid int64) error

DeleteAllTransactions deletes all existed transactions from database

func (*TransactionService) DeleteTransaction

func (s *TransactionService) DeleteTransaction(c core.Context, uid int64, transactionId int64) error

DeleteTransaction deletes an existed transaction from database

func (*TransactionService) GetAccountsAndCategoriesMonthlyIncomeAndExpense added in v0.5.0

func (s *TransactionService) GetAccountsAndCategoriesMonthlyIncomeAndExpense(c core.Context, uid int64, startYear int32, startMonth int32, endYear int32, endMonth int32, tagIds []int64, noTags bool, tagFilterType models.TransactionTagFilterType, utcOffset int16, useTransactionTimezone bool) (map[int32][]*models.Transaction, error)

GetAccountsAndCategoriesMonthlyIncomeAndExpense returns the every accounts monthly income and expense amount by specific date range

func (*TransactionService) GetAccountsAndCategoriesTotalIncomeAndExpense

func (s *TransactionService) GetAccountsAndCategoriesTotalIncomeAndExpense(c core.Context, uid int64, startUnixTime int64, endUnixTime int64, tagIds []int64, noTags bool, tagFilterType models.TransactionTagFilterType, utcOffset int16, useTransactionTimezone bool) ([]*models.Transaction, error)

GetAccountsAndCategoriesTotalIncomeAndExpense returns the every accounts and categories total income and expense amount by specific date range

func (*TransactionService) GetAccountsTotalIncomeAndExpense

func (s *TransactionService) GetAccountsTotalIncomeAndExpense(c core.Context, uid int64, startUnixTime int64, endUnixTime int64, utcOffset int16, useTransactionTimezone bool) (map[int64]int64, map[int64]int64, error)

GetAccountsTotalIncomeAndExpense returns the every accounts total income and expense amount by specific date range

func (*TransactionService) GetAllTransactionCount

func (s *TransactionService) GetAllTransactionCount(c core.Context, uid int64) (int64, error)

GetAllTransactionCount returns total count of transactions

func (*TransactionService) GetAllTransactions

func (s *TransactionService) GetAllTransactions(c core.Context, uid int64, pageCount int32, noDuplicated bool) ([]*models.Transaction, error)

GetAllTransactions returns all transactions

func (*TransactionService) GetAllTransactionsByMaxTime

func (s *TransactionService) GetAllTransactionsByMaxTime(c core.Context, uid int64, maxTransactionTime int64, count int32, noDuplicated bool) ([]*models.Transaction, error)

GetAllTransactionsByMaxTime returns all transactions before given time

func (*TransactionService) GetRelatedTransferTransaction

func (s *TransactionService) GetRelatedTransferTransaction(originalTransaction *models.Transaction) *models.Transaction

GetRelatedTransferTransaction returns the related transaction for transfer transaction

func (*TransactionService) GetTotalTransactionCountByUid added in v0.2.0

func (s *TransactionService) GetTotalTransactionCountByUid(c core.Context, uid int64) (int64, error)

GetTotalTransactionCountByUid returns total transaction count of user

func (*TransactionService) GetTransactionByTransactionId

func (s *TransactionService) GetTransactionByTransactionId(c core.Context, uid int64, transactionId int64) (*models.Transaction, error)

GetTransactionByTransactionId returns a transaction model according to transaction id

func (*TransactionService) GetTransactionCount

func (s *TransactionService) GetTransactionCount(c core.Context, uid int64, maxTransactionTime int64, minTransactionTime int64, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, tagIds []int64, noTags bool, tagFilterType models.TransactionTagFilterType, amountFilter string, keyword string) (int64, error)

GetTransactionCount returns count of transactions

func (*TransactionService) GetTransactionIds added in v0.6.0

func (s *TransactionService) GetTransactionIds(transactions []*models.Transaction) []int64

GetTransactionIds returns transaction ids list

func (*TransactionService) GetTransactionMapByList

func (s *TransactionService) GetTransactionMapByList(transactions []*models.Transaction) map[int64]*models.Transaction

GetTransactionMapByList returns a transaction map by a list

func (*TransactionService) GetTransactionsByMaxTime

func (s *TransactionService) GetTransactionsByMaxTime(c core.Context, uid int64, maxTransactionTime int64, minTransactionTime int64, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, tagIds []int64, noTags bool, tagFilterType models.TransactionTagFilterType, amountFilter string, keyword string, page int32, count int32, needOneMoreItem bool, noDuplicated bool) ([]*models.Transaction, error)

GetTransactionsByMaxTime returns transactions before given time

func (*TransactionService) GetTransactionsInMonthByPage

func (s *TransactionService) GetTransactionsInMonthByPage(c core.Context, uid int64, year int32, month int32, transactionType models.TransactionDbType, categoryIds []int64, accountIds []int64, tagIds []int64, noTags bool, tagFilterType models.TransactionTagFilterType, amountFilter string, keyword string) ([]*models.Transaction, error)

GetTransactionsInMonthByPage returns all transactions in given year and month

func (*TransactionService) ModifyTransaction

func (s *TransactionService) ModifyTransaction(c core.Context, transaction *models.Transaction, currentTagIdsCount int, addTagIds []int64, removeTagIds []int64, addPictureIds []int64, removePictureIds []int64) error

ModifyTransaction saves an existed transaction to database

type TransactionTagService

type TransactionTagService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

TransactionTagService represents transaction tag service

func (*TransactionTagService) CreateTag

CreateTag saves a new transaction tag model to database

func (*TransactionTagService) DeleteAllTags

func (s *TransactionTagService) DeleteAllTags(c core.Context, uid int64) error

DeleteAllTags deletes all existed transaction tags from database

func (*TransactionTagService) DeleteTag

func (s *TransactionTagService) DeleteTag(c core.Context, uid int64, tagId int64) error

DeleteTag deletes an existed transaction tag from database

func (*TransactionTagService) ExistsTagName

func (s *TransactionTagService) ExistsTagName(c core.Context, uid int64, name string) (bool, error)

ExistsTagName returns whether the given tag name exists

func (*TransactionTagService) GetAllTagIdsMapOfAllTransactions added in v0.5.0

func (s *TransactionTagService) GetAllTagIdsMapOfAllTransactions(c core.Context, uid int64) (map[int64][]int64, error)

GetAllTagIdsMapOfAllTransactions returns all transaction tag ids map grouped by transaction id

func (*TransactionTagService) GetAllTagIdsOfAllTransactions

func (s *TransactionTagService) GetAllTagIdsOfAllTransactions(c core.Context, uid int64) ([]*models.TransactionTagIndex, error)

GetAllTagIdsOfAllTransactions returns all transaction tag ids

func (*TransactionTagService) GetAllTagIdsOfTransactions

func (s *TransactionTagService) GetAllTagIdsOfTransactions(c core.Context, uid int64, transactionIds []int64) (map[int64][]int64, error)

GetAllTagIdsOfTransactions returns transaction tag ids for given transactions

func (*TransactionTagService) GetAllTagsByUid

func (s *TransactionTagService) GetAllTagsByUid(c core.Context, uid int64) ([]*models.TransactionTag, error)

GetAllTagsByUid returns all transaction tag models of user

func (*TransactionTagService) GetGroupedTransactionTagIds added in v0.5.0

func (s *TransactionTagService) GetGroupedTransactionTagIds(tagIndexes []*models.TransactionTagIndex) map[int64][]int64

func (*TransactionTagService) GetMaxDisplayOrder

func (s *TransactionTagService) GetMaxDisplayOrder(c core.Context, uid int64) (int32, error)

GetMaxDisplayOrder returns the max display order

func (*TransactionTagService) GetTagByTagId

func (s *TransactionTagService) GetTagByTagId(c core.Context, uid int64, tagId int64) (*models.TransactionTag, error)

GetTagByTagId returns a transaction tag model according to transaction tag id

func (*TransactionTagService) GetTagMapByList

func (s *TransactionTagService) GetTagMapByList(tags []*models.TransactionTag) map[int64]*models.TransactionTag

GetTagMapByList returns a transaction tag map by a list

func (*TransactionTagService) GetTagNameMapByList added in v0.6.0

func (s *TransactionTagService) GetTagNameMapByList(tags []*models.TransactionTag) map[string]*models.TransactionTag

GetTagNameMapByList returns a transaction tag map by a list

func (*TransactionTagService) GetTagNames added in v0.6.0

func (s *TransactionTagService) GetTagNames(tags []*models.TransactionTag) []string

GetTagNames returns a list with tag names from tag models list

func (*TransactionTagService) GetTagsByTagIds

func (s *TransactionTagService) GetTagsByTagIds(c core.Context, uid int64, tagIds []int64) (map[int64]*models.TransactionTag, error)

GetTagsByTagIds returns transaction tag models according to transaction tag ids

func (*TransactionTagService) GetTotalTagCountByUid added in v0.2.0

func (s *TransactionTagService) GetTotalTagCountByUid(c core.Context, uid int64) (int64, error)

GetTotalTagCountByUid returns total tag count of user

func (*TransactionTagService) HideTag

func (s *TransactionTagService) HideTag(c core.Context, uid int64, ids []int64, hidden bool) error

HideTag updates hidden field of given transaction tags

func (*TransactionTagService) ModifyTag

ModifyTag saves an existed transaction tag model to database

func (*TransactionTagService) ModifyTagDisplayOrders

func (s *TransactionTagService) ModifyTagDisplayOrders(c core.Context, uid int64, tags []*models.TransactionTag) error

ModifyTagDisplayOrders updates display order of given transaction tags

func (*TransactionTagService) ModifyTagIndexTransactionTime added in v0.5.0

func (s *TransactionTagService) ModifyTagIndexTransactionTime(c core.Context, uid int64, tagIndexes []*models.TransactionTagIndex) error

ModifyTagIndexTransactionTime updates transaction time of given transaction tag indexes

type TransactionTemplateService added in v0.5.0

type TransactionTemplateService struct {
	ServiceUsingDB
	ServiceUsingUuid
}

TransactionTemplateService represents transaction template service

func (*TransactionTemplateService) CreateTemplate added in v0.5.0

func (s *TransactionTemplateService) CreateTemplate(c core.Context, template *models.TransactionTemplate) error

CreateTemplate saves a new transaction template model to database

func (*TransactionTemplateService) DeleteAllTemplates added in v0.5.0

func (s *TransactionTemplateService) DeleteAllTemplates(c core.Context, uid int64) error

DeleteAllTemplates deletes all existed transaction templates from database

func (*TransactionTemplateService) DeleteTemplate added in v0.5.0

func (s *TransactionTemplateService) DeleteTemplate(c core.Context, uid int64, templateId int64) error

DeleteTemplate deletes an existed transaction template from database

func (*TransactionTemplateService) GetAllTemplatesByUid added in v0.5.0

func (s *TransactionTemplateService) GetAllTemplatesByUid(c core.Context, uid int64, templateType models.TransactionTemplateType) ([]*models.TransactionTemplate, error)

GetAllTemplatesByUid returns all transaction template models of user

func (*TransactionTemplateService) GetMaxDisplayOrder added in v0.5.0

func (s *TransactionTemplateService) GetMaxDisplayOrder(c core.Context, uid int64, templateType models.TransactionTemplateType) (int32, error)

GetMaxDisplayOrder returns the max display order

func (*TransactionTemplateService) GetTemplateByTemplateId added in v0.5.0

func (s *TransactionTemplateService) GetTemplateByTemplateId(c core.Context, uid int64, templateId int64) (*models.TransactionTemplate, error)

GetTemplateByTemplateId returns a transaction template model according to transaction template id

func (*TransactionTemplateService) GetTotalNormalTemplateCountByUid added in v0.5.0

func (s *TransactionTemplateService) GetTotalNormalTemplateCountByUid(c core.Context, uid int64) (int64, error)

GetTotalNormalTemplateCountByUid returns total normal template count of user

func (*TransactionTemplateService) GetTotalScheduledTemplateCountByUid added in v0.6.0

func (s *TransactionTemplateService) GetTotalScheduledTemplateCountByUid(c core.Context, uid int64) (int64, error)

GetTotalScheduledTemplateCountByUid returns total scheduled transaction count of user

func (*TransactionTemplateService) HideTemplate added in v0.5.0

func (s *TransactionTemplateService) HideTemplate(c core.Context, uid int64, ids []int64, hidden bool) error

HideTemplate updates hidden field of given transaction templates

func (*TransactionTemplateService) ModifyTemplate added in v0.5.0

func (s *TransactionTemplateService) ModifyTemplate(c core.Context, template *models.TransactionTemplate) error

ModifyTemplate saves an existed transaction template model to database

func (*TransactionTemplateService) ModifyTemplateDisplayOrders added in v0.5.0

func (s *TransactionTemplateService) ModifyTemplateDisplayOrders(c core.Context, uid int64, templates []*models.TransactionTemplate) error

ModifyTemplateDisplayOrders updates display order of given transaction templates

type TwoFactorAuthorizationService

type TwoFactorAuthorizationService struct {
	ServiceUsingDB
	ServiceUsingConfig
	ServiceUsingUuid
}

TwoFactorAuthorizationService represents 2fa service

func (*TwoFactorAuthorizationService) CreateTwoFactorRecoveryCodes

func (s *TwoFactorAuthorizationService) CreateTwoFactorRecoveryCodes(c core.Context, uid int64, recoveryCodes []string, salt string) error

CreateTwoFactorRecoveryCodes saves new 2fa recovery codes to database

func (*TwoFactorAuthorizationService) CreateTwoFactorSetting

func (s *TwoFactorAuthorizationService) CreateTwoFactorSetting(c core.Context, twoFactor *models.TwoFactor) error

CreateTwoFactorSetting saves a new 2fa setting to database

func (*TwoFactorAuthorizationService) DeleteTwoFactorRecoveryCodes

func (s *TwoFactorAuthorizationService) DeleteTwoFactorRecoveryCodes(c core.Context, uid int64) error

DeleteTwoFactorRecoveryCodes deletes existed 2fa recovery codes from database

func (*TwoFactorAuthorizationService) DeleteTwoFactorSetting

func (s *TwoFactorAuthorizationService) DeleteTwoFactorSetting(c core.Context, uid int64) error

DeleteTwoFactorSetting deletes an existed 2fa setting from database

func (*TwoFactorAuthorizationService) ExistsTwoFactorSetting

func (s *TwoFactorAuthorizationService) ExistsTwoFactorSetting(c core.Context, uid int64) (bool, error)

ExistsTwoFactorSetting returns whether the given user has existed 2fa setting

func (*TwoFactorAuthorizationService) GenerateTwoFactorRecoveryCodes

func (s *TwoFactorAuthorizationService) GenerateTwoFactorRecoveryCodes() ([]string, error)

GenerateTwoFactorRecoveryCodes generates new 2fa recovery codes

func (*TwoFactorAuthorizationService) GenerateTwoFactorSecret

func (s *TwoFactorAuthorizationService) GenerateTwoFactorSecret(c core.Context, user *models.User) (*otp.Key, error)

GenerateTwoFactorSecret generates a new 2fa secret

func (*TwoFactorAuthorizationService) GetAndUseUserTwoFactorRecoveryCode

func (s *TwoFactorAuthorizationService) GetAndUseUserTwoFactorRecoveryCode(c core.Context, uid int64, recoveryCode string, salt string) error

GetAndUseUserTwoFactorRecoveryCode checks whether the given 2fa recovery code exists and marks it used

func (*TwoFactorAuthorizationService) GetUserTwoFactorSettingByUid

func (s *TwoFactorAuthorizationService) GetUserTwoFactorSettingByUid(c core.Context, uid int64) (*models.TwoFactor, error)

GetUserTwoFactorSettingByUid returns the 2fa setting model according to user uid

type UserService

UserService represents user service

func (*UserService) AddUserFeatureRestriction added in v0.7.0

func (s *UserService) AddUserFeatureRestriction(c core.Context, username string, featureRestriction core.UserFeatureRestrictions) error

AddUserFeatureRestriction adds user user feature restrictions

func (*UserService) CreateUser

func (s *UserService) CreateUser(c core.Context, user *models.User) error

CreateUser saves a new user model to database

func (*UserService) DeleteUser

func (s *UserService) DeleteUser(c core.Context, username string) error

DeleteUser deletes an existed user from database

func (*UserService) DisableUser added in v0.4.0

func (s *UserService) DisableUser(c core.Context, username string) error

DisableUser sets user disabled

func (*UserService) EnableUser added in v0.4.0

func (s *UserService) EnableUser(c core.Context, username string) error

EnableUser sets user enabled

func (*UserService) ExistsEmail

func (s *UserService) ExistsEmail(c core.Context, email string) (bool, error)

ExistsEmail returns whether the given user email exists

func (*UserService) ExistsUsername

func (s *UserService) ExistsUsername(c core.Context, username string) (bool, error)

ExistsUsername returns whether the given user name exists

func (*UserService) GetUserAvatar added in v0.6.0

func (s *UserService) GetUserAvatar(c core.Context, uid int64, fileExtension string) ([]byte, error)

GetUserAvatar returns the user avatar image data according to user uid

func (*UserService) GetUserByEmail

func (s *UserService) GetUserByEmail(c core.Context, email string) (*models.User, error)

GetUserByEmail returns the user model according to user email

func (*UserService) GetUserById

func (s *UserService) GetUserById(c core.Context, uid int64) (*models.User, error)

GetUserById returns the user model according to user uid

func (*UserService) GetUserByUsername

func (s *UserService) GetUserByUsername(c core.Context, username string) (*models.User, error)

GetUserByUsername returns the user model according to user name

func (*UserService) GetUserByUsernameOrEmailAndPassword

func (s *UserService) GetUserByUsernameOrEmailAndPassword(c core.Context, loginname string, password string) (*models.User, error)

GetUserByUsernameOrEmailAndPassword returns the user model according to login name and password

func (*UserService) IsPasswordEqualsUserPassword

func (s *UserService) IsPasswordEqualsUserPassword(password string, user *models.User) bool

IsPasswordEqualsUserPassword returns whether the given password is correct

func (*UserService) RemoveUserAvatar added in v0.6.0

func (s *UserService) RemoveUserAvatar(c core.Context, uid int64, fileExtension string) error

RemoveUserAvatar removes the custom avatar type of specified user

func (*UserService) RemoveUserFeatureRestriction added in v0.7.0

func (s *UserService) RemoveUserFeatureRestriction(c core.Context, username string, featureRestriction core.UserFeatureRestrictions) error

RemoveUserFeatureRestriction removes user user feature restrictions

func (*UserService) SendVerifyEmail added in v0.4.0

func (s *UserService) SendVerifyEmail(user *models.User, verifyEmailToken string, backupLocale string) error

SendVerifyEmail sends verify email according to specified parameters

func (*UserService) SetUserEmailUnverified added in v0.4.0

func (s *UserService) SetUserEmailUnverified(c core.Context, username string) error

SetUserEmailUnverified sets user email address unverified

func (*UserService) SetUserEmailVerified added in v0.4.0

func (s *UserService) SetUserEmailVerified(c core.Context, username string) error

SetUserEmailVerified sets user email address verified

func (*UserService) UpdateUser

func (s *UserService) UpdateUser(c core.Context, user *models.User, modifyUserLanguage bool) (keyProfileUpdated bool, emailSetToUnverified bool, err error)

UpdateUser saves an existed user model to database

func (*UserService) UpdateUserAvatar added in v0.5.0

func (s *UserService) UpdateUserAvatar(c core.Context, uid int64, avatarFile multipart.File, fileExtension string, oldFileExtension string) error

UpdateUserAvatar updates the custom avatar type of specified user

func (*UserService) UpdateUserFeatureRestriction added in v0.7.0

func (s *UserService) UpdateUserFeatureRestriction(c core.Context, username string, featureRestriction core.UserFeatureRestrictions) error

UpdateUserFeatureRestriction sets user user feature restrictions

func (*UserService) UpdateUserLastLoginTime

func (s *UserService) UpdateUserLastLoginTime(c core.Context, uid int64) error

UpdateUserLastLoginTime updates the last login time field

Jump to

Keyboard shortcuts

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